mirror of https://github.com/RPCS3/rpcs3
rsx/vk/gl: Make texture parameter reads backend-dependent
- Allows optimizations and improvements per-backend
This commit is contained in:
parent
7c4a6118f8
commit
dacc8b5c21
|
|
@ -201,7 +201,8 @@ void GLFragmentDecompilerThread::insertConstants(std::stringstream & OS)
|
|||
" uvec4 stipple_pattern[8];\n"
|
||||
"};\n\n"
|
||||
|
||||
"#define texture_base_index 0\n\n";
|
||||
"#define texture_base_index 0\n"
|
||||
"#define TEX_PARAM(index) texture_parameters[index]\n\n";
|
||||
}
|
||||
|
||||
void GLFragmentDecompilerThread::insertGlobalFunctions(std::stringstream &OS)
|
||||
|
|
|
|||
|
|
@ -300,6 +300,7 @@ namespace gl
|
|||
}
|
||||
|
||||
builder << "\n"
|
||||
"#define TEX_PARAM(index) texture_parameters[index + texture_base_index]\n"
|
||||
"#define IS_TEXTURE_RESIDENT(index) (texture_handles[index] < 0xFF)\n"
|
||||
"#define SAMPLER1D(index) sampler1D_array[texture_handles[index]]\n"
|
||||
"#define SAMPLER2D(index) sampler2D_array[texture_handles[index]]\n"
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
R"(
|
||||
#define ZS_READ(index, coord) vec2(texture(TEX_NAME(index), coord).r, float(texture(TEX_NAME_STENCIL(index), coord).x))
|
||||
#define TEX1D_Z24X8_RGBA8(index, coord1) _process_texel(convert_z24x8_to_rgba8(ZS_READ(index, COORD_SCALE1(index, coord1)), texture_parameters[index + texture_base_index].remap, TEX_FLAGS(index)), TEX_FLAGS(index))
|
||||
#define TEX2D_Z24X8_RGBA8(index, coord2) _process_texel(convert_z24x8_to_rgba8(ZS_READ(index, COORD_SCALE2(index, coord2)), texture_parameters[index + texture_base_index].remap, TEX_FLAGS(index)), TEX_FLAGS(index))
|
||||
#define TEX3D_Z24X8_RGBA8(index, coord3) _process_texel(convert_z24x8_to_rgba8(ZS_READ(index, COORD_SCALE3(index, coord3)), texture_parameters[index + texture_base_index].remap, TEX_FLAGS(index)), TEX_FLAGS(index))
|
||||
#define TEX1D_Z24X8_RGBA8(index, coord1) _process_texel(convert_z24x8_to_rgba8(ZS_READ(index, COORD_SCALE1(index, coord1)), TEX_PARAM(index).remap, TEX_FLAGS(index)), TEX_FLAGS(index))
|
||||
#define TEX2D_Z24X8_RGBA8(index, coord2) _process_texel(convert_z24x8_to_rgba8(ZS_READ(index, COORD_SCALE2(index, coord2)), TEX_PARAM(index).remap, TEX_FLAGS(index)), TEX_FLAGS(index))
|
||||
#define TEX3D_Z24X8_RGBA8(index, coord3) _process_texel(convert_z24x8_to_rgba8(ZS_READ(index, COORD_SCALE3(index, coord3)), TEX_PARAM(index).remap, TEX_FLAGS(index)), TEX_FLAGS(index))
|
||||
|
||||
// NOTE: Memory layout is fetched as byteswapped BGRA [GBAR] (GOW collection, DS2, DeS)
|
||||
// The A component (Z) is useless (should contain stencil8 or just 1)
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ R"(
|
|||
#define TEX2D_MS(index, coord2) _process_texel(sampleTexture2DMS(TEX_NAME(index), coord2, index), TEX_FLAGS(index))
|
||||
#define TEX2D_SHADOW_MS(index, coord3) vec4(comparison_passes(sampleTexture2DMS(TEX_NAME(index), coord3.xy, index).x, coord3.z, ZCOMPARE_FUNC(index)))
|
||||
#define TEX2D_SHADOWPROJ_MS(index, coord4) TEX2D_SHADOW_MS(index, (coord4.xyz / coord4.w))
|
||||
#define TEX2D_Z24X8_RGBA8_MS(index, coord2) _process_texel(convert_z24x8_to_rgba8(ZS_READ_MS(index, coord2), texture_parameters[index + texture_base_index].remap, TEX_FLAGS(index)), TEX_FLAGS(index))
|
||||
#define TEX2D_Z24X8_RGBA8_MS(index, coord2) _process_texel(convert_z24x8_to_rgba8(ZS_READ_MS(index, coord2), TEX_PARAM(index).remap, TEX_FLAGS(index)), TEX_FLAGS(index))
|
||||
|
||||
vec3 compute2x2DownsampleWeights(const in float coord, const in float uv_step, const in float actual_step)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -24,17 +24,17 @@ R"(
|
|||
uint _texture_flag_override = 0;
|
||||
#define _enable_texture_expand() _texture_flag_override = SIGN_EXPAND_MASK
|
||||
#define _disable_texture_expand() _texture_flag_override = 0
|
||||
#define TEX_FLAGS(index) (texture_parameters[index + texture_base_index].flags | _texture_flag_override)
|
||||
#define TEX_FLAGS(index) (TEX_PARAM(index).flags | _texture_flag_override)
|
||||
#else
|
||||
#define TEX_FLAGS(index) texture_parameters[index + texture_base_index].flags
|
||||
#define TEX_FLAGS(index) TEX_PARAM(index).flags
|
||||
#endif
|
||||
|
||||
#define TEX_NAME(index) tex##index
|
||||
#define TEX_NAME_STENCIL(index) tex##index##_stencil
|
||||
|
||||
#define COORD_SCALE1(index, coord1) _texcoord_xform(coord1, texture_parameters[index + texture_base_index])
|
||||
#define COORD_SCALE2(index, coord2) _texcoord_xform(coord2, texture_parameters[index + texture_base_index])
|
||||
#define COORD_SCALE3(index, coord3) _texcoord_xform(coord3, texture_parameters[index + texture_base_index])
|
||||
#define COORD_SCALE1(index, coord1) _texcoord_xform(coord1, TEX_PARAM(index))
|
||||
#define COORD_SCALE2(index, coord2) _texcoord_xform(coord2, TEX_PARAM(index))
|
||||
#define COORD_SCALE3(index, coord3) _texcoord_xform(coord3, TEX_PARAM(index))
|
||||
#define COORD_PROJ1(index, coord2) COORD_SCALE1(index, coord2.x / coord2.y)
|
||||
#define COORD_PROJ2(index, coord3) COORD_SCALE2(index, coord3.xy / coord3.z)
|
||||
#define COORD_PROJ3(index, coord4) COORD_SCALE3(index, coord4.xyz / coord4.w)
|
||||
|
|
@ -57,9 +57,9 @@ R"(
|
|||
|
||||
#ifdef _ENABLE_SHADOW
|
||||
#ifdef _EMULATED_TEXSHADOW
|
||||
#define SHADOW_COORD(index, coord3) _texcoord_xform_shadow(coord3, texture_parameters[index + texture_base_index])
|
||||
#define SHADOW_COORD4(index, coord4) _texcoord_xform_shadow(coord4, texture_parameters[index + texture_base_index])
|
||||
#define SHADOW_COORD_PROJ(index, coord4) _texcoord_xform_shadow(coord4.xyz / coord4.w, texture_parameters[index + texture_base_index])
|
||||
#define SHADOW_COORD(index, coord3) _texcoord_xform_shadow(coord3, TEX_PARAM(index))
|
||||
#define SHADOW_COORD4(index, coord4) _texcoord_xform_shadow(coord4, TEX_PARAM(index))
|
||||
#define SHADOW_COORD_PROJ(index, coord4) _texcoord_xform_shadow(coord4.xyz / coord4.w, TEX_PARAM(index))
|
||||
|
||||
#define TEX2D_SHADOW(index, coord3) texture(TEX_NAME(index), SHADOW_COORD(index, coord3))
|
||||
#define TEX3D_SHADOW(index, coord4) texture(TEX_NAME(index), SHADOW_COORD4(index, coord4))
|
||||
|
|
|
|||
|
|
@ -346,7 +346,8 @@ void VKFragmentDecompilerThread::insertGlobalFunctions(std::stringstream &OS)
|
|||
}
|
||||
|
||||
OS <<
|
||||
"#define texture_base_index _fs_texture_base_index\n\n";
|
||||
"#define texture_base_index _fs_texture_base_index\n"
|
||||
"#define TEX_PARAM(index) texture_parameters[index + texture_base_index]\n\n";
|
||||
|
||||
glsl::insert_glsl_legacy_function(OS, m_shader_props);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -264,6 +264,7 @@ namespace vk
|
|||
}
|
||||
|
||||
builder << "\n"
|
||||
"#define TEX_PARAM(index) texture_parameters[index + texture_base_index]\n"
|
||||
"#define IS_TEXTURE_RESIDENT(index) true\n"
|
||||
"#define SAMPLER1D(index) sampler1D_array[index]\n"
|
||||
"#define SAMPLER2D(index) sampler2D_array[index]\n"
|
||||
|
|
|
|||
Loading…
Reference in New Issue