mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-07-12 04:35:56 +00:00
Fix shared memory definition when only one type is used (#3106)
This commit is contained in:
parent
21d14abaee
commit
9dd35c3a42
2 changed files with 36 additions and 17 deletions
|
@ -995,19 +995,26 @@ void EmitContext::DefineSharedMemory() {
|
|||
|
||||
const u32 num_elements{Common::DivCeil(shared_memory_size, element_size)};
|
||||
const Id array_type{TypeArray(element_type, ConstU32(num_elements))};
|
||||
Decorate(array_type, spv::Decoration::ArrayStride, element_size);
|
||||
|
||||
const Id struct_type{TypeStruct(array_type)};
|
||||
MemberDecorate(struct_type, 0u, spv::Decoration::Offset, 0u);
|
||||
const auto mem_type = [&] {
|
||||
if (num_types > 1) {
|
||||
const Id struct_type{TypeStruct(array_type)};
|
||||
Decorate(struct_type, spv::Decoration::Block);
|
||||
MemberDecorate(struct_type, 0u, spv::Decoration::Offset, 0u);
|
||||
return struct_type;
|
||||
} else {
|
||||
return array_type;
|
||||
}
|
||||
}();
|
||||
|
||||
const Id pointer = TypePointer(spv::StorageClass::Workgroup, struct_type);
|
||||
const Id pointer = TypePointer(spv::StorageClass::Workgroup, mem_type);
|
||||
const Id element_pointer = TypePointer(spv::StorageClass::Workgroup, element_type);
|
||||
const Id variable = AddGlobalVariable(pointer, spv::StorageClass::Workgroup);
|
||||
Name(variable, name);
|
||||
interfaces.push_back(variable);
|
||||
|
||||
if (num_types > 1) {
|
||||
Decorate(struct_type, spv::Decoration::Block);
|
||||
Decorate(array_type, spv::Decoration::ArrayStride, element_size);
|
||||
Decorate(variable, spv::Decoration::Aliased);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue