shader_recompiler: support const buffer indirect addressing on OpenGL SPIR-V
This commit is contained in:
parent
8e9d253687
commit
a45baa0e78
|
@ -1043,15 +1043,15 @@ void EmitContext::DefineConstantBufferIndirectFunctions(const Info& info) {
|
|||
const Id merge_label{OpLabel()};
|
||||
const Id uniform_type{uniform_types.*member_ptr};
|
||||
|
||||
std::array<Id, Info::MAX_CBUFS> buf_labels;
|
||||
std::array<Sirit::Literal, Info::MAX_CBUFS> buf_literals;
|
||||
for (u32 i = 0; i < Info::MAX_CBUFS; i++) {
|
||||
std::array<Id, Info::MAX_INDIRECT_CBUFS> buf_labels;
|
||||
std::array<Sirit::Literal, Info::MAX_INDIRECT_CBUFS> buf_literals;
|
||||
for (u32 i = 0; i < Info::MAX_INDIRECT_CBUFS; i++) {
|
||||
buf_labels[i] = OpLabel();
|
||||
buf_literals[i] = Sirit::Literal{i};
|
||||
}
|
||||
OpSelectionMerge(merge_label, spv::SelectionControlMask::MaskNone);
|
||||
OpSwitch(binding, buf_labels[0], buf_literals, buf_labels);
|
||||
for (u32 i = 0; i < Info::MAX_CBUFS; i++) {
|
||||
for (u32 i = 0; i < Info::MAX_INDIRECT_CBUFS; i++) {
|
||||
AddLabel(buf_labels[i]);
|
||||
const Id cbuf{cbufs[i].*member_ptr};
|
||||
const Id access_chain{OpAccessChain(uniform_type, cbuf, u32_zero_value, offset)};
|
||||
|
@ -1064,22 +1064,23 @@ void EmitContext::DefineConstantBufferIndirectFunctions(const Info& info) {
|
|||
return func;
|
||||
}};
|
||||
IR::Type types{info.used_indirect_cbuf_types};
|
||||
if (True(types & IR::Type::U8)) {
|
||||
bool supports_aliasing = profile.support_descriptor_aliasing;
|
||||
if (supports_aliasing && True(types & IR::Type::U8)) {
|
||||
load_const_func_u8 = make_accessor(U8, &UniformDefinitions::U8);
|
||||
}
|
||||
if (True(types & IR::Type::U16)) {
|
||||
if (supports_aliasing && True(types & IR::Type::U16)) {
|
||||
load_const_func_u16 = make_accessor(U16, &UniformDefinitions::U16);
|
||||
}
|
||||
if (True(types & IR::Type::F32)) {
|
||||
if (supports_aliasing && True(types & IR::Type::F32)) {
|
||||
load_const_func_f32 = make_accessor(F32[1], &UniformDefinitions::F32);
|
||||
}
|
||||
if (True(types & IR::Type::U32)) {
|
||||
if (supports_aliasing && True(types & IR::Type::U32)) {
|
||||
load_const_func_u32 = make_accessor(U32[1], &UniformDefinitions::U32);
|
||||
}
|
||||
if (True(types & IR::Type::U32x2)) {
|
||||
if (supports_aliasing && True(types & IR::Type::U32x2)) {
|
||||
load_const_func_u32x2 = make_accessor(U32[2], &UniformDefinitions::U32x2);
|
||||
}
|
||||
if (True(types & IR::Type::U32x4)) {
|
||||
if (!supports_aliasing || True(types & IR::Type::U32x4)) {
|
||||
load_const_func_u32x4 = make_accessor(U32[4], &UniformDefinitions::U32x4);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,13 +32,8 @@ void AddConstantBufferDescriptor(Info& info, u32 index, u32 count) {
|
|||
void AddRegisterIndexedLdc(Info& info) {
|
||||
info.uses_cbuf_indirect = true;
|
||||
|
||||
// The shader can use any possible constant buffer
|
||||
info.constant_buffer_mask = (1 << Info::MAX_CBUFS) - 1;
|
||||
|
||||
auto& cbufs{info.constant_buffer_descriptors};
|
||||
cbufs.clear();
|
||||
for (u32 i = 0; i < Info::MAX_CBUFS; i++) {
|
||||
cbufs.push_back(ConstantBufferDescriptor{.index = i, .count = 1});
|
||||
for (u32 i = 0; i < Info::MAX_INDIRECT_CBUFS; i++) {
|
||||
AddConstantBufferDescriptor(info, i, 1);
|
||||
|
||||
// The shader can use any possible access size
|
||||
info.constant_buffer_used_sizes[i] = 0x10'000;
|
||||
|
|
|
@ -105,6 +105,7 @@ struct ImageDescriptor {
|
|||
using ImageDescriptors = boost::container::small_vector<ImageDescriptor, 4>;
|
||||
|
||||
struct Info {
|
||||
static constexpr size_t MAX_INDIRECT_CBUFS{16};
|
||||
static constexpr size_t MAX_CBUFS{18};
|
||||
static constexpr size_t MAX_SSBOS{32};
|
||||
|
||||
|
|
Reference in New Issue