1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-26 04:32:35 +01:00

rsx: Add stippled rendering support to interpreters

This commit is contained in:
kd-11 2020-05-30 13:48:58 +03:00 committed by kd-11
parent 1677618c75
commit 542a6aed51
4 changed files with 37 additions and 2 deletions

View File

@ -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;

View File

@ -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()

View File

@ -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";

View File

@ -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]]
{