mirror of
https://github.com/libretro/RetroArch
synced 2025-03-25 16:44:01 +00:00
(slang) slang_process: change the type of FragCoord only when it is a
pixel shader input.
This commit is contained in:
parent
b8e3933fe0
commit
189ea0578d
@ -357,9 +357,11 @@ bool slang_process(
|
|||||||
ps_compiler->set_decoration(ps_resources.uniform_buffers[0].id, spv::DecorationBinding, 0);
|
ps_compiler->set_decoration(ps_resources.uniform_buffers[0].id, spv::DecorationBinding, 0);
|
||||||
|
|
||||||
if (!vs_resources.push_constant_buffers.empty())
|
if (!vs_resources.push_constant_buffers.empty())
|
||||||
vs_compiler->set_decoration(vs_resources.push_constant_buffers[0].id, spv::DecorationBinding, 1);
|
vs_compiler->set_decoration(
|
||||||
|
vs_resources.push_constant_buffers[0].id, spv::DecorationBinding, 1);
|
||||||
if (!ps_resources.push_constant_buffers.empty())
|
if (!ps_resources.push_constant_buffers.empty())
|
||||||
ps_compiler->set_decoration(ps_resources.push_constant_buffers[0].id, spv::DecorationBinding, 1);
|
ps_compiler->set_decoration(
|
||||||
|
ps_resources.push_constant_buffers[0].id, spv::DecorationBinding, 1);
|
||||||
|
|
||||||
if (dst_type == RARCH_SHADER_HLSL || dst_type == RARCH_SHADER_CG)
|
if (dst_type == RARCH_SHADER_HLSL || dst_type == RARCH_SHADER_CG)
|
||||||
{
|
{
|
||||||
@ -375,14 +377,6 @@ bool slang_process(
|
|||||||
/* not exactly a vertex attribute but this remaps
|
/* not exactly a vertex attribute but this remaps
|
||||||
* float2 FragCoord :TEXCOORD# to float4 FragCoord : SV_POSITION */
|
* float2 FragCoord :TEXCOORD# to float4 FragCoord : SV_POSITION */
|
||||||
std::vector<HLSLVertexAttributeRemap> ps_attrib_remap;
|
std::vector<HLSLVertexAttributeRemap> ps_attrib_remap;
|
||||||
for (Resource& resource : ps_resources.stage_inputs)
|
|
||||||
{
|
|
||||||
if (ps->get_name(resource.id) == "FragCoord")
|
|
||||||
{
|
|
||||||
uint32_t location = ps->get_decoration(resource.id, spv::DecorationLocation);
|
|
||||||
ps_attrib_remap.push_back({ location, "SV_Position" });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* "line" is a reserved keyword in hlsl
|
/* "line" is a reserved keyword in hlsl
|
||||||
* maybe there is an easier way to rename a variable ? */
|
* maybe there is an easier way to rename a variable ? */
|
||||||
@ -394,14 +388,11 @@ bool slang_process(
|
|||||||
{
|
{
|
||||||
string name = vs->get_name(id);
|
string name = vs->get_name(id);
|
||||||
|
|
||||||
if(name == "line" ||
|
if (name == "line" || name == "point" || name == "linear")
|
||||||
name == "point" ||
|
|
||||||
name == "linear")
|
|
||||||
vs->set_name(id, string("var_") + name);
|
vs->set_name(id, string("var_") + name);
|
||||||
|
|
||||||
id++;
|
id++;
|
||||||
}
|
} catch (const std::exception& e)
|
||||||
catch (const std::exception& e)
|
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -414,23 +405,31 @@ bool slang_process(
|
|||||||
{
|
{
|
||||||
string name = ps->get_name(id);
|
string name = ps->get_name(id);
|
||||||
|
|
||||||
if(name == "line" ||
|
if (name == "line" || name == "point" || name == "linear")
|
||||||
name == "point" ||
|
|
||||||
name == "linear")
|
|
||||||
ps->set_name(id, string("var_") + name);
|
ps->set_name(id, string("var_") + name);
|
||||||
|
|
||||||
id++;
|
id++;
|
||||||
}
|
} catch (const std::exception& e)
|
||||||
catch (const std::exception& e)
|
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VariableTypeRemapCallback ps_var_remap_cb =
|
VariableTypeRemapCallback ps_var_remap_cb = [&](const SPIRType& type,
|
||||||
[](const SPIRType& type, const std::string& var_name, std::string& name_of_type) {
|
const std::string& var_name,
|
||||||
|
std::string& name_of_type) {
|
||||||
if (var_name == "FragCoord")
|
if (var_name == "FragCoord")
|
||||||
|
{
|
||||||
|
for (Resource& resource : ps_resources.stage_inputs)
|
||||||
|
{
|
||||||
|
if (ps->get_name(resource.id) == "FragCoord")
|
||||||
|
{
|
||||||
|
uint32_t location = ps->get_decoration(resource.id, spv::DecorationLocation);
|
||||||
|
ps_attrib_remap.push_back({ location, "SV_Position" });
|
||||||
name_of_type = "float4";
|
name_of_type = "float4";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
ps->set_variable_type_remap_callback(ps_var_remap_cb);
|
ps->set_variable_type_remap_callback(ps_var_remap_cb);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user