radeonsi: rename a few R600/r600_ -> SI_/si_
[mesa.git] / src / gallium / drivers / radeonsi / si_cp_dma.c
index 89492d3500e1f4d44bc34c6487632ec0e3d5f825..ffdb78c3e404f20e60cc7444d5dfaa0666507a6a 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright 2013 Advanced Micro Devices, Inc.
+ * All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -60,9 +61,9 @@ static inline unsigned cp_dma_max_byte_count(struct si_context *sctx)
  */
 static void si_emit_cp_dma(struct si_context *sctx, uint64_t dst_va,
                           uint64_t src_va, unsigned size, unsigned flags,
-                          enum r600_coherency coher)
+                          enum si_coherency coher)
 {
-       struct radeon_winsys_cs *cs = sctx->b.gfx.cs;
+       struct radeon_winsys_cs *cs = sctx->b.gfx_cs;
        uint32_t header = 0, command = 0;
 
        assert(size);
@@ -122,31 +123,31 @@ static void si_emit_cp_dma(struct si_context *sctx, uint64_t dst_va,
         * indices. If we wanted to execute CP DMA in PFP, this packet
         * should precede it.
         */
-       if (coher == R600_COHERENCY_SHADER && flags & CP_DMA_SYNC) {
+       if (coher == SI_COHERENCY_SHADER && flags & CP_DMA_SYNC) {
                radeon_emit(cs, PKT3(PKT3_PFP_SYNC_ME, 0, 0));
                radeon_emit(cs, 0);
        }
 }
 
-static unsigned get_flush_flags(struct si_context *sctx, enum r600_coherency coher)
+static unsigned get_flush_flags(struct si_context *sctx, enum si_coherency coher)
 {
        switch (coher) {
        default:
-       case R600_COHERENCY_NONE:
+       case SI_COHERENCY_NONE:
                return 0;
-       case R600_COHERENCY_SHADER:
+       case SI_COHERENCY_SHADER:
                return SI_CONTEXT_INV_SMEM_L1 |
                       SI_CONTEXT_INV_VMEM_L1 |
                       (sctx->b.chip_class == SI ? SI_CONTEXT_INV_GLOBAL_L2 : 0);
-       case R600_COHERENCY_CB_META:
+       case SI_COHERENCY_CB_META:
                return SI_CONTEXT_FLUSH_AND_INV_CB;
        }
 }
 
-static unsigned get_tc_l2_flag(struct si_context *sctx, enum r600_coherency coher)
+static unsigned get_tc_l2_flag(struct si_context *sctx, enum si_coherency coher)
 {
-       if ((sctx->b.chip_class >= GFX9 && coher == R600_COHERENCY_CB_META) ||
-           (sctx->b.chip_class >= CIK && coher == R600_COHERENCY_SHADER))
+       if ((sctx->b.chip_class >= GFX9 && coher == SI_COHERENCY_CB_META) ||
+           (sctx->b.chip_class >= CIK && coher == SI_COHERENCY_SHADER))
                return CP_DMA_USE_L2;
 
        return 0;
@@ -165,21 +166,21 @@ static void si_cp_dma_prepare(struct si_context *sctx, struct pipe_resource *dst
 
        if (!(user_flags & SI_CPDMA_SKIP_BO_LIST_UPDATE)) {
                /* Count memory usage in so that need_cs_space can take it into account. */
-               r600_context_add_resource_size(&sctx->b.b, dst);
+               si_context_add_resource_size(sctx, dst);
                if (src)
-                       r600_context_add_resource_size(&sctx->b.b, src);
+                       si_context_add_resource_size(sctx, src);
        }
 
        if (!(user_flags & SI_CPDMA_SKIP_CHECK_CS_SPACE))
-               si_need_cs_space(sctx);
+               si_need_gfx_cs_space(sctx);
 
        /* This must be done after need_cs_space. */
        if (!(user_flags & SI_CPDMA_SKIP_BO_LIST_UPDATE)) {
-               radeon_add_to_buffer_list(&sctx->b, &sctx->b.gfx,
+               radeon_add_to_buffer_list(sctx, sctx->b.gfx_cs,
                                          (struct r600_resource*)dst,
                                          RADEON_USAGE_WRITE, RADEON_PRIO_CP_DMA);
                if (src)
-                       radeon_add_to_buffer_list(&sctx->b, &sctx->b.gfx,
+                       radeon_add_to_buffer_list(sctx, sctx->b.gfx_cs,
                                                  (struct r600_resource*)src,
                                                  RADEON_USAGE_READ, RADEON_PRIO_CP_DMA);
        }
@@ -203,11 +204,10 @@ static void si_cp_dma_prepare(struct si_context *sctx, struct pipe_resource *dst
                *packet_flags |= CP_DMA_SYNC;
 }
 
-void si_clear_buffer(struct pipe_context *ctx, struct pipe_resource *dst,
+void si_clear_buffer(struct si_context *sctx, struct pipe_resource *dst,
                     uint64_t offset, uint64_t size, unsigned value,
-                    enum r600_coherency coher)
+                    enum si_coherency coher)
 {
-       struct si_context *sctx = (struct si_context*)ctx;
        struct radeon_winsys *ws = sctx->b.ws;
        struct r600_resource *rdst = r600_resource(dst);
        unsigned tc_l2_flag = get_tc_l2_flag(sctx, coher);
@@ -228,7 +228,7 @@ void si_clear_buffer(struct pipe_context *ctx, struct pipe_resource *dst,
 
        /* dma_clear_buffer can use clear_buffer on failure. Make sure that
         * doesn't happen. We don't want an infinite recursion: */
-       if (sctx->b.dma.cs &&
+       if (sctx->b.dma_cs &&
            !(dst->flags & PIPE_RESOURCE_FLAG_SPARSE) &&
            (offset % 4 == 0) &&
            /* CP DMA is very slow. Always use SDMA for big clears. This
@@ -240,9 +240,9 @@ void si_clear_buffer(struct pipe_context *ctx, struct pipe_resource *dst,
              * si_emit_framebuffer_state (in a draw call) adds them.
              * For example, DeusEx:MD has 21 buffer clears per frame and all
              * of them are moved to SDMA thanks to this. */
-            !ws->cs_is_buffer_referenced(sctx->b.gfx.cs, rdst->buf,
+            !ws->cs_is_buffer_referenced(sctx->b.gfx_cs, rdst->buf,
                                          RADEON_USAGE_READWRITE))) {
-               sctx->b.dma_clear_buffer(ctx, dst, offset, dma_clear_size, value);
+               sctx->b.dma_clear_buffer(sctx, dst, offset, dma_clear_size, value);
 
                offset += dma_clear_size;
                size -= dma_clear_size;
@@ -274,7 +274,7 @@ void si_clear_buffer(struct pipe_context *ctx, struct pipe_resource *dst,
                        rdst->TC_L2_dirty = true;
 
                /* If it's not a framebuffer fast clear... */
-               if (coher == R600_COHERENCY_SHADER)
+               if (coher == SI_COHERENCY_SHADER)
                        sctx->b.num_cp_dma_calls++;
        }
 
@@ -286,7 +286,7 @@ void si_clear_buffer(struct pipe_context *ctx, struct pipe_resource *dst,
                assert(dst->target == PIPE_BUFFER);
                assert(size < 4);
 
-               pipe_buffer_write(ctx, dst, offset, size, &value);
+               pipe_buffer_write(&sctx->b.b, dst, offset, size, &value);
        }
 }
 
@@ -321,11 +321,11 @@ static void si_pipe_clear_buffer(struct pipe_context *ctx,
                        union pipe_color_union clear_value;
 
                        memcpy(&clear_value, clear_value_ptr, clear_value_size);
-                       si_blitter_begin(ctx, SI_DISABLE_RENDER_COND);
+                       si_blitter_begin(sctx, SI_DISABLE_RENDER_COND);
                        util_blitter_clear_buffer(sctx->blitter, dst, offset,
                                                  size, clear_value_size / 4,
                                                  &clear_value);
-                       si_blitter_end(ctx);
+                       si_blitter_end(sctx);
                        return;
                }
        }
@@ -346,8 +346,8 @@ static void si_pipe_clear_buffer(struct pipe_context *ctx,
                dword_value = *(uint32_t*)clear_value_ptr;
        }
 
-       si_clear_buffer(ctx, dst, offset, size, dword_value,
-                       R600_COHERENCY_SHADER);
+       si_clear_buffer(sctx, dst, offset, size, dword_value,
+                       SI_COHERENCY_SHADER);
 }
 
 /**
@@ -372,8 +372,8 @@ static void si_cp_dma_realign_engine(struct si_context *sctx, unsigned size,
            sctx->scratch_buffer->b.b.width0 < scratch_size) {
                r600_resource_reference(&sctx->scratch_buffer, NULL);
                sctx->scratch_buffer = (struct r600_resource*)
-                       si_aligned_buffer_create(&sctx->screen->b.b,
-                                                  R600_RESOURCE_FLAG_UNMAPPABLE,
+                       si_aligned_buffer_create(&sctx->screen->b,
+                                                  SI_RESOURCE_FLAG_UNMAPPABLE,
                                                   PIPE_USAGE_DEFAULT,
                                                   scratch_size, 256);
                if (!sctx->scratch_buffer)
@@ -388,7 +388,7 @@ static void si_cp_dma_realign_engine(struct si_context *sctx, unsigned size,
 
        va = sctx->scratch_buffer->gpu_address;
        si_emit_cp_dma(sctx, va, va + SI_CPDMA_ALIGNMENT, size, dma_flags,
-                      R600_COHERENCY_SHADER);
+                      SI_COHERENCY_SHADER);
 }
 
 /**
@@ -404,8 +404,8 @@ void si_copy_buffer(struct si_context *sctx,
        uint64_t main_dst_offset, main_src_offset;
        unsigned skipped_size = 0;
        unsigned realign_size = 0;
-       unsigned tc_l2_flag = get_tc_l2_flag(sctx, R600_COHERENCY_SHADER);
-       unsigned flush_flags = get_flush_flags(sctx, R600_COHERENCY_SHADER);
+       unsigned tc_l2_flag = get_tc_l2_flag(sctx, SI_COHERENCY_SHADER);
+       unsigned flush_flags = get_flush_flags(sctx, SI_COHERENCY_SHADER);
        bool is_first = true;
 
        if (!size)
@@ -462,7 +462,7 @@ void si_copy_buffer(struct si_context *sctx,
                                  user_flags, &is_first, &dma_flags);
 
                si_emit_cp_dma(sctx, main_dst_offset, main_src_offset,
-                              byte_count, dma_flags, R600_COHERENCY_SHADER);
+                              byte_count, dma_flags, SI_COHERENCY_SHADER);
 
                size -= byte_count;
                main_src_offset += byte_count;
@@ -478,7 +478,7 @@ void si_copy_buffer(struct si_context *sctx,
                                  &is_first, &dma_flags);
 
                si_emit_cp_dma(sctx, dst_offset, src_offset, skipped_size,
-                              dma_flags, R600_COHERENCY_SHADER);
+                              dma_flags, SI_COHERENCY_SHADER);
        }
 
        /* Finally, realign the engine if the size wasn't aligned. */
@@ -516,9 +516,8 @@ static void cik_prefetch_VBO_descriptors(struct si_context *sctx)
        if (!sctx->vertex_elements)
                return;
 
-       cik_prefetch_TC_L2_async(sctx, &sctx->vertex_buffers.buffer->b.b,
-                                sctx->vertex_buffers.gpu_address -
-                                sctx->vertex_buffers.buffer->gpu_address,
+       cik_prefetch_TC_L2_async(sctx, &sctx->vb_descriptors_buffer->b.b,
+                                sctx->vb_descriptors_offset,
                                 sctx->vertex_elements->desc_list_byte_size);
 }
 
@@ -591,5 +590,4 @@ void cik_emit_prefetch_L2(struct si_context *sctx)
 void si_init_cp_dma_functions(struct si_context *sctx)
 {
        sctx->b.b.clear_buffer = si_pipe_clear_buffer;
-       sctx->b.clear_buffer = si_clear_buffer;
 }