glsl: Implement gl_ViewportIndex
SSBU now working
This commit is contained in:
parent
b7561226ed
commit
3a024b3026
3 changed files with 14 additions and 5 deletions
|
@ -126,6 +126,8 @@ EmitContext::EmitContext(IR::Program& program, Bindings& bindings, const Profile
|
||||||
void EmitContext::SetupExtensions(std::string&) {
|
void EmitContext::SetupExtensions(std::string&) {
|
||||||
// TODO: track this usage
|
// TODO: track this usage
|
||||||
header += "#extension GL_ARB_sparse_texture2 : enable\n";
|
header += "#extension GL_ARB_sparse_texture2 : enable\n";
|
||||||
|
header += "#extension GL_ARB_shader_viewport_layer_array : enable\n";
|
||||||
|
header += "#extension GL_NV_viewport_array2 : enable\n";
|
||||||
header += "#extension GL_EXT_texture_shadow_lod : enable\n";
|
header += "#extension GL_EXT_texture_shadow_lod : enable\n";
|
||||||
if (info.uses_int64) {
|
if (info.uses_int64) {
|
||||||
header += "#extension GL_ARB_gpu_shader_int64 : enable\n";
|
header += "#extension GL_ARB_gpu_shader_int64 : enable\n";
|
||||||
|
@ -243,9 +245,13 @@ void EmitContext::SetupImages(Bindings& bindings) {
|
||||||
}
|
}
|
||||||
texture_buffer_bindings.reserve(info.texture_buffer_descriptors.size());
|
texture_buffer_bindings.reserve(info.texture_buffer_descriptors.size());
|
||||||
for (const auto& desc : info.texture_buffer_descriptors) {
|
for (const auto& desc : info.texture_buffer_descriptors) {
|
||||||
throw NotImplementedException("TextureType::Buffer");
|
|
||||||
|
|
||||||
texture_buffer_bindings.push_back(bindings.texture);
|
texture_buffer_bindings.push_back(bindings.texture);
|
||||||
|
const auto sampler_type{SamplerType(TextureType::Buffer, false)};
|
||||||
|
const auto indices{bindings.texture + desc.count};
|
||||||
|
for (u32 index = bindings.texture; index < indices; ++index) {
|
||||||
|
header += fmt::format("layout(binding={}) uniform {} tex{};", bindings.texture,
|
||||||
|
sampler_type, index);
|
||||||
|
}
|
||||||
bindings.texture += desc.count;
|
bindings.texture += desc.count;
|
||||||
}
|
}
|
||||||
texture_bindings.reserve(info.texture_descriptors.size());
|
texture_bindings.reserve(info.texture_descriptors.size());
|
||||||
|
|
|
@ -186,6 +186,9 @@ void EmitSetAttribute(EmitContext& ctx, IR::Attribute attr, std::string_view val
|
||||||
case IR::Attribute::PositionW:
|
case IR::Attribute::PositionW:
|
||||||
ctx.Add("gl_Position.{}={};", swizzle, value);
|
ctx.Add("gl_Position.{}={};", swizzle, value);
|
||||||
break;
|
break;
|
||||||
|
case IR::Attribute::ViewportIndex:
|
||||||
|
ctx.Add("gl_ViewportIndex=floatBitsToInt({});", value);
|
||||||
|
break;
|
||||||
case IR::Attribute::ClipDistance0:
|
case IR::Attribute::ClipDistance0:
|
||||||
case IR::Attribute::ClipDistance1:
|
case IR::Attribute::ClipDistance1:
|
||||||
case IR::Attribute::ClipDistance2:
|
case IR::Attribute::ClipDistance2:
|
||||||
|
|
|
@ -71,7 +71,7 @@ std::string PtpOffsets(const IR::Value& offset, const IR::Value& offset2) {
|
||||||
const std::array values{offset.InstRecursive(), offset2.InstRecursive()};
|
const std::array values{offset.InstRecursive(), offset2.InstRecursive()};
|
||||||
if (!values[0]->AreAllArgsImmediates() || !values[1]->AreAllArgsImmediates()) {
|
if (!values[0]->AreAllArgsImmediates() || !values[1]->AreAllArgsImmediates()) {
|
||||||
// LOG_WARNING("Not all arguments in PTP are immediate, STUBBING");
|
// LOG_WARNING("Not all arguments in PTP are immediate, STUBBING");
|
||||||
return "";
|
return "ivec2[](ivec2(0), ivec2(1), ivec2(2), ivec2(3))";
|
||||||
}
|
}
|
||||||
const IR::Opcode opcode{values[0]->GetOpcode()};
|
const IR::Opcode opcode{values[0]->GetOpcode()};
|
||||||
if (opcode != values[1]->GetOpcode() || opcode != IR::Opcode::CompositeConstructU32x4) {
|
if (opcode != values[1]->GetOpcode() || opcode != IR::Opcode::CompositeConstructU32x4) {
|
||||||
|
@ -340,8 +340,8 @@ void EmitImageFetch([[maybe_unused]] EmitContext& ctx, [[maybe_unused]] IR::Inst
|
||||||
*sparse_inst, texture, CastToIntVec(coords, info), lod,
|
*sparse_inst, texture, CastToIntVec(coords, info), lod,
|
||||||
CastToIntVec(offset, info), texel);
|
CastToIntVec(offset, info), texel);
|
||||||
} else {
|
} else {
|
||||||
ctx.AddU1("{}=sparseTexelsResidentARB(sparseTexelFetchARB({},{},{},{}));", *sparse_inst,
|
ctx.AddU1("{}=sparseTexelsResidentARB(sparseTexelFetchARB({},{},int({}),{}));",
|
||||||
texture, CastToIntVec(coords, info), lod, texel);
|
*sparse_inst, texture, CastToIntVec(coords, info), lod, texel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue