mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-02-05 15:40:10 +00:00
rsx: Add GLSL support for instanced rendering
This commit is contained in:
parent
e696d9b324
commit
9e9ae54455
@ -269,6 +269,7 @@ public:
|
||||
|
||||
struct
|
||||
{
|
||||
// Configuration properties (in)
|
||||
u16 in_register_mask = 0;
|
||||
|
||||
u16 common_access_sampler_mask = 0;
|
||||
@ -276,6 +277,7 @@ public:
|
||||
u16 redirected_sampler_mask = 0;
|
||||
u16 multisampled_sampler_mask = 0;
|
||||
|
||||
// Decoded properties (out)
|
||||
bool has_lit_op = false;
|
||||
bool has_gather_op = false;
|
||||
bool has_no_output = false;
|
||||
|
@ -262,6 +262,11 @@ namespace glsl
|
||||
}
|
||||
}
|
||||
|
||||
if (props.require_instanced_render)
|
||||
{
|
||||
enabled_options.push_back("_ENABLE_INSTANCED_CONSTANTS");
|
||||
}
|
||||
|
||||
// Import vertex header
|
||||
program_common::define_glsl_switches(OS, enabled_options);
|
||||
|
||||
|
@ -55,4 +55,16 @@ vec4 apply_zclip_xform(
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(_ENABLE_INSTANCED_CONSTANTS)
|
||||
vec4 _fetch_constant(const in int base_offset)
|
||||
{
|
||||
// Get virtual draw/instance id. Normally will be 1:1 based on instance index
|
||||
const int indirection_offset = (gl_InstanceID * CONSTANTS_ARRAY_LENGTH) + base_offset;
|
||||
const int corrected_offset = constants_addressing_lookup[indirection_offset];
|
||||
return instanced_constants_array[corrected_offset];
|
||||
}
|
||||
#else
|
||||
#define _fetch_constant(x) vc[x]
|
||||
#endif
|
||||
|
||||
)"
|
||||
|
@ -22,6 +22,7 @@ namespace glsl
|
||||
// Applicable in vertex stage
|
||||
bool require_lit_emulation : 1;
|
||||
bool require_explicit_invariance : 1;
|
||||
bool require_instanced_render : 1;
|
||||
bool emulate_zclip_transform : 1;
|
||||
bool emulate_depth_clip_only : 1;
|
||||
|
||||
|
@ -341,6 +341,7 @@ vertex_program_utils::vertex_program_metadata vertex_program_utils::analyse_vert
|
||||
usz vertex_program_storage_hash::operator()(const RSXVertexProgram &program) const
|
||||
{
|
||||
usz hash = vertex_program_utils::get_vertex_program_ucode_hash(program);
|
||||
hash ^= program.ctrl;
|
||||
hash ^= program.output_mask;
|
||||
hash ^= program.texture_state.texture_dimensions;
|
||||
hash ^= program.texture_state.multisampled_textures;
|
||||
@ -351,6 +352,8 @@ bool vertex_program_compare::operator()(const RSXVertexProgram &binary1, const R
|
||||
{
|
||||
if (binary1.output_mask != binary2.output_mask)
|
||||
return false;
|
||||
if (binary1.ctrl != binary2.ctrl)
|
||||
return false;
|
||||
if (binary1.texture_state != binary2.texture_state)
|
||||
return false;
|
||||
if (binary1.data.size() != binary2.data.size())
|
||||
|
@ -131,7 +131,7 @@ std::string VertexProgramDecompiler::GetSRC(const u32 n)
|
||||
m_parr.AddParam(PF_PARAM_UNIFORM, float4, std::string("vc[468]"));
|
||||
properties.has_indexed_constants |= !!d3.index_const;
|
||||
m_constant_ids.insert(static_cast<u16>(d1.const_src));
|
||||
ret += std::string("vc[") + std::to_string(d1.const_src) + (d3.index_const ? " + " + AddAddrReg() : "") + "]";
|
||||
fmt::append(ret, "_fetch_constant(%u%s)", d1.const_src, (d3.index_const ? " + " + AddAddrReg() : ""));
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -132,6 +132,10 @@ protected:
|
||||
public:
|
||||
struct
|
||||
{
|
||||
// Configuration properties (in)
|
||||
// None
|
||||
|
||||
// Decoded properties (out)
|
||||
bool has_lit_op = false;
|
||||
bool has_indexed_constants = false;
|
||||
}
|
||||
|
@ -2202,6 +2202,13 @@ namespace rsx
|
||||
|
||||
void thread::prefetch_vertex_program()
|
||||
{
|
||||
// Test if instanced command is coming up
|
||||
current_vertex_program.ctrl = 0;
|
||||
if (rsx::method_registers.current_draw_clause.is_trivial_instanced_draw)
|
||||
{
|
||||
current_vertex_program.ctrl |= RSX_SHADER_CONTROL_INSTANCED_CONSTANTS;
|
||||
}
|
||||
|
||||
if (!m_graphics_state.test(rsx::pipeline_state::vertex_program_ucode_dirty))
|
||||
{
|
||||
return;
|
||||
@ -2256,7 +2263,6 @@ namespace rsx
|
||||
|
||||
ensure(!m_graphics_state.test(rsx::pipeline_state::vertex_program_ucode_dirty));
|
||||
current_vertex_program.output_mask = rsx::method_registers.vertex_attrib_output_mask();
|
||||
current_vertex_program.ctrl = 0; // Reserved
|
||||
|
||||
for (u32 textures_ref = current_vp_metadata.referenced_textures_mask, i = 0; textures_ref; textures_ref >>= 1, ++i)
|
||||
{
|
||||
|
@ -455,7 +455,8 @@ namespace gcm
|
||||
RSX_SHADER_CONTROL_UNKNOWN1 = 0x8000, // seemingly set when srgb packer is used??
|
||||
|
||||
// Custom
|
||||
RSX_SHADER_CONTROL_ATTRIBUTE_INTERPOLATION = 0x10000 // Rasterizing triangles and not lines or points
|
||||
RSX_SHADER_CONTROL_ATTRIBUTE_INTERPOLATION = 0x10000, // Rasterizing triangles and not lines or points
|
||||
RSX_SHADER_CONTROL_INSTANCED_CONSTANTS = 0x20000, // Support instance ID offsets when loading constants
|
||||
};
|
||||
|
||||
// GCM Reports
|
||||
|
Loading…
x
Reference in New Issue
Block a user