gpu: check right register for primitive restart index (#453)

@red-prig suggestion

Not sure if it is possible to have trash in the register (maybe if primitive restart is toggled off), but just to make sure.
This commit is contained in:
Vinicius Rangel 2024-08-16 13:49:15 -03:00 committed by GitHub
parent ad60ae1d40
commit 444cdfbba5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 13 additions and 8 deletions

View File

@ -933,7 +933,7 @@ struct Liverpool {
std::array<ViewportScissor, NumViewports> viewport_scissors; std::array<ViewportScissor, NumViewports> viewport_scissors;
std::array<ViewportDepth, NumViewports> viewport_depths; std::array<ViewportDepth, NumViewports> viewport_depths;
INSERT_PADDING_WORDS(0xA103 - 0xA0D4); INSERT_PADDING_WORDS(0xA103 - 0xA0D4);
u32 primitive_reset_index; u32 primitive_restart_index;
INSERT_PADDING_WORDS(1); INSERT_PADDING_WORDS(1);
BlendConstants blend_constants; BlendConstants blend_constants;
INSERT_PADDING_WORDS(0xA10B - 0xA105 - 4); INSERT_PADDING_WORDS(0xA10B - 0xA105 - 4);
@ -973,7 +973,9 @@ struct Liverpool {
IndexBufferType index_buffer_type; IndexBufferType index_buffer_type;
INSERT_PADDING_WORDS(0xA2A1 - 0xA29E - 2); INSERT_PADDING_WORDS(0xA2A1 - 0xA29E - 2);
u32 enable_primitive_id; u32 enable_primitive_id;
INSERT_PADDING_WORDS(0xA2A8 - 0xA2A1 - 1); INSERT_PADDING_WORDS(3);
u32 enable_primitive_restart;
INSERT_PADDING_WORDS(0xA2A8 - 0xA2A5 - 1);
u32 vgt_instance_step_rate_0; u32 vgt_instance_step_rate_0;
u32 vgt_instance_step_rate_1; u32 vgt_instance_step_rate_1;
INSERT_PADDING_WORDS(0xA2D5 - 0xA2A9 - 1); INSERT_PADDING_WORDS(0xA2D5 - 0xA2A9 - 1);
@ -1160,7 +1162,7 @@ static_assert(GFX6_3D_REG_INDEX(depth_buffer.depth_slice) == 0xA017);
static_assert(GFX6_3D_REG_INDEX(color_target_mask) == 0xA08E); static_assert(GFX6_3D_REG_INDEX(color_target_mask) == 0xA08E);
static_assert(GFX6_3D_REG_INDEX(color_shader_mask) == 0xA08F); static_assert(GFX6_3D_REG_INDEX(color_shader_mask) == 0xA08F);
static_assert(GFX6_3D_REG_INDEX(viewport_scissors) == 0xA094); static_assert(GFX6_3D_REG_INDEX(viewport_scissors) == 0xA094);
static_assert(GFX6_3D_REG_INDEX(primitive_reset_index) == 0xA103); static_assert(GFX6_3D_REG_INDEX(primitive_restart_index) == 0xA103);
static_assert(GFX6_3D_REG_INDEX(stencil_control) == 0xA10B); static_assert(GFX6_3D_REG_INDEX(stencil_control) == 0xA10B);
static_assert(GFX6_3D_REG_INDEX(viewports) == 0xA10F); static_assert(GFX6_3D_REG_INDEX(viewports) == 0xA10F);
static_assert(GFX6_3D_REG_INDEX(clip_user_data) == 0xA16F); static_assert(GFX6_3D_REG_INDEX(clip_user_data) == 0xA16F);
@ -1181,6 +1183,7 @@ static_assert(GFX6_3D_REG_INDEX(vs_output_control) == 0xA207);
static_assert(GFX6_3D_REG_INDEX(index_size) == 0xA29D); static_assert(GFX6_3D_REG_INDEX(index_size) == 0xA29D);
static_assert(GFX6_3D_REG_INDEX(index_buffer_type) == 0xA29F); static_assert(GFX6_3D_REG_INDEX(index_buffer_type) == 0xA29F);
static_assert(GFX6_3D_REG_INDEX(enable_primitive_id) == 0xA2A1); static_assert(GFX6_3D_REG_INDEX(enable_primitive_id) == 0xA2A1);
static_assert(GFX6_3D_REG_INDEX(enable_primitive_restart) == 0xA2A5);
static_assert(GFX6_3D_REG_INDEX(vgt_instance_step_rate_0) == 0xA2A8); static_assert(GFX6_3D_REG_INDEX(vgt_instance_step_rate_0) == 0xA2A8);
static_assert(GFX6_3D_REG_INDEX(vgt_instance_step_rate_1) == 0xA2A9); static_assert(GFX6_3D_REG_INDEX(vgt_instance_step_rate_1) == 0xA2A9);
static_assert(GFX6_3D_REG_INDEX(stage_enable) == 0xA2D5); static_assert(GFX6_3D_REG_INDEX(stage_enable) == 0xA2D5);

View File

@ -86,10 +86,10 @@ GraphicsPipeline::GraphicsPipeline(const Instance& instance_, Scheduler& schedul
const vk::PipelineInputAssemblyStateCreateInfo input_assembly = { const vk::PipelineInputAssemblyStateCreateInfo input_assembly = {
.topology = LiverpoolToVK::PrimitiveType(key.prim_type), .topology = LiverpoolToVK::PrimitiveType(key.prim_type),
.primitiveRestartEnable = key.prim_restart_index != 0, .primitiveRestartEnable = key.enable_primitive_restart != 0,
}; };
ASSERT_MSG(key.prim_restart_index == 0 || key.prim_restart_index == 0xFFFF, ASSERT_MSG(!key.enable_primitive_restart || key.primitive_restart_index == 0xFFFF,
"Primitive restart index other than 0xFFFF is not supported"); "Primitive restart index other than 0xFFFF is not supported yet");
const vk::PipelineRasterizationStateCreateInfo raster_state = { const vk::PipelineRasterizationStateCreateInfo raster_state = {
.depthClampEnable = false, .depthClampEnable = false,

View File

@ -39,7 +39,8 @@ struct GraphicsPipelineKey {
Liverpool::StencilRefMask stencil_ref_front; Liverpool::StencilRefMask stencil_ref_front;
Liverpool::StencilRefMask stencil_ref_back; Liverpool::StencilRefMask stencil_ref_back;
Liverpool::PrimitiveType prim_type; Liverpool::PrimitiveType prim_type;
u32 prim_restart_index; u32 enable_primitive_restart;
u32 primitive_restart_index;
Liverpool::PolygonMode polygon_mode; Liverpool::PolygonMode polygon_mode;
Liverpool::CullMode cull_mode; Liverpool::CullMode cull_mode;
Liverpool::FrontFace front_face; Liverpool::FrontFace front_face;

View File

@ -165,7 +165,8 @@ void PipelineCache::RefreshGraphicsKey() {
key.stencil_ref_front = regs.stencil_ref_front; key.stencil_ref_front = regs.stencil_ref_front;
key.stencil_ref_back = regs.stencil_ref_back; key.stencil_ref_back = regs.stencil_ref_back;
key.prim_type = regs.primitive_type; key.prim_type = regs.primitive_type;
key.prim_restart_index = regs.primitive_reset_index; key.enable_primitive_restart = regs.enable_primitive_restart;
key.primitive_restart_index = regs.primitive_restart_index & 1;
key.polygon_mode = regs.polygon_control.PolyMode(); key.polygon_mode = regs.polygon_control.PolyMode();
key.cull_mode = regs.polygon_control.CullingMode(); key.cull_mode = regs.polygon_control.CullingMode();
key.clip_space = regs.clipper_control.clip_space; key.clip_space = regs.clipper_control.clip_space;