HLSL: Declare undef variables as static.
Undef variables would somehow become cbuffer variables without any warning ...
This commit is contained in:
parent
7ac5c38838
commit
e81c1b1d98
@ -11,7 +11,7 @@ struct SPIRV_Cross_Output
|
||||
float4 FragColor : SV_Target0;
|
||||
};
|
||||
|
||||
bool _47;
|
||||
static bool _47;
|
||||
|
||||
void frag_main()
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
RWByteAddressBuffer block : register(u0);
|
||||
|
||||
float _15;
|
||||
static float _15;
|
||||
|
||||
void comp_main()
|
||||
{
|
||||
|
@ -11,7 +11,7 @@ struct SPIRV_Cross_Output
|
||||
float4 FragColor : SV_Target0;
|
||||
};
|
||||
|
||||
float4 undef;
|
||||
static float4 undef;
|
||||
|
||||
void frag_main()
|
||||
{
|
||||
|
@ -11,7 +11,7 @@ struct SPIRV_Cross_Output
|
||||
float4 FragColor : SV_Target0;
|
||||
};
|
||||
|
||||
float4 _21;
|
||||
static float4 _21;
|
||||
|
||||
void frag_main()
|
||||
{
|
||||
|
@ -1117,6 +1117,18 @@ void CompilerHLSL::replace_illegal_names()
|
||||
CompilerGLSL::replace_illegal_names();
|
||||
}
|
||||
|
||||
void CompilerHLSL::declare_undefined_values()
|
||||
{
|
||||
bool emitted = false;
|
||||
ir.for_each_typed_id<SPIRUndef>([&](uint32_t, const SPIRUndef &undef) {
|
||||
statement("static ", variable_decl(this->get<SPIRType>(undef.basetype), to_name(undef.self), undef.self), ";");
|
||||
emitted = true;
|
||||
});
|
||||
|
||||
if (emitted)
|
||||
statement("");
|
||||
}
|
||||
|
||||
void CompilerHLSL::emit_resources()
|
||||
{
|
||||
auto &execution = get_entry_point();
|
||||
|
@ -186,6 +186,7 @@ private:
|
||||
void emit_hlsl_entry_point();
|
||||
void emit_header() override;
|
||||
void emit_resources();
|
||||
void declare_undefined_values() override;
|
||||
void emit_interface_block_globally(const SPIRVariable &type);
|
||||
void emit_interface_block_in_struct(const SPIRVariable &type, std::unordered_set<uint32_t> &active_locations);
|
||||
void emit_builtin_inputs_in_struct();
|
||||
|
Loading…
Reference in New Issue
Block a user