diff --git a/rpcs3/Emu/RSX/Common/Interpreter/FragmentInterpreter.glsl b/rpcs3/Emu/RSX/Common/Interpreter/FragmentInterpreter.glsl index 9b756e01f3..1ca3ae9622 100644 --- a/rpcs3/Emu/RSX/Common/Interpreter/FragmentInterpreter.glsl +++ b/rpcs3/Emu/RSX/Common/Interpreter/FragmentInterpreter.glsl @@ -472,6 +472,21 @@ void main() inst.end = false; bool handled; +#ifdef WITH_STIPPLING + uvr0.xy = uvec2(gl_FragCoord.xy) % uvec2(32u); // x,y location + ur0 = uvr0.y * 32u + uvr0.x; // linear address + ur1 = ur0 & 31u; // address % 32 -> fetch bit offset + ur1 = (1u << ur1); // address mask + uvr0.x = (ur0 >> 7u); // address to uvec4 row (each row has 32x4 bits) + ur0 = (ur0 >> 5u) & 3u; // address to uvec4 word (address / 32) % 4 + + if ((stipple_pattern[uvr0.x][ur0] & ur1) == 0u) + { + discard; + inst.end = true; + } +#endif + while (!inst.end) { ip += inst_length; diff --git a/rpcs3/Emu/RSX/Common/ShaderInterpreter.h b/rpcs3/Emu/RSX/Common/ShaderInterpreter.h index 56b863bb65..f93a8a8f57 100644 --- a/rpcs3/Emu/RSX/Common/ShaderInterpreter.h +++ b/rpcs3/Emu/RSX/Common/ShaderInterpreter.h @@ -18,7 +18,8 @@ namespace program_common COMPILER_OPT_ENABLE_ALPHA_TEST_NE = 256, COMPILER_OPT_ENABLE_FLOW_CTRL = 512, COMPILER_OPT_ENABLE_PACKING = 1024, - COMPILER_OPT_ENABLE_KIL = 2048 + COMPILER_OPT_ENABLE_KIL = 2048, + COMPILER_OPT_ENABLE_STIPPLING = 4096 }; static std::string get_vertex_interpreter() diff --git a/rpcs3/Emu/RSX/GL/GLShaderInterpreter.cpp b/rpcs3/Emu/RSX/GL/GLShaderInterpreter.cpp index 3cc89af72c..ccf995249f 100644 --- a/rpcs3/Emu/RSX/GL/GLShaderInterpreter.cpp +++ b/rpcs3/Emu/RSX/GL/GLShaderInterpreter.cpp @@ -99,6 +99,7 @@ namespace gl if (metadata.referenced_textures_mask) opt |= program_common::interpreter::COMPILER_OPT_ENABLE_TEXTURES; if (metadata.has_branch_instructions) opt |= program_common::interpreter::COMPILER_OPT_ENABLE_FLOW_CTRL; if (metadata.has_pack_instructions) opt |= program_common::interpreter::COMPILER_OPT_ENABLE_PACKING; + if (rsx::method_registers.polygon_stipple_enabled()) opt |= program_common::interpreter::COMPILER_OPT_ENABLE_STIPPLING; if (auto it = m_program_cache.find(opt); it != m_program_cache.end()) [[likely]] { @@ -266,6 +267,11 @@ namespace gl builder << "#define WITH_KIL\n"; } + if (compiler_options & program_common::interpreter::COMPILER_OPT_ENABLE_STIPPLING) + { + builder << "#define WITH_STIPPLING\n"; + } + if (compiler_options & program_common::interpreter::COMPILER_OPT_ENABLE_TEXTURES) { builder << "#define WITH_TEXTURES\n\n"; diff --git a/rpcs3/Emu/RSX/VK/VKShaderInterpreter.cpp b/rpcs3/Emu/RSX/VK/VKShaderInterpreter.cpp index 14d1502142..d824572371 100644 --- a/rpcs3/Emu/RSX/VK/VKShaderInterpreter.cpp +++ b/rpcs3/Emu/RSX/VK/VKShaderInterpreter.cpp @@ -94,6 +94,7 @@ namespace vk VKFragmentProgram vk_prog; VKFragmentDecompilerThread comp(shader_str, arr, frag, len, vk_prog); + const auto& binding_table = vk::get_current_renderer()->get_pipeline_binding_table(); std::stringstream builder; builder << "#version 450\n" @@ -157,6 +158,11 @@ namespace vk builder << "#define WITH_KIL\n"; } + if (compiler_options & program_common::interpreter::COMPILER_OPT_ENABLE_STIPPLING) + { + builder << "#define WITH_STIPPLING\n"; + } + const char* type_names[] = { "sampler1D", "sampler2D", "sampler3D", "samplerCube" }; if (compiler_options & program_common::interpreter::COMPILER_OPT_ENABLE_TEXTURES) { @@ -193,7 +199,6 @@ namespace vk fs->compile(); // Prepare input table - const auto& binding_table = vk::get_current_renderer()->get_pipeline_binding_table(); vk::glsl::program_input in; in.location = binding_table.fragment_constant_buffers_bind_slot; in.domain = ::glsl::glsl_fragment_program; @@ -279,6 +284,13 @@ namespace vk idx++; + bindings[idx].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; + bindings[idx].descriptorCount = 1; + bindings[idx].stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT; + bindings[idx].binding = binding_table.rasterizer_env_bind_slot; + + idx++; + bindings[idx].descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; bindings[idx].descriptorCount = 16; bindings[idx].stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT; @@ -579,6 +591,7 @@ namespace vk if (metadata.referenced_textures_mask) key.compiler_opt |= program_common::interpreter::COMPILER_OPT_ENABLE_TEXTURES; if (metadata.has_branch_instructions) key.compiler_opt |= program_common::interpreter::COMPILER_OPT_ENABLE_FLOW_CTRL; if (metadata.has_pack_instructions) key.compiler_opt |= program_common::interpreter::COMPILER_OPT_ENABLE_PACKING; + if (rsx::method_registers.polygon_stipple_enabled()) key.compiler_opt |= program_common::interpreter::COMPILER_OPT_ENABLE_STIPPLING; if (m_current_key == key) [[likely]] {