Skip to content

Commit cf931c6

Browse files
TheMostDiligenttheHamsta
authored andcommitted
Add source language to parsed IR source data
1 parent 87aea0a commit cf931c6

4 files changed

Lines changed: 8 additions & 9 deletions

File tree

spirv_cross_parsed_ir.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ class ParsedIR
111111

112112
struct Source
113113
{
114+
spv::SourceLanguage lang = spv::SourceLanguageUnknown;
114115
uint32_t version = 0;
115116
bool es = false;
116117
bool known = false;

spirv_glsl.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16087,7 +16087,7 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction)
1608716087
join("createTensorLayoutNV(", to_expression(type.ext.tensorLayoutNv.dim_id), ", ",
1608816088
to_pretty_expression_if_int_constant(type.ext.tensorLayoutNv.clamp_mode_id,
1608916089
std::begin(CooperativeMatrixClampModeNames),
16090-
std::end(CooperativeMatrixClampModeNames), true, ""),
16090+
std::end(CooperativeMatrixClampModeNames), true),
1609116091
")"),
1609216092
true);
1609316093
break;
@@ -17123,7 +17123,7 @@ string CompilerGLSL::type_to_glsl(const SPIRType &type, uint32_t id)
1712317123
uint32_t dim = dim_constant.scalar();
1712417124
auto clamp_expr = to_pretty_expression_if_int_constant(type.ext.tensorLayoutNv.clamp_mode_id,
1712517125
std::begin(CooperativeMatrixClampModeNames),
17126-
std::end(CooperativeMatrixClampModeNames), true, "");
17126+
std::end(CooperativeMatrixClampModeNames), true);
1712717127
return join("tensorLayoutNV<", dim, ", ", clamp_expr, ">");
1712817128
}
1712917129

@@ -20409,8 +20409,7 @@ std::string CompilerGLSL::format_double(double value) const
2040920409
std::string CompilerGLSL::to_pretty_expression_if_int_constant(uint32_t id,
2041020410
const GlslConstantNameMapping *mapping_start,
2041120411
const GlslConstantNameMapping *mapping_end,
20412-
bool register_expression_read,
20413-
const char* target_type)
20412+
bool register_expression_read)
2041420413
{
2041520414
auto *c = maybe_get<SPIRConstant>(id);
2041620415
if (c && !c->specialization)
@@ -20421,5 +20420,5 @@ std::string CompilerGLSL::to_pretty_expression_if_int_constant(uint32_t id,
2042120420
if (pretty_name != mapping_end)
2042220421
return pretty_name->alias;
2042320422
}
20424-
return join(target_type, "(", to_expression(id, register_expression_read), ")");
20423+
return join("int(", to_expression(id, register_expression_read), ")");
2042520424
}

spirv_glsl.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -812,8 +812,7 @@ class CompilerGLSL : public Compiler
812812
std::string to_pretty_expression_if_int_constant(
813813
uint32_t id,
814814
const GlslConstantNameMapping *mapping_start, const GlslConstantNameMapping *mapping_end,
815-
bool register_expression_read = true,
816-
const char* target_type = "int");
815+
bool register_expression_read = true);
817816
std::string to_expression(uint32_t id, bool register_expression_read = true);
818817
std::string to_composite_constructor_expression(const SPIRType &parent_type, uint32_t id, bool block_like_type);
819818
std::string to_rerolled_array_expression(const SPIRType &parent_type, const std::string &expr, const SPIRType &type);

spirv_parser.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,8 @@ void Parser::parse(const Instruction &instruction)
213213

214214
case OpSource:
215215
{
216-
auto lang = static_cast<SourceLanguage>(ops[0]);
217-
switch (lang)
216+
ir.source.lang = static_cast<SourceLanguage>(ops[0]);
217+
switch (ir.source.lang)
218218
{
219219
case SourceLanguageESSL:
220220
ir.source.es = true;

0 commit comments

Comments
 (0)