radv: Add bound checking workaround for dynamic buffers.
authorBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Thu, 19 Apr 2018 05:29:03 +0000 (07:29 +0200)
committerBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Thu, 19 Apr 2018 14:13:25 +0000 (16:13 +0200)
I have seen a few applications and games do the dynamic buffer bounds incorrectly, this
make it easier to work around, e.g. for debugging.

Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
src/amd/vulkan/radv_cmd_buffer.c
src/amd/vulkan/radv_debug.h
src/amd/vulkan/radv_device.c

index f6b23f6e739903e85ccdff22161635415f32e0cc..1afdeda486515861e5025ab09008b6b0e079036f 100644 (file)
@@ -2224,6 +2224,8 @@ void radv_CmdBindDescriptorSets(
        RADV_FROM_HANDLE(radv_pipeline_layout, layout, _layout);
        unsigned dyn_idx = 0;
 
+       const bool no_dynamic_bounds = cmd_buffer->device->instance->debug_flags & RADV_DEBUG_NO_DYNAMIC_BOUNDS;
+
        for (unsigned i = 0; i < descriptorSetCount; ++i) {
                unsigned idx = i + firstSet;
                RADV_FROM_HANDLE(radv_descriptor_set, set, pDescriptorSets[i]);
@@ -2238,7 +2240,7 @@ void radv_CmdBindDescriptorSets(
                        uint64_t va = range->va + pDynamicOffsets[dyn_idx];
                        dst[0] = va;
                        dst[1] = S_008F04_BASE_ADDRESS_HI(va >> 32);
-                       dst[2] = range->size;
+                       dst[2] = no_dynamic_bounds ? 0xffffffffu : range->size;
                        dst[3] = S_008F0C_DST_SEL_X(V_008F0C_SQ_SEL_X) |
                                 S_008F0C_DST_SEL_Y(V_008F0C_SQ_SEL_Y) |
                                 S_008F0C_DST_SEL_Z(V_008F0C_SQ_SEL_Z) |
index 79c624aec1d70bf23eafa00bc679057fb9dc3b85..03f218fcda8364f1854960031336b826169ca69b 100644 (file)
@@ -43,6 +43,7 @@ enum {
        RADV_DEBUG_SYNC_SHADERS      = 0x2000,
        RADV_DEBUG_NO_SISCHED        = 0x4000,
        RADV_DEBUG_PREOPTIR          = 0x8000,
+       RADV_DEBUG_NO_DYNAMIC_BOUNDS = 0x10000,
 };
 
 enum {
index 14ecbd020014404cee96f1eb390e8fe57930166c..4f384163b8627ed5243e76592dcc22cc783b5198 100644 (file)
@@ -386,6 +386,7 @@ static const struct debug_control radv_debug_options[] = {
        {"syncshaders", RADV_DEBUG_SYNC_SHADERS},
        {"nosisched", RADV_DEBUG_NO_SISCHED},
        {"preoptir", RADV_DEBUG_PREOPTIR},
+       {"nodynamicbounds", RADV_DEBUG_NO_DYNAMIC_BOUNDS},
        {NULL, 0}
 };