|
|
@ -45,6 +45,30 @@ void AddRegisterIndexedLdc(Info& info) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
u32 GetElementSize(IR::Type& used_type, Shader::IR::Opcode opcode) {
|
|
|
|
|
|
|
|
switch (opcode) {
|
|
|
|
|
|
|
|
case IR::Opcode::GetCbufU8:
|
|
|
|
|
|
|
|
case IR::Opcode::GetCbufS8:
|
|
|
|
|
|
|
|
used_type |= IR::Type::U8;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
case IR::Opcode::GetCbufU16:
|
|
|
|
|
|
|
|
case IR::Opcode::GetCbufS16:
|
|
|
|
|
|
|
|
used_type |= IR::Type::U16;
|
|
|
|
|
|
|
|
return 2;
|
|
|
|
|
|
|
|
case IR::Opcode::GetCbufU32:
|
|
|
|
|
|
|
|
used_type |= IR::Type::U32;
|
|
|
|
|
|
|
|
return 4;
|
|
|
|
|
|
|
|
case IR::Opcode::GetCbufF32:
|
|
|
|
|
|
|
|
used_type |= IR::Type::F32;
|
|
|
|
|
|
|
|
return 4;
|
|
|
|
|
|
|
|
case IR::Opcode::GetCbufU32x2:
|
|
|
|
|
|
|
|
used_type |= IR::Type::U32x2;
|
|
|
|
|
|
|
|
return 8;
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
throw InvalidArgument("Invalid opcode {}", opcode);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GetPatch(Info& info, IR::Patch patch) {
|
|
|
|
void GetPatch(Info& info, IR::Patch patch) {
|
|
|
|
if (!IR::IsGeneric(patch)) {
|
|
|
|
if (!IR::IsGeneric(patch)) {
|
|
|
|
throw NotImplementedException("Reading non-generic patch {}", patch);
|
|
|
|
throw NotImplementedException("Reading non-generic patch {}", patch);
|
|
|
@ -481,45 +505,16 @@ void VisitUsages(Info& info, IR::Inst& inst) {
|
|
|
|
const IR::Value offset{inst.Arg(1)};
|
|
|
|
const IR::Value offset{inst.Arg(1)};
|
|
|
|
if (index.IsImmediate()) {
|
|
|
|
if (index.IsImmediate()) {
|
|
|
|
AddConstantBufferDescriptor(info, index.U32(), 1);
|
|
|
|
AddConstantBufferDescriptor(info, index.U32(), 1);
|
|
|
|
} else {
|
|
|
|
u32 element_size = GetElementSize(info.used_constant_buffer_types, inst.GetOpcode());
|
|
|
|
AddRegisterIndexedLdc(info);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
u32 element_size{};
|
|
|
|
|
|
|
|
switch (inst.GetOpcode()) {
|
|
|
|
|
|
|
|
case IR::Opcode::GetCbufU8:
|
|
|
|
|
|
|
|
case IR::Opcode::GetCbufS8:
|
|
|
|
|
|
|
|
info.used_constant_buffer_types |= IR::Type::U8;
|
|
|
|
|
|
|
|
element_size = 1;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IR::Opcode::GetCbufU16:
|
|
|
|
|
|
|
|
case IR::Opcode::GetCbufS16:
|
|
|
|
|
|
|
|
info.used_constant_buffer_types |= IR::Type::U16;
|
|
|
|
|
|
|
|
element_size = 2;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IR::Opcode::GetCbufU32:
|
|
|
|
|
|
|
|
info.used_constant_buffer_types |= IR::Type::U32;
|
|
|
|
|
|
|
|
element_size = 4;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IR::Opcode::GetCbufF32:
|
|
|
|
|
|
|
|
info.used_constant_buffer_types |= IR::Type::F32;
|
|
|
|
|
|
|
|
element_size = 4;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IR::Opcode::GetCbufU32x2:
|
|
|
|
|
|
|
|
info.used_constant_buffer_types |= IR::Type::U32x2;
|
|
|
|
|
|
|
|
element_size = 8;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (index.IsImmediate()) {
|
|
|
|
|
|
|
|
u32& size{info.constant_buffer_used_sizes[index.U32()]};
|
|
|
|
u32& size{info.constant_buffer_used_sizes[index.U32()]};
|
|
|
|
if (offset.IsImmediate()) {
|
|
|
|
if (offset.IsImmediate()) {
|
|
|
|
size = Common::AlignUp(std::max(size, offset.U32() + element_size), 16u);
|
|
|
|
size = Common::AlignUp(std::max(size, offset.U32() + element_size), 16u);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
size = 0x10'000;
|
|
|
|
size = 0x10'000;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
AddRegisterIndexedLdc(info);
|
|
|
|
|
|
|
|
GetElementSize(info.used_indirect_cbuf_types, inst.GetOpcode());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|