mirror of
https://github.com/yuzu-mirror/yuzu.git
synced 2024-11-03 11:29:58 +00:00
glsl: minor cleanup
This commit is contained in:
parent
005eecffcd
commit
1542f31e79
4 changed files with 19 additions and 20 deletions
|
@ -135,6 +135,7 @@ public:
|
||||||
std::vector<u32> image_bindings;
|
std::vector<u32> image_bindings;
|
||||||
|
|
||||||
bool uses_y_direction{};
|
bool uses_y_direction{};
|
||||||
|
bool uses_cc_carry{};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void SetupExtensions(std::string& header);
|
void SetupExtensions(std::string& header);
|
||||||
|
|
|
@ -234,9 +234,6 @@ void EmitImageGather([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Ins
|
||||||
const auto texture{Texture(ctx, info, index)};
|
const auto texture{Texture(ctx, info, index)};
|
||||||
const auto texel{ctx.reg_alloc.Define(inst, Type::F32x4)};
|
const auto texel{ctx.reg_alloc.Define(inst, Type::F32x4)};
|
||||||
const auto sparse_inst{PrepareSparse(inst)};
|
const auto sparse_inst{PrepareSparse(inst)};
|
||||||
if (!offset2.IsEmpty()) {
|
|
||||||
ctx.Add("/*OFFSET 2 IS {}*/", ctx.reg_alloc.Consume(offset2));
|
|
||||||
}
|
|
||||||
if (!sparse_inst) {
|
if (!sparse_inst) {
|
||||||
if (offset.IsEmpty()) {
|
if (offset.IsEmpty()) {
|
||||||
ctx.Add("{}=textureGather({},{},int({}));", texel, texture, coords,
|
ctx.Add("{}=textureGather({},{},int({}));", texel, texture, coords,
|
||||||
|
|
|
@ -31,6 +31,7 @@ void SetSignFlag(EmitContext& ctx, IR::Inst& inst, std::string_view result) {
|
||||||
void EmitIAdd32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b) {
|
void EmitIAdd32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b) {
|
||||||
const auto result{ctx.reg_alloc.Define(inst, Type::U32)};
|
const auto result{ctx.reg_alloc.Define(inst, Type::U32)};
|
||||||
if (IR::Inst* const carry{inst.GetAssociatedPseudoOperation(IR::Opcode::GetCarryFromOp)}) {
|
if (IR::Inst* const carry{inst.GetAssociatedPseudoOperation(IR::Opcode::GetCarryFromOp)}) {
|
||||||
|
ctx.uses_cc_carry = true;
|
||||||
ctx.Add("{}=uaddCarry({},{},carry);", result, a, b);
|
ctx.Add("{}=uaddCarry({},{},carry);", result, a, b);
|
||||||
ctx.AddU1("{}=carry!=0;", *carry, result);
|
ctx.AddU1("{}=carry!=0;", *carry, result);
|
||||||
carry->Invalidate();
|
carry->Invalidate();
|
||||||
|
@ -61,11 +62,11 @@ void EmitISub64(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::strin
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmitIMul32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b) {
|
void EmitIMul32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b) {
|
||||||
ctx.AddU32("{}={}*{};", inst, a, b);
|
ctx.AddU32("{}=uint({}*{});", inst, a, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmitINeg32(EmitContext& ctx, IR::Inst& inst, std::string_view value) {
|
void EmitINeg32(EmitContext& ctx, IR::Inst& inst, std::string_view value) {
|
||||||
ctx.AddU32("{}=-({});", inst, value);
|
ctx.AddU32("{}=uint(-({}));", inst, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmitINeg64(EmitContext& ctx, IR::Inst& inst, std::string_view value) {
|
void EmitINeg64(EmitContext& ctx, IR::Inst& inst, std::string_view value) {
|
||||||
|
@ -124,7 +125,7 @@ void EmitBitwiseXor32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std:
|
||||||
|
|
||||||
void EmitBitFieldInsert(EmitContext& ctx, IR::Inst& inst, std::string_view base,
|
void EmitBitFieldInsert(EmitContext& ctx, IR::Inst& inst, std::string_view base,
|
||||||
std::string_view insert, std::string_view offset, std::string_view count) {
|
std::string_view insert, std::string_view offset, std::string_view count) {
|
||||||
ctx.AddU32("{}=bitfieldInsert({}, {}, int({}), int({}));", inst, base, insert, offset, count);
|
ctx.AddU32("{}=bitfieldInsert({},{},int({}),int({}));", inst, base, insert, offset, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmitBitFieldSExtract(EmitContext& ctx, IR::Inst& inst, std::string_view base,
|
void EmitBitFieldSExtract(EmitContext& ctx, IR::Inst& inst, std::string_view base,
|
||||||
|
@ -166,25 +167,25 @@ void EmitFindUMsb32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmitSMin32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b) {
|
void EmitSMin32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b) {
|
||||||
ctx.AddU32("{}=min(int({}), int({}));", inst, a, b);
|
ctx.AddU32("{}=min(int({}),int({}));", inst, a, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmitUMin32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b) {
|
void EmitUMin32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b) {
|
||||||
ctx.AddU32("{}=min(uint({}), uint({}));", inst, a, b);
|
ctx.AddU32("{}=min(uint({}),uint({}));", inst, a, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmitSMax32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b) {
|
void EmitSMax32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b) {
|
||||||
ctx.AddU32("{}=max(int({}), int({}));", inst, a, b);
|
ctx.AddU32("{}=max(int({}),int({}));", inst, a, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmitUMax32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b) {
|
void EmitUMax32(EmitContext& ctx, IR::Inst& inst, std::string_view a, std::string_view b) {
|
||||||
ctx.AddU32("{}=max(uint({}), uint({}));", inst, a, b);
|
ctx.AddU32("{}=max(uint({}),uint({}));", inst, a, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmitSClamp32(EmitContext& ctx, IR::Inst& inst, std::string_view value, std::string_view min,
|
void EmitSClamp32(EmitContext& ctx, IR::Inst& inst, std::string_view value, std::string_view min,
|
||||||
std::string_view max) {
|
std::string_view max) {
|
||||||
const auto result{ctx.reg_alloc.Define(inst, Type::U32)};
|
const auto result{ctx.reg_alloc.Define(inst, Type::U32)};
|
||||||
ctx.Add("{}=clamp(int({}), int({}), int({}));", result, value, min, max);
|
ctx.Add("{}=clamp(int({}),int({}),int({}));", result, value, min, max);
|
||||||
SetZeroFlag(ctx, inst, result);
|
SetZeroFlag(ctx, inst, result);
|
||||||
SetSignFlag(ctx, inst, result);
|
SetSignFlag(ctx, inst, result);
|
||||||
}
|
}
|
||||||
|
@ -192,7 +193,7 @@ void EmitSClamp32(EmitContext& ctx, IR::Inst& inst, std::string_view value, std:
|
||||||
void EmitUClamp32(EmitContext& ctx, IR::Inst& inst, std::string_view value, std::string_view min,
|
void EmitUClamp32(EmitContext& ctx, IR::Inst& inst, std::string_view value, std::string_view min,
|
||||||
std::string_view max) {
|
std::string_view max) {
|
||||||
const auto result{ctx.reg_alloc.Define(inst, Type::U32)};
|
const auto result{ctx.reg_alloc.Define(inst, Type::U32)};
|
||||||
ctx.Add("{}=clamp(uint({}), uint({}), uint({}));", result, value, min, max);
|
ctx.Add("{}=clamp(uint({}),uint({}),uint({}));", result, value, min, max);
|
||||||
SetZeroFlag(ctx, inst, result);
|
SetZeroFlag(ctx, inst, result);
|
||||||
SetSignFlag(ctx, inst, result);
|
SetSignFlag(ctx, inst, result);
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,16 +50,16 @@ void EmitLoadStorage32(EmitContext& ctx, IR::Inst& inst, const IR::Value& bindin
|
||||||
void EmitLoadStorage64(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding,
|
void EmitLoadStorage64(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding,
|
||||||
const IR::Value& offset) {
|
const IR::Value& offset) {
|
||||||
const auto offset_var{ctx.reg_alloc.Consume(offset)};
|
const auto offset_var{ctx.reg_alloc.Consume(offset)};
|
||||||
ctx.AddU32x2("{}=uvec2(ssbo{}[{}/4],ssbo{}[{}/4+1]);", inst, binding.U32(), offset_var,
|
ctx.AddU32x2("{}=uvec2(ssbo{}[{}/4],ssbo{}[({}+4)/4]);", inst, binding.U32(), offset_var,
|
||||||
binding.U32(), offset_var);
|
binding.U32(), offset_var);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmitLoadStorage128(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding,
|
void EmitLoadStorage128(EmitContext& ctx, IR::Inst& inst, const IR::Value& binding,
|
||||||
const IR::Value& offset) {
|
const IR::Value& offset) {
|
||||||
const auto offset_var{ctx.reg_alloc.Consume(offset)};
|
const auto offset_var{ctx.reg_alloc.Consume(offset)};
|
||||||
ctx.AddU32x4("{}=uvec4(ssbo{}[{}/4],ssbo{}[{}/4+1],ssbo{}[{}/4+2],ssbo{}[{}/4+3]);", inst,
|
ctx.AddU32x4("{}=uvec4(ssbo{}[{}/4],ssbo{}[({}+4)/4],ssbo{}[({}+8)/4],ssbo{}[({}+12)/4]);",
|
||||||
binding.U32(), offset_var, binding.U32(), offset_var, binding.U32(), offset_var,
|
inst, binding.U32(), offset_var, binding.U32(), offset_var, binding.U32(),
|
||||||
binding.U32(), offset_var);
|
offset_var, binding.U32(), offset_var);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmitWriteStorageU8([[maybe_unused]] EmitContext& ctx,
|
void EmitWriteStorageU8([[maybe_unused]] EmitContext& ctx,
|
||||||
|
@ -108,7 +108,7 @@ void EmitWriteStorage64(EmitContext& ctx, const IR::Value& binding, const IR::Va
|
||||||
std::string_view value) {
|
std::string_view value) {
|
||||||
const auto offset_var{ctx.reg_alloc.Consume(offset)};
|
const auto offset_var{ctx.reg_alloc.Consume(offset)};
|
||||||
ctx.Add("ssbo{}[{}/4]={}.x;", binding.U32(), offset_var, value);
|
ctx.Add("ssbo{}[{}/4]={}.x;", binding.U32(), offset_var, value);
|
||||||
ctx.Add("ssbo{}[({}/4)+1]={}.y;", binding.U32(), offset_var, value);
|
ctx.Add("ssbo{}[({}+4)/4]={}.y;", binding.U32(), offset_var, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmitWriteStorage128([[maybe_unused]] EmitContext& ctx,
|
void EmitWriteStorage128([[maybe_unused]] EmitContext& ctx,
|
||||||
|
@ -117,8 +117,8 @@ void EmitWriteStorage128([[maybe_unused]] EmitContext& ctx,
|
||||||
[[maybe_unused]] std::string_view value) {
|
[[maybe_unused]] std::string_view value) {
|
||||||
const auto offset_var{ctx.reg_alloc.Consume(offset)};
|
const auto offset_var{ctx.reg_alloc.Consume(offset)};
|
||||||
ctx.Add("ssbo{}[{}/4]={}.x;", binding.U32(), offset_var, value);
|
ctx.Add("ssbo{}[{}/4]={}.x;", binding.U32(), offset_var, value);
|
||||||
ctx.Add("ssbo{}[({}/4)+1]={}.y;", binding.U32(), offset_var, value);
|
ctx.Add("ssbo{}[({}+4)/4]={}.y;", binding.U32(), offset_var, value);
|
||||||
ctx.Add("ssbo{}[({}/4)+2]={}.z;", binding.U32(), offset_var, value);
|
ctx.Add("ssbo{}[({}+8)/4]={}.z;", binding.U32(), offset_var, value);
|
||||||
ctx.Add("ssbo{}[({}/4)+3]={}.w;", binding.U32(), offset_var, value);
|
ctx.Add("ssbo{}[({}+12)/4]={}.w;", binding.U32(), offset_var, value);
|
||||||
}
|
}
|
||||||
} // namespace Shader::Backend::GLSL
|
} // namespace Shader::Backend::GLSL
|
||||||
|
|
Loading…
Reference in a new issue