forked from suyu/suyu
glsl: Remove Signed Integer variables
This commit is contained in:
parent
4759db28d0
commit
7d89a82a48
8 changed files with 13 additions and 43 deletions
|
@ -69,21 +69,11 @@ public:
|
||||||
Add<GlslVarType::U32>(format_str, inst, args...);
|
Add<GlslVarType::U32>(format_str, inst, args...);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Args>
|
|
||||||
void AddS32(const char* format_str, IR::Inst& inst, Args&&... args) {
|
|
||||||
Add<GlslVarType::S32>(format_str, inst, args...);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
void AddF32(const char* format_str, IR::Inst& inst, Args&&... args) {
|
void AddF32(const char* format_str, IR::Inst& inst, Args&&... args) {
|
||||||
Add<GlslVarType::F32>(format_str, inst, args...);
|
Add<GlslVarType::F32>(format_str, inst, args...);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Args>
|
|
||||||
void AddS64(const char* format_str, IR::Inst& inst, Args&&... args) {
|
|
||||||
Add<GlslVarType::S64>(format_str, inst, args...);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
void AddU64(const char* format_str, IR::Inst& inst, Args&&... args) {
|
void AddU64(const char* format_str, IR::Inst& inst, Args&&... args) {
|
||||||
Add<GlslVarType::U64>(format_str, inst, args...);
|
Add<GlslVarType::U64>(format_str, inst, args...);
|
||||||
|
|
|
@ -183,7 +183,7 @@ void EmitStorageAtomicIAdd64(EmitContext& ctx, IR::Inst& inst, const IR::Value&
|
||||||
void EmitStorageAtomicSMin64(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding,
|
void EmitStorageAtomicSMin64(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding,
|
||||||
const IR::Value& offset, std::string_view value) {
|
const IR::Value& offset, std::string_view value) {
|
||||||
// LOG_WARNING(..., "Op falling to non-atomic");
|
// LOG_WARNING(..., "Op falling to non-atomic");
|
||||||
ctx.AddS64("{}=packInt2x32(ivec2({}_ssbo{}[{}>>2],{}_ssbo{}[({}>>2)+1]));", inst,
|
ctx.AddU64("{}=packInt2x32(ivec2({}_ssbo{}[{}>>2],{}_ssbo{}[({}>>2)+1]));", inst,
|
||||||
ctx.stage_name, binding.U32(), ctx.var_alloc.Consume(offset), ctx.stage_name,
|
ctx.stage_name, binding.U32(), ctx.var_alloc.Consume(offset), ctx.stage_name,
|
||||||
binding.U32(), ctx.var_alloc.Consume(offset));
|
binding.U32(), ctx.var_alloc.Consume(offset));
|
||||||
ctx.Add("for(int i=0;i<2;++i){{ "
|
ctx.Add("for(int i=0;i<2;++i){{ "
|
||||||
|
@ -208,7 +208,7 @@ void EmitStorageAtomicUMin64(EmitContext& ctx, IR::Inst& inst, const IR::Value&
|
||||||
void EmitStorageAtomicSMax64(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding,
|
void EmitStorageAtomicSMax64(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding,
|
||||||
const IR::Value& offset, std::string_view value) {
|
const IR::Value& offset, std::string_view value) {
|
||||||
// LOG_WARNING(..., "Op falling to non-atomic");
|
// LOG_WARNING(..., "Op falling to non-atomic");
|
||||||
ctx.AddS64("{}=packInt2x32(ivec2({}_ssbo{}[{}>>2],{}_ssbo{}[({}>>2)+1]));", inst,
|
ctx.AddU64("{}=packInt2x32(ivec2({}_ssbo{}[{}>>2],{}_ssbo{}[({}>>2)+1]));", inst,
|
||||||
ctx.stage_name, binding.U32(), ctx.var_alloc.Consume(offset), ctx.stage_name,
|
ctx.stage_name, binding.U32(), ctx.var_alloc.Consume(offset), ctx.stage_name,
|
||||||
binding.U32(), ctx.var_alloc.Consume(offset));
|
binding.U32(), ctx.var_alloc.Consume(offset));
|
||||||
ctx.Add("for(int i=0;i<2;++i){{ "
|
ctx.Add("for(int i=0;i<2;++i){{ "
|
||||||
|
|
|
@ -15,7 +15,7 @@ void EmitConvertS16F16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::I
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmitConvertS16F32(EmitContext& ctx, IR::Inst& inst, std::string_view value) {
|
void EmitConvertS16F32(EmitContext& ctx, IR::Inst& inst, std::string_view value) {
|
||||||
ctx.AddS32("{}=(int({})&0xffff)|(bitfieldExtract(int({}),31,1)<<15);", inst, value, value);
|
ctx.AddU32("{}=(int({})&0xffff)|(bitfieldExtract(int({}),31,1)<<15);", inst, value, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmitConvertS16F64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
|
void EmitConvertS16F64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
|
||||||
|
@ -29,11 +29,11 @@ void EmitConvertS32F16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::I
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmitConvertS32F32(EmitContext& ctx, IR::Inst& inst, std::string_view value) {
|
void EmitConvertS32F32(EmitContext& ctx, IR::Inst& inst, std::string_view value) {
|
||||||
ctx.AddS32("{}=int({});", inst, value);
|
ctx.AddU32("{}=int({});", inst, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmitConvertS32F64(EmitContext& ctx, IR::Inst& inst, std::string_view value) {
|
void EmitConvertS32F64(EmitContext& ctx, IR::Inst& inst, std::string_view value) {
|
||||||
ctx.AddS32("{}=int({});", inst, value);
|
ctx.AddU32("{}=int({});", inst, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmitConvertS64F16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
|
void EmitConvertS64F16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
|
||||||
|
@ -42,11 +42,11 @@ void EmitConvertS64F16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::I
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmitConvertS64F32(EmitContext& ctx, IR::Inst& inst, std::string_view value) {
|
void EmitConvertS64F32(EmitContext& ctx, IR::Inst& inst, std::string_view value) {
|
||||||
ctx.AddS64("{}=int64_t(double({}));", inst, value);
|
ctx.AddU64("{}=int64_t(double({}));", inst, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmitConvertS64F64(EmitContext& ctx, IR::Inst& inst, std::string_view value) {
|
void EmitConvertS64F64(EmitContext& ctx, IR::Inst& inst, std::string_view value) {
|
||||||
ctx.AddS64("{}=int64_t({});", inst, value);
|
ctx.AddU64("{}=int64_t({});", inst, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmitConvertU16F16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
|
void EmitConvertU16F16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
|
||||||
|
|
|
@ -103,7 +103,7 @@ void EmitShiftRightLogical64(EmitContext& ctx, IR::Inst& inst, std::string_view
|
||||||
|
|
||||||
void EmitShiftRightArithmetic32(EmitContext& ctx, IR::Inst& inst, std::string_view base,
|
void EmitShiftRightArithmetic32(EmitContext& ctx, IR::Inst& inst, std::string_view base,
|
||||||
std::string_view shift) {
|
std::string_view shift) {
|
||||||
ctx.AddS32("{}=int({})>>{};", inst, base, shift);
|
ctx.AddU32("{}=int({})>>{};", inst, base, shift);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmitShiftRightArithmetic64(EmitContext& ctx, IR::Inst& inst, std::string_view base,
|
void EmitShiftRightArithmetic64(EmitContext& ctx, IR::Inst& inst, std::string_view base,
|
||||||
|
|
|
@ -87,7 +87,7 @@ void EmitLoadStorageU8(EmitContext& ctx, IR::Inst& inst, const IR::Value& bindin
|
||||||
void EmitLoadStorageS8(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding,
|
void EmitLoadStorageS8(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding,
|
||||||
const IR::Value& offset) {
|
const IR::Value& offset) {
|
||||||
const auto offset_var{ctx.var_alloc.Consume(offset)};
|
const auto offset_var{ctx.var_alloc.Consume(offset)};
|
||||||
ctx.AddS32("{}=bitfieldExtract(int({}_ssbo{}[{}>>2]),int({}%4)*8,8);", inst, ctx.stage_name,
|
ctx.AddU32("{}=bitfieldExtract(int({}_ssbo{}[{}>>2]),int({}%4)*8,8);", inst, ctx.stage_name,
|
||||||
binding.U32(), offset_var, offset_var);
|
binding.U32(), offset_var, offset_var);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ void EmitLoadStorageU16(EmitContext& ctx, IR::Inst& inst, const IR::Value& bindi
|
||||||
void EmitLoadStorageS16(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding,
|
void EmitLoadStorageS16(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding,
|
||||||
const IR::Value& offset) {
|
const IR::Value& offset) {
|
||||||
const auto offset_var{ctx.var_alloc.Consume(offset)};
|
const auto offset_var{ctx.var_alloc.Consume(offset)};
|
||||||
ctx.AddS32("{}=bitfieldExtract(int({}_ssbo{}[{}>>2]),int(({}>>1)%2)*16,16);", inst,
|
ctx.AddU32("{}=bitfieldExtract(int({}_ssbo{}[{}>>2]),int(({}>>1)%2)*16,16);", inst,
|
||||||
ctx.stage_name, binding.U32(), offset_var, offset_var);
|
ctx.stage_name, binding.U32(), offset_var, offset_var);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ void EmitLoadSharedU8(EmitContext& ctx, IR::Inst& inst, std::string_view offset)
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmitLoadSharedS8(EmitContext& ctx, IR::Inst& inst, std::string_view offset) {
|
void EmitLoadSharedS8(EmitContext& ctx, IR::Inst& inst, std::string_view offset) {
|
||||||
ctx.AddS32("{}=bitfieldExtract(int(smem[{}>>2]),int({}%4)*8,8);", inst, offset, offset);
|
ctx.AddU32("{}=bitfieldExtract(int(smem[{}>>2]),int({}%4)*8,8);", inst, offset, offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmitLoadSharedU16(EmitContext& ctx, IR::Inst& inst, std::string_view offset) {
|
void EmitLoadSharedU16(EmitContext& ctx, IR::Inst& inst, std::string_view offset) {
|
||||||
|
@ -22,7 +22,7 @@ void EmitLoadSharedU16(EmitContext& ctx, IR::Inst& inst, std::string_view offset
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmitLoadSharedS16(EmitContext& ctx, IR::Inst& inst, std::string_view offset) {
|
void EmitLoadSharedS16(EmitContext& ctx, IR::Inst& inst, std::string_view offset) {
|
||||||
ctx.AddS32("{}=bitfieldExtract(int(smem[{}>>2]),int(({}>>1)%2)*16,16);", inst, offset, offset);
|
ctx.AddU32("{}=bitfieldExtract(int(smem[{}>>2]),int(({}>>1)%2)*16,16);", inst, offset, offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmitLoadSharedU32(EmitContext& ctx, IR::Inst& inst, std::string_view offset) {
|
void EmitLoadSharedU32(EmitContext& ctx, IR::Inst& inst, std::string_view offset) {
|
||||||
|
|
|
@ -21,12 +21,8 @@ std::string TypePrefix(GlslVarType type) {
|
||||||
return "f16x2_";
|
return "f16x2_";
|
||||||
case GlslVarType::U32:
|
case GlslVarType::U32:
|
||||||
return "u_";
|
return "u_";
|
||||||
case GlslVarType::S32:
|
|
||||||
return "s_";
|
|
||||||
case GlslVarType::F32:
|
case GlslVarType::F32:
|
||||||
return "f_";
|
return "f_";
|
||||||
case GlslVarType::S64:
|
|
||||||
return "s64_";
|
|
||||||
case GlslVarType::U64:
|
case GlslVarType::U64:
|
||||||
return "u64_";
|
return "u64_";
|
||||||
case GlslVarType::F64:
|
case GlslVarType::F64:
|
||||||
|
@ -213,13 +209,9 @@ std::string VarAlloc::GetGlslType(GlslVarType type) const {
|
||||||
return "f16vec2";
|
return "f16vec2";
|
||||||
case GlslVarType::U32:
|
case GlslVarType::U32:
|
||||||
return "uint";
|
return "uint";
|
||||||
case GlslVarType::S32:
|
|
||||||
return "int";
|
|
||||||
case GlslVarType::F32:
|
case GlslVarType::F32:
|
||||||
case GlslVarType::PrecF32:
|
case GlslVarType::PrecF32:
|
||||||
return "float";
|
return "float";
|
||||||
case GlslVarType::S64:
|
|
||||||
return "int64_t";
|
|
||||||
case GlslVarType::U64:
|
case GlslVarType::U64:
|
||||||
return "uint64_t";
|
return "uint64_t";
|
||||||
case GlslVarType::F64:
|
case GlslVarType::F64:
|
||||||
|
@ -252,12 +244,8 @@ VarAlloc::UseTracker& VarAlloc::GetUseTracker(GlslVarType type) {
|
||||||
return var_f16x2;
|
return var_f16x2;
|
||||||
case GlslVarType::U32:
|
case GlslVarType::U32:
|
||||||
return var_u32;
|
return var_u32;
|
||||||
case GlslVarType::S32:
|
|
||||||
return var_s32;
|
|
||||||
case GlslVarType::F32:
|
case GlslVarType::F32:
|
||||||
return var_f32;
|
return var_f32;
|
||||||
case GlslVarType::S64:
|
|
||||||
return var_s64;
|
|
||||||
case GlslVarType::U64:
|
case GlslVarType::U64:
|
||||||
return var_u64;
|
return var_u64;
|
||||||
case GlslVarType::F64:
|
case GlslVarType::F64:
|
||||||
|
@ -291,12 +279,8 @@ const VarAlloc::UseTracker& VarAlloc::GetUseTracker(GlslVarType type) const {
|
||||||
return var_f16x2;
|
return var_f16x2;
|
||||||
case GlslVarType::U32:
|
case GlslVarType::U32:
|
||||||
return var_u32;
|
return var_u32;
|
||||||
case GlslVarType::S32:
|
|
||||||
return var_s32;
|
|
||||||
case GlslVarType::F32:
|
case GlslVarType::F32:
|
||||||
return var_f32;
|
return var_f32;
|
||||||
case GlslVarType::S64:
|
|
||||||
return var_s64;
|
|
||||||
case GlslVarType::U64:
|
case GlslVarType::U64:
|
||||||
return var_u64;
|
return var_u64;
|
||||||
case GlslVarType::F64:
|
case GlslVarType::F64:
|
||||||
|
|
|
@ -21,10 +21,8 @@ namespace Shader::Backend::GLSL {
|
||||||
enum class GlslVarType : u32 {
|
enum class GlslVarType : u32 {
|
||||||
U1,
|
U1,
|
||||||
F16x2,
|
F16x2,
|
||||||
S32,
|
|
||||||
U32,
|
U32,
|
||||||
F32,
|
F32,
|
||||||
S64,
|
|
||||||
U64,
|
U64,
|
||||||
F64,
|
F64,
|
||||||
U32x2,
|
U32x2,
|
||||||
|
@ -42,7 +40,7 @@ struct Id {
|
||||||
union {
|
union {
|
||||||
u32 raw;
|
u32 raw;
|
||||||
BitField<0, 1, u32> is_valid;
|
BitField<0, 1, u32> is_valid;
|
||||||
BitField<1, 5, GlslVarType> type;
|
BitField<1, 4, GlslVarType> type;
|
||||||
BitField<6, 26, u32> index;
|
BitField<6, 26, u32> index;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -90,7 +88,6 @@ private:
|
||||||
|
|
||||||
UseTracker var_bool{};
|
UseTracker var_bool{};
|
||||||
UseTracker var_f16x2{};
|
UseTracker var_f16x2{};
|
||||||
UseTracker var_s32{};
|
|
||||||
UseTracker var_u32{};
|
UseTracker var_u32{};
|
||||||
UseTracker var_u32x2{};
|
UseTracker var_u32x2{};
|
||||||
UseTracker var_u32x3{};
|
UseTracker var_u32x3{};
|
||||||
|
@ -100,7 +97,6 @@ private:
|
||||||
UseTracker var_f32x3{};
|
UseTracker var_f32x3{};
|
||||||
UseTracker var_f32x4{};
|
UseTracker var_f32x4{};
|
||||||
UseTracker var_u64{};
|
UseTracker var_u64{};
|
||||||
UseTracker var_s64{};
|
|
||||||
UseTracker var_f64{};
|
UseTracker var_f64{};
|
||||||
UseTracker var_precf32{};
|
UseTracker var_precf32{};
|
||||||
UseTracker var_precf64{};
|
UseTracker var_precf64{};
|
||||||
|
|
Loading…
Reference in a new issue