radv: use num_patches output from tcs shader.
authorDave Airlie <airlied@redhat.com>
Tue, 20 Feb 2018 01:22:07 +0000 (11:22 +1000)
committerDave Airlie <airlied@redhat.com>
Fri, 16 Mar 2018 05:23:05 +0000 (05:23 +0000)
Instead of recalculating the value, use the shader calculated value.

Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
src/amd/vulkan/radv_pipeline.c

index b4e96238d7665291715142fa51f24ff96b18c18f..898124fa827e2f97e86bf19c828767afaef14bcc 100644 (file)
@@ -1311,7 +1311,7 @@ calculate_tess_state(struct radv_pipeline *pipeline,
        unsigned num_tcs_patch_outputs;
        unsigned input_vertex_size, output_vertex_size, pervertex_output_patch_size;
        unsigned input_patch_size, output_patch_size, output_patch0_offset;
-       unsigned lds_size, hardware_lds_size;
+       unsigned lds_size;
        unsigned num_patches;
        struct radv_tessellation_state tess = {0};
 
@@ -1334,34 +1334,8 @@ calculate_tess_state(struct radv_pipeline *pipeline,
 
        pervertex_output_patch_size = num_tcs_output_cp * output_vertex_size;
        output_patch_size = pervertex_output_patch_size + num_tcs_patch_outputs * 16;
-       /* Ensure that we only need one wave per SIMD so we don't need to check
-        * resource usage. Also ensures that the number of tcs in and out
-        * vertices per threadgroup are at most 256.
-        */
-       num_patches = 64 / MAX2(num_tcs_input_cp, num_tcs_output_cp) * 4;
-
-       /* Make sure that the data fits in LDS. This assumes the shaders only
-        * use LDS for the inputs and outputs.
-        */
-       hardware_lds_size = pipeline->device->physical_device->rad_info.chip_class >= CIK ? 65536 : 32768;
-       num_patches = MIN2(num_patches, hardware_lds_size / (input_patch_size + output_patch_size));
-
-       /* Make sure the output data fits in the offchip buffer */
-       num_patches = MIN2(num_patches,
-                           (pipeline->device->tess_offchip_block_dw_size * 4) /
-                           output_patch_size);
-
-       /* Not necessary for correctness, but improves performance. The
-        * specific value is taken from the proprietary driver.
-        */
-       num_patches = MIN2(num_patches, 40);
-
-       /* SI bug workaround - limit LS-HS threadgroups to only one wave. */
-       if (pipeline->device->physical_device->rad_info.chip_class == SI) {
-               unsigned one_wave = 64 / MAX2(num_tcs_input_cp, num_tcs_output_cp);
-               num_patches = MIN2(num_patches, one_wave);
-       }
 
+       num_patches = pipeline->shaders[MESA_SHADER_TESS_CTRL]->info.tcs.num_patches;
        output_patch0_offset = input_patch_size * num_patches;
 
        lds_size = output_patch0_offset + output_patch_size * num_patches;