From f1d1670b0b1b5c08064df95dabd295f3cf5dcf7f Mon Sep 17 00:00:00 2001 From: gdkchan Date: Wed, 16 Nov 2022 14:53:04 -0300 Subject: Implement HLE macro for DrawElementsIndirect (#3748) * Implement HLE macro for DrawElementsIndirect * Shader cache version bump * Use GL_ARB_shader_draw_parameters extension on OpenGL * Fix DrawIndexedIndirectCount on Vulkan when extension is not supported * Implement DrawIndex * Alignment * Fix some validation errors * Rename BaseIds to DrawParameters * Fix incorrect index buffer and vertex buffer size in some cases * Add HLE macros for DrawArraysInstanced and DrawElementsInstanced * Perform a regular draw when indirect data is not modified * Use non-indirect draw methods if indirect buffer was not GPU modified * Only check if draw parameters match if the shader actually uses them * Expose Macro HLE setting on GUI * Reset FirstVertex and FirstInstance after draw * Update shader cache version again since some people already tested this * PR feedback Co-authored-by: riperiperi --- .../Shaders/ConvertIndexBufferShaderSource.comp | 58 ++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 Ryujinx.Graphics.Vulkan/Shaders/ConvertIndexBufferShaderSource.comp (limited to 'Ryujinx.Graphics.Vulkan/Shaders/ConvertIndexBufferShaderSource.comp') diff --git a/Ryujinx.Graphics.Vulkan/Shaders/ConvertIndexBufferShaderSource.comp b/Ryujinx.Graphics.Vulkan/Shaders/ConvertIndexBufferShaderSource.comp new file mode 100644 index 00000000..d56d6cfd --- /dev/null +++ b/Ryujinx.Graphics.Vulkan/Shaders/ConvertIndexBufferShaderSource.comp @@ -0,0 +1,58 @@ +#version 450 core + +#extension GL_EXT_scalar_block_layout : require +#extension GL_EXT_shader_8bit_storage : require + +layout (local_size_x = 16, local_size_y = 1, local_size_z = 1) in; + +layout (std430, set = 0, binding = 0) uniform index_buffer_pattern +{ + int ibp_pattern[8]; + int ibp_primitive_vertices; + int ibp_primitive_vertices_out; + int ibp_index_size; + int ibp_index_size_out; + int ibp_base_index; + int ibp_index_stride; + int src_offset; + int total_primitives; +}; + +layout (std430, set = 1, binding = 1) buffer in_s +{ + uint8_t[] in_data; +}; + +layout (std430, set = 1, binding = 2) buffer out_s +{ + uint8_t[] out_data; +}; + +void main() +{ + int primitiveIndex = int(gl_GlobalInvocationID.x); + if (primitiveIndex >= total_primitives) + { + return; + } + + int inOffset = primitiveIndex * ibp_index_stride; + int outOffset = primitiveIndex * ibp_primitive_vertices_out; + + for (int i = 0; i < ibp_primitive_vertices_out; i++) + { + int j; + int io = max(0, inOffset + ibp_base_index + ibp_pattern[i]) * ibp_index_size; + int oo = (outOffset + i) * ibp_index_size_out; + + for (j = 0; j < ibp_index_size; j++) + { + out_data[oo + j] = in_data[src_offset + io + j]; + } + + for (; j < ibp_index_size_out; j++) + { + out_data[oo + j] = uint8_t(0); + } + } +} -- cgit v1.2.3