glsl: More FP fixes
This commit is contained in:
parent
3064bde415
commit
ac7b0ebcb7
|
@ -48,11 +48,16 @@ void EmitContext::DefineStorageBuffers() {
|
||||||
}
|
}
|
||||||
u32 binding{};
|
u32 binding{};
|
||||||
for (const auto& desc : info.storage_buffers_descriptors) {
|
for (const auto& desc : info.storage_buffers_descriptors) {
|
||||||
Add("layout(std430,binding={}) buffer ssbo_{}_u32{{uint ssbo{}_u32[];}};", binding, binding,
|
if (True(info.used_storage_buffer_types & IR::Type::U32) ||
|
||||||
desc.cbuf_index, desc.count);
|
True(info.used_storage_buffer_types & IR::Type::F32)) {
|
||||||
// TODO: Track ssbo data type usage
|
Add("layout(std430,binding={}) buffer ssbo_{}_u32{{uint ssbo{}_u32[];}};", binding,
|
||||||
Add("layout(std430,binding={}) buffer ssbo_{}_u64{{uvec2 ssbo{}_u64[];}};", binding,
|
binding, desc.cbuf_index, desc.count);
|
||||||
binding, desc.cbuf_index, desc.count);
|
}
|
||||||
|
if (True(info.used_storage_buffer_types & IR::Type::U32x2) ||
|
||||||
|
True(info.used_storage_buffer_types & IR::Type::F32x2)) {
|
||||||
|
Add("layout(std430,binding={}) buffer ssbo_{}_u64{{uvec2 ssbo{}_u64[];}};", binding,
|
||||||
|
binding, desc.cbuf_index, desc.count);
|
||||||
|
}
|
||||||
++binding;
|
++binding;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -161,12 +161,12 @@ void EmitFPSaturate16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::In
|
||||||
|
|
||||||
void EmitFPSaturate32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
|
void EmitFPSaturate32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
|
||||||
[[maybe_unused]] std::string_view value) {
|
[[maybe_unused]] std::string_view value) {
|
||||||
ctx.AddF32("{}=clamp({},0.0,1.0);", inst, value);
|
ctx.AddF32("{}=min(max({},0.0),1.0);", inst, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmitFPSaturate64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
|
void EmitFPSaturate64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
|
||||||
[[maybe_unused]] std::string_view value) {
|
[[maybe_unused]] std::string_view value) {
|
||||||
ctx.AddF64("{}=clamp({},0.0,1.0);", inst, value);
|
ctx.AddF64("{}=min(max({},0.0),1.0);", inst, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmitFPClamp16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
|
void EmitFPClamp16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
|
||||||
|
@ -180,14 +180,16 @@ void EmitFPClamp32([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst&
|
||||||
[[maybe_unused]] std::string_view value,
|
[[maybe_unused]] std::string_view value,
|
||||||
[[maybe_unused]] std::string_view min_value,
|
[[maybe_unused]] std::string_view min_value,
|
||||||
[[maybe_unused]] std::string_view max_value) {
|
[[maybe_unused]] std::string_view max_value) {
|
||||||
ctx.AddF32("{}=clamp({},float({}),float({}));", inst, value, min_value, max_value);
|
// GLSL's clamp does not produce desirable results
|
||||||
|
ctx.AddF32("{}=min(max({},float({})),float({}));", inst, value, min_value, max_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmitFPClamp64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
|
void EmitFPClamp64([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
|
||||||
[[maybe_unused]] std::string_view value,
|
[[maybe_unused]] std::string_view value,
|
||||||
[[maybe_unused]] std::string_view min_value,
|
[[maybe_unused]] std::string_view min_value,
|
||||||
[[maybe_unused]] std::string_view max_value) {
|
[[maybe_unused]] std::string_view max_value) {
|
||||||
ctx.AddF64("{}=clamp({},double({}),double({}));", inst, value, min_value, max_value);
|
// GLSL's clamp does not produce desirable results
|
||||||
|
ctx.AddF64("{}=min(max({},double({})),double({}));", inst, value, min_value, max_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmitFPRoundEven16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
|
void EmitFPRoundEven16([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst& inst,
|
||||||
|
|
Loading…
Reference in a new issue