radeonsi/gfx9: make shader binaries use read-only memory
authorMarek Olšák <marek.olsak@amd.com>
Tue, 5 Dec 2017 12:32:47 +0000 (13:32 +0100)
committerMarek Olšák <marek.olsak@amd.com>
Wed, 6 Dec 2017 14:19:02 +0000 (15:19 +0100)
Tested-by: Dieter Nützel <Dieter@nuetzel-hh.de>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
src/gallium/drivers/radeon/r600_buffer_common.c
src/gallium/drivers/radeon/r600_pipe_common.h
src/gallium/drivers/radeonsi/si_pipe.c
src/gallium/drivers/radeonsi/si_pipe.h
src/gallium/drivers/radeonsi/si_shader.c

index 09075f3ea296fae9dc3bc2ac0959d487a12b6bce..aca536d7fd450e15f01739bf8e0481808b7414dc 100644 (file)
@@ -174,6 +174,9 @@ void si_init_resource_fields(struct si_screen *sscreen,
        if (sscreen->debug_flags & DBG(NO_WC))
                res->flags &= ~RADEON_FLAG_GTT_WC;
 
+       if (res->b.b.flags & R600_RESOURCE_FLAG_READ_ONLY)
+               res->flags |= RADEON_FLAG_READ_ONLY;
+
        /* Set expected VRAM and GART usage for the buffer. */
        res->vram_usage = 0;
        res->gart_usage = 0;
index 498a7418c0a20db9ec8c6c7a334e6fb004c8985a..d1fdea074e9699b9b550804fdc04dbd237ad8d08 100644 (file)
@@ -53,6 +53,7 @@ struct si_context;
 #define R600_RESOURCE_FLAG_FORCE_TILING                (PIPE_RESOURCE_FLAG_DRV_PRIV << 2)
 #define R600_RESOURCE_FLAG_DISABLE_DCC         (PIPE_RESOURCE_FLAG_DRV_PRIV << 3)
 #define R600_RESOURCE_FLAG_UNMAPPABLE          (PIPE_RESOURCE_FLAG_DRV_PRIV << 4)
+#define R600_RESOURCE_FLAG_READ_ONLY           (PIPE_RESOURCE_FLAG_DRV_PRIV << 5)
 
 /* Debug flags. */
 enum {
index 5d7837dd1166af71dc28f71595edaeda037bef74..676d199618bf3412e91aa9e976126f8fd41c6043 100644 (file)
@@ -829,6 +829,8 @@ struct pipe_screen *radeonsi_screen_create(struct radeon_winsys *ws,
                (sscreen->debug_flags & DBG(DCC_MSAA) ||
                 sscreen->info.chip_class == VI);
 
+       sscreen->cpdma_prefetch_writes_memory = sscreen->info.chip_class <= VI;
+
        (void) mtx_init(&sscreen->shader_parts_mutex, mtx_plain);
        sscreen->use_monolithic_shaders =
                (sscreen->debug_flags & DBG(MONOLITHIC_SHADERS)) != 0;
index 7a099376021779a17ee39179b929f852ccc3254a..3a959f98da5386374d455c41874a2955acac97fd 100644 (file)
@@ -123,6 +123,7 @@ struct si_screen {
        bool                            has_rbplus;     /* if RB+ registers exist */
        bool                            rbplus_allowed; /* if RB+ is allowed */
        bool                            dcc_msaa_allowed;
+       bool                            cpdma_prefetch_writes_memory;
 
        struct slab_parent_pool         pool_transfers;
 
index 6a1293b99d1ac8da911ab663489ea798f69e2bb6..5da9ec0bf54bc3c723a7dd190587fcc04f88aea5 100644 (file)
@@ -5057,9 +5057,12 @@ int si_shader_binary_upload(struct si_screen *sscreen, struct si_shader *shader)
 
        r600_resource_reference(&shader->bo, NULL);
        shader->bo = (struct r600_resource*)
-                    pipe_buffer_create(&sscreen->b, 0,
-                                       PIPE_USAGE_IMMUTABLE,
-                                       align(bo_size, SI_CPDMA_ALIGNMENT));
+                    si_aligned_buffer_create(&sscreen->b,
+                                             sscreen->cpdma_prefetch_writes_memory ?
+                                               0 : R600_RESOURCE_FLAG_READ_ONLY,
+                                              PIPE_USAGE_IMMUTABLE,
+                                              align(bo_size, SI_CPDMA_ALIGNMENT),
+                                              256);
        if (!shader->bo)
                return -ENOMEM;