mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-13 10:18:40 +12:00
vk/gl: Fix sampling of shadow2D textures
This commit is contained in:
parent
69d3d47901
commit
110974af0b
4 changed files with 37 additions and 6 deletions
|
@ -521,6 +521,7 @@ bool FragmentProgramDecompiler::handle_tex_srb(u32 opcode)
|
||||||
SetDst(getFunction(FUNCTION::FUNCTION_TEXTURE_SAMPLE2D_DEPTH_RGBA));
|
SetDst(getFunction(FUNCTION::FUNCTION_TEXTURE_SAMPLE2D_DEPTH_RGBA));
|
||||||
else
|
else
|
||||||
SetDst(getFunction(FUNCTION::FUNCTION_TEXTURE_SAMPLE2D));
|
SetDst(getFunction(FUNCTION::FUNCTION_TEXTURE_SAMPLE2D));
|
||||||
|
m_2d_sampled_textures |= (1 << dst.tex_num);
|
||||||
return true;
|
return true;
|
||||||
case rsx::texture_dimension_extended::texture_dimension_cubemap:
|
case rsx::texture_dimension_extended::texture_dimension_cubemap:
|
||||||
SetDst(getFunction(FUNCTION::FUNCTION_TEXTURE_SAMPLECUBE));
|
SetDst(getFunction(FUNCTION::FUNCTION_TEXTURE_SAMPLECUBE));
|
||||||
|
@ -541,6 +542,8 @@ bool FragmentProgramDecompiler::handle_tex_srb(u32 opcode)
|
||||||
return true;
|
return true;
|
||||||
case rsx::texture_dimension_extended::texture_dimension_2d:
|
case rsx::texture_dimension_extended::texture_dimension_2d:
|
||||||
SetDst(getFunction(FUNCTION::FUNCTION_TEXTURE_SAMPLE2D_PROJ));
|
SetDst(getFunction(FUNCTION::FUNCTION_TEXTURE_SAMPLE2D_PROJ));
|
||||||
|
if (m_prog.shadow_textures & (1 << dst.tex_num))
|
||||||
|
m_shadow_sampled_textures |= (1 << dst.tex_num);
|
||||||
return true;
|
return true;
|
||||||
case rsx::texture_dimension_extended::texture_dimension_cubemap:
|
case rsx::texture_dimension_extended::texture_dimension_cubemap:
|
||||||
SetDst(getFunction(FUNCTION::FUNCTION_TEXTURE_SAMPLECUBE_PROJ));
|
SetDst(getFunction(FUNCTION::FUNCTION_TEXTURE_SAMPLECUBE_PROJ));
|
||||||
|
@ -558,6 +561,7 @@ bool FragmentProgramDecompiler::handle_tex_srb(u32 opcode)
|
||||||
return true;
|
return true;
|
||||||
case rsx::texture_dimension_extended::texture_dimension_2d:
|
case rsx::texture_dimension_extended::texture_dimension_2d:
|
||||||
SetDst(getFunction(FUNCTION::FUNCTION_TEXTURE_SAMPLE2D_GRAD));
|
SetDst(getFunction(FUNCTION::FUNCTION_TEXTURE_SAMPLE2D_GRAD));
|
||||||
|
m_2d_sampled_textures |= (1 << dst.tex_num);
|
||||||
return true;
|
return true;
|
||||||
case rsx::texture_dimension_extended::texture_dimension_cubemap:
|
case rsx::texture_dimension_extended::texture_dimension_cubemap:
|
||||||
SetDst(getFunction(FUNCTION::FUNCTION_TEXTURE_SAMPLECUBE_GRAD));
|
SetDst(getFunction(FUNCTION::FUNCTION_TEXTURE_SAMPLECUBE_GRAD));
|
||||||
|
@ -576,6 +580,7 @@ bool FragmentProgramDecompiler::handle_tex_srb(u32 opcode)
|
||||||
return true;
|
return true;
|
||||||
case rsx::texture_dimension_extended::texture_dimension_2d:
|
case rsx::texture_dimension_extended::texture_dimension_2d:
|
||||||
SetDst(getFunction(FUNCTION::FUNCTION_TEXTURE_SAMPLE2D_LOD));
|
SetDst(getFunction(FUNCTION::FUNCTION_TEXTURE_SAMPLE2D_LOD));
|
||||||
|
m_2d_sampled_textures |= (1 << dst.tex_num);
|
||||||
return true;
|
return true;
|
||||||
case rsx::texture_dimension_extended::texture_dimension_cubemap:
|
case rsx::texture_dimension_extended::texture_dimension_cubemap:
|
||||||
SetDst(getFunction(FUNCTION::FUNCTION_TEXTURE_SAMPLECUBE_LOD));
|
SetDst(getFunction(FUNCTION::FUNCTION_TEXTURE_SAMPLECUBE_LOD));
|
||||||
|
|
|
@ -88,7 +88,11 @@ class FragmentProgramDecompiler
|
||||||
bool handle_tex_srb(u32 opcode);
|
bool handle_tex_srb(u32 opcode);
|
||||||
protected:
|
protected:
|
||||||
const RSXFragmentProgram &m_prog;
|
const RSXFragmentProgram &m_prog;
|
||||||
u32 m_ctrl;
|
u32 m_ctrl = 0;
|
||||||
|
|
||||||
|
u32 m_2d_sampled_textures = 0; //Mask of textures sampled as texture2D (conflicts with samplerShadow fetch)
|
||||||
|
u32 m_shadow_sampled_textures = 0; //Mask of textures sampled as boolean shadow comparisons
|
||||||
|
|
||||||
/** returns the type name of float vectors.
|
/** returns the type name of float vectors.
|
||||||
*/
|
*/
|
||||||
virtual std::string getFloatTypeName(size_t elementCount) = 0;
|
virtual std::string getFloatTypeName(size_t elementCount) = 0;
|
||||||
|
|
|
@ -107,8 +107,18 @@ void GLFragmentDecompilerThread::insertConstants(std::stringstream & OS)
|
||||||
std::string samplerType = PT.type;
|
std::string samplerType = PT.type;
|
||||||
int index = atoi(&PI.name.data()[3]);
|
int index = atoi(&PI.name.data()[3]);
|
||||||
|
|
||||||
if ((m_prog.shadow_textures & (1 << index)) > 0)
|
const auto mask = (1 << index);
|
||||||
|
|
||||||
|
if (m_prog.shadow_textures & mask)
|
||||||
|
{
|
||||||
|
if (m_shadow_sampled_textures & mask)
|
||||||
|
{
|
||||||
|
if (m_2d_sampled_textures & mask)
|
||||||
|
LOG_ERROR(RSX, "Texture unit %d is sampled as both a shadow texture and a depth texture", index);
|
||||||
|
else
|
||||||
samplerType = "sampler2DShadow";
|
samplerType = "sampler2DShadow";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
OS << "uniform " << samplerType << " " << PI.name << ";" << std::endl;
|
OS << "uniform " << samplerType << " " << PI.name << ";" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,10 +123,22 @@ void VKFragmentDecompilerThread::insertConstants(std::stringstream & OS)
|
||||||
std::string samplerType = PT.type;
|
std::string samplerType = PT.type;
|
||||||
int index = atoi(&PI.name.data()[3]);
|
int index = atoi(&PI.name.data()[3]);
|
||||||
|
|
||||||
if (m_prog.unnormalized_coords & (1 << index))
|
const auto mask = (1 << index);
|
||||||
|
|
||||||
|
if (m_prog.unnormalized_coords & mask)
|
||||||
|
{
|
||||||
samplerType = "sampler2DRect";
|
samplerType = "sampler2DRect";
|
||||||
else if (m_prog.shadow_textures & (1 << index))
|
}
|
||||||
|
else if (m_prog.shadow_textures & mask)
|
||||||
|
{
|
||||||
|
if (m_shadow_sampled_textures & mask)
|
||||||
|
{
|
||||||
|
if (m_2d_sampled_textures & mask)
|
||||||
|
LOG_ERROR(RSX, "Texture unit %d is sampled as both a shadow texture and a depth texture", index);
|
||||||
|
else
|
||||||
samplerType = "sampler2DShadow";
|
samplerType = "sampler2DShadow";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
vk::glsl::program_input in;
|
vk::glsl::program_input in;
|
||||||
in.location = location;
|
in.location = location;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue