glsl: Minor cleanup
This commit is contained in:
parent
427a2596a1
commit
39c29664f9
@ -42,7 +42,7 @@ 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.AddU64("{}=int64_t(double({}));", inst, value);
|
ctx.AddU64("{}=int64_t({});", inst, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmitConvertS64F64(EmitContext& ctx, IR::Inst& inst, std::string_view value) {
|
void EmitConvertS64F64(EmitContext& ctx, IR::Inst& inst, std::string_view value) {
|
||||||
|
@ -45,7 +45,7 @@ std::string CastToIntVec(std::string_view value, const IR::TextureInstInfo& info
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string TexelFetchCastToInt(std::string_view value, const IR::TextureInstInfo& info) {
|
std::string CoordsCastToInt(std::string_view value, const IR::TextureInstInfo& info) {
|
||||||
switch (info.type) {
|
switch (info.type) {
|
||||||
case TextureType::Color1D:
|
case TextureType::Color1D:
|
||||||
case TextureType::Buffer:
|
case TextureType::Buffer:
|
||||||
@ -407,13 +407,13 @@ void EmitImageFetch(EmitContext& ctx, IR::Inst& inst, const IR::Value& index,
|
|||||||
if (!sparse_inst) {
|
if (!sparse_inst) {
|
||||||
if (!offset.empty()) {
|
if (!offset.empty()) {
|
||||||
ctx.Add("{}=texelFetchOffset({},{},int({}),{});", texel, texture,
|
ctx.Add("{}=texelFetchOffset({},{},int({}),{});", texel, texture,
|
||||||
TexelFetchCastToInt(coords, info), lod, TexelFetchCastToInt(offset, info));
|
CoordsCastToInt(coords, info), lod, CoordsCastToInt(offset, info));
|
||||||
} else {
|
} else {
|
||||||
if (info.type == TextureType::Buffer) {
|
if (info.type == TextureType::Buffer) {
|
||||||
ctx.Add("{}=texelFetch({},int({}));", texel, texture, coords);
|
ctx.Add("{}=texelFetch({},int({}));", texel, texture, coords);
|
||||||
} else {
|
} else {
|
||||||
ctx.Add("{}=texelFetch({},{},int({}));", texel, texture,
|
ctx.Add("{}=texelFetch({},{},int({}));", texel, texture,
|
||||||
TexelFetchCastToInt(coords, info), lod);
|
CoordsCastToInt(coords, info), lod);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -498,29 +498,28 @@ void EmitImageRead(EmitContext& ctx, IR::Inst& inst, const IR::Value& index,
|
|||||||
throw NotImplementedException("EmitImageRead Sparse");
|
throw NotImplementedException("EmitImageRead Sparse");
|
||||||
}
|
}
|
||||||
const auto image{Image(ctx, info, index)};
|
const auto image{Image(ctx, info, index)};
|
||||||
ctx.AddU32x4("{}=uvec4(imageLoad({},{}));", inst, image, TexelFetchCastToInt(coords, info));
|
ctx.AddU32x4("{}=uvec4(imageLoad({},{}));", inst, image, CoordsCastToInt(coords, info));
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmitImageWrite(EmitContext& ctx, IR::Inst& inst, const IR::Value& index,
|
void EmitImageWrite(EmitContext& ctx, IR::Inst& inst, const IR::Value& index,
|
||||||
std::string_view coords, std::string_view color) {
|
std::string_view coords, std::string_view color) {
|
||||||
const auto info{inst.Flags<IR::TextureInstInfo>()};
|
const auto info{inst.Flags<IR::TextureInstInfo>()};
|
||||||
const auto image{Image(ctx, info, index)};
|
const auto image{Image(ctx, info, index)};
|
||||||
ctx.Add("imageStore({},{},{});", image, TexelFetchCastToInt(coords, info), color);
|
ctx.Add("imageStore({},{},{});", image, CoordsCastToInt(coords, info), color);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmitImageAtomicIAdd32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index,
|
void EmitImageAtomicIAdd32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index,
|
||||||
std::string_view coords, std::string_view value) {
|
std::string_view coords, std::string_view value) {
|
||||||
const auto info{inst.Flags<IR::TextureInstInfo>()};
|
const auto info{inst.Flags<IR::TextureInstInfo>()};
|
||||||
const auto image{Image(ctx, info, index)};
|
const auto image{Image(ctx, info, index)};
|
||||||
ctx.AddU32("{}=imageAtomicAdd({},{},{});", inst, image, TexelFetchCastToInt(coords, info),
|
ctx.AddU32("{}=imageAtomicAdd({},{},{});", inst, image, CoordsCastToInt(coords, info), value);
|
||||||
value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmitImageAtomicSMin32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index,
|
void EmitImageAtomicSMin32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index,
|
||||||
std::string_view coords, std::string_view value) {
|
std::string_view coords, std::string_view value) {
|
||||||
const auto info{inst.Flags<IR::TextureInstInfo>()};
|
const auto info{inst.Flags<IR::TextureInstInfo>()};
|
||||||
const auto image{Image(ctx, info, index)};
|
const auto image{Image(ctx, info, index)};
|
||||||
ctx.AddU32("{}=imageAtomicMin({},{},int({}));", inst, image, TexelFetchCastToInt(coords, info),
|
ctx.AddU32("{}=imageAtomicMin({},{},int({}));", inst, image, CoordsCastToInt(coords, info),
|
||||||
value);
|
value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -528,7 +527,7 @@ void EmitImageAtomicUMin32(EmitContext& ctx, IR::Inst& inst, const IR::Value& in
|
|||||||
std::string_view coords, std::string_view value) {
|
std::string_view coords, std::string_view value) {
|
||||||
const auto info{inst.Flags<IR::TextureInstInfo>()};
|
const auto info{inst.Flags<IR::TextureInstInfo>()};
|
||||||
const auto image{Image(ctx, info, index)};
|
const auto image{Image(ctx, info, index)};
|
||||||
ctx.AddU32("{}=imageAtomicMin({},{},uint({}));", inst, image, TexelFetchCastToInt(coords, info),
|
ctx.AddU32("{}=imageAtomicMin({},{},uint({}));", inst, image, CoordsCastToInt(coords, info),
|
||||||
value);
|
value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -536,7 +535,7 @@ void EmitImageAtomicSMax32(EmitContext& ctx, IR::Inst& inst, const IR::Value& in
|
|||||||
std::string_view coords, std::string_view value) {
|
std::string_view coords, std::string_view value) {
|
||||||
const auto info{inst.Flags<IR::TextureInstInfo>()};
|
const auto info{inst.Flags<IR::TextureInstInfo>()};
|
||||||
const auto image{Image(ctx, info, index)};
|
const auto image{Image(ctx, info, index)};
|
||||||
ctx.AddU32("{}=imageAtomicMax({},{},int({}));", inst, image, TexelFetchCastToInt(coords, info),
|
ctx.AddU32("{}=imageAtomicMax({},{},int({}));", inst, image, CoordsCastToInt(coords, info),
|
||||||
value);
|
value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -544,7 +543,7 @@ void EmitImageAtomicUMax32(EmitContext& ctx, IR::Inst& inst, const IR::Value& in
|
|||||||
std::string_view coords, std::string_view value) {
|
std::string_view coords, std::string_view value) {
|
||||||
const auto info{inst.Flags<IR::TextureInstInfo>()};
|
const auto info{inst.Flags<IR::TextureInstInfo>()};
|
||||||
const auto image{Image(ctx, info, index)};
|
const auto image{Image(ctx, info, index)};
|
||||||
ctx.AddU32("{}=imageAtomicMax({},{},uint({}));", inst, image, TexelFetchCastToInt(coords, info),
|
ctx.AddU32("{}=imageAtomicMax({},{},uint({}));", inst, image, CoordsCastToInt(coords, info),
|
||||||
value);
|
value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -562,31 +561,28 @@ void EmitImageAtomicAnd32(EmitContext& ctx, IR::Inst& inst, const IR::Value& ind
|
|||||||
std::string_view coords, std::string_view value) {
|
std::string_view coords, std::string_view value) {
|
||||||
const auto info{inst.Flags<IR::TextureInstInfo>()};
|
const auto info{inst.Flags<IR::TextureInstInfo>()};
|
||||||
const auto image{Image(ctx, info, index)};
|
const auto image{Image(ctx, info, index)};
|
||||||
ctx.AddU32("{}=imageAtomicAnd({},{},{});", inst, image, TexelFetchCastToInt(coords, info),
|
ctx.AddU32("{}=imageAtomicAnd({},{},{});", inst, image, CoordsCastToInt(coords, info), value);
|
||||||
value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmitImageAtomicOr32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index,
|
void EmitImageAtomicOr32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index,
|
||||||
std::string_view coords, std::string_view value) {
|
std::string_view coords, std::string_view value) {
|
||||||
const auto info{inst.Flags<IR::TextureInstInfo>()};
|
const auto info{inst.Flags<IR::TextureInstInfo>()};
|
||||||
const auto image{Image(ctx, info, index)};
|
const auto image{Image(ctx, info, index)};
|
||||||
ctx.AddU32("{}=imageAtomicOr({},{},{});", inst, image, TexelFetchCastToInt(coords, info),
|
ctx.AddU32("{}=imageAtomicOr({},{},{});", inst, image, CoordsCastToInt(coords, info), value);
|
||||||
value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmitImageAtomicXor32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index,
|
void EmitImageAtomicXor32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index,
|
||||||
std::string_view coords, std::string_view value) {
|
std::string_view coords, std::string_view value) {
|
||||||
const auto info{inst.Flags<IR::TextureInstInfo>()};
|
const auto info{inst.Flags<IR::TextureInstInfo>()};
|
||||||
const auto image{Image(ctx, info, index)};
|
const auto image{Image(ctx, info, index)};
|
||||||
ctx.AddU32("{}=imageAtomicXor({},{},{});", inst, image, TexelFetchCastToInt(coords, info),
|
ctx.AddU32("{}=imageAtomicXor({},{},{});", inst, image, CoordsCastToInt(coords, info), value);
|
||||||
value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmitImageAtomicExchange32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index,
|
void EmitImageAtomicExchange32(EmitContext& ctx, IR::Inst& inst, const IR::Value& index,
|
||||||
std::string_view coords, std::string_view value) {
|
std::string_view coords, std::string_view value) {
|
||||||
const auto info{inst.Flags<IR::TextureInstInfo>()};
|
const auto info{inst.Flags<IR::TextureInstInfo>()};
|
||||||
const auto image{Image(ctx, info, index)};
|
const auto image{Image(ctx, info, index)};
|
||||||
ctx.AddU32("{}=imageAtomicExchange({},{},{});", inst, image, TexelFetchCastToInt(coords, info),
|
ctx.AddU32("{}=imageAtomicExchange({},{},{});", inst, image, CoordsCastToInt(coords, info),
|
||||||
value);
|
value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user