mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-08-04 16:32:39 +00:00
Address review comments.
This commit is contained in:
parent
15a47d10ae
commit
a66adebe1b
@ -419,11 +419,9 @@ static Id EmitLoadBufferBoundsCheck(EmitContext& ctx, Id index, Id buffer_size,
|
|||||||
auto zero_value = is_float ? ctx.f32_zero_value : ctx.u32_zero_value;
|
auto zero_value = is_float ? ctx.f32_zero_value : ctx.u32_zero_value;
|
||||||
if (N > 1) {
|
if (N > 1) {
|
||||||
compare_index = ctx.OpIAdd(ctx.U32[1], index, ctx.ConstU32(N - 1));
|
compare_index = ctx.OpIAdd(ctx.U32[1], index, ctx.ConstU32(N - 1));
|
||||||
boost::container::static_vector<Id, N> zero_ids;
|
std::array<Id, N> zero_ids;
|
||||||
for (u32 i = 0; i < N; i++) {
|
zero_ids.fill(zero_value);
|
||||||
zero_ids.push_back(zero_value);
|
zero_value = ctx.ConstantComposite(result_type, zero_ids);
|
||||||
}
|
|
||||||
zero_value = ctx.OpCompositeConstruct(result_type, zero_ids);
|
|
||||||
}
|
}
|
||||||
const Id in_bounds = ctx.OpULessThan(ctx.U1[1], compare_index, buffer_size);
|
const Id in_bounds = ctx.OpULessThan(ctx.U1[1], compare_index, buffer_size);
|
||||||
return ctx.OpSelect(result_type, in_bounds, result, zero_value);
|
return ctx.OpSelect(result_type, in_bounds, result, zero_value);
|
||||||
|
@ -211,7 +211,8 @@ Id EmitContext::GetBufferSize(const u32 sharp_idx) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void EmitContext::DefineBufferProperties() {
|
void EmitContext::DefineBufferProperties() {
|
||||||
for (BufferDefinition& buffer : buffers) {
|
for (u32 i = 0; i < buffers.size(); i++) {
|
||||||
|
BufferDefinition& buffer = buffers[i];
|
||||||
if (buffer.buffer_type != BufferType::Guest) {
|
if (buffer.buffer_type != BufferType::Guest) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -230,10 +231,11 @@ void EmitContext::DefineBufferProperties() {
|
|||||||
// Only need to load size if performing bounds checks and the buffer is both guest and not
|
// Only need to load size if performing bounds checks and the buffer is both guest and not
|
||||||
// inline.
|
// inline.
|
||||||
if (!profile.supports_robust_buffer_access && buffer.buffer_type == BufferType::Guest) {
|
if (!profile.supports_robust_buffer_access && buffer.buffer_type == BufferType::Guest) {
|
||||||
if (buffer.desc.sharp_idx == std::numeric_limits<u32>::max()) {
|
const BufferResource& desc = info.buffers[i];
|
||||||
buffer.size = ConstU32(buffer.desc.inline_cbuf.GetSize());
|
if (desc.sharp_idx == std::numeric_limits<u32>::max()) {
|
||||||
|
buffer.size = ConstU32(desc.inline_cbuf.GetSize());
|
||||||
} else {
|
} else {
|
||||||
buffer.size = GetBufferSize(buffer.desc.sharp_idx);
|
buffer.size = GetBufferSize(desc.sharp_idx);
|
||||||
}
|
}
|
||||||
Name(buffer.size, fmt::format("buf{}_size", binding));
|
Name(buffer.size, fmt::format("buf{}_size", binding));
|
||||||
buffer.size_shorts = OpShiftRightLogical(U32[1], buffer.size, ConstU32(1U));
|
buffer.size_shorts = OpShiftRightLogical(U32[1], buffer.size, ConstU32(1U));
|
||||||
@ -715,7 +717,7 @@ void EmitContext::DefineBuffers() {
|
|||||||
const bool is_storage = desc.IsStorage(buf_sharp, profile);
|
const bool is_storage = desc.IsStorage(buf_sharp, profile);
|
||||||
|
|
||||||
// Define aliases depending on the shader usage.
|
// Define aliases depending on the shader usage.
|
||||||
auto& spv_buffer = buffers.emplace_back(binding.buffer++, desc.buffer_type, desc);
|
auto& spv_buffer = buffers.emplace_back(binding.buffer++, desc.buffer_type);
|
||||||
if (True(desc.used_types & IR::Type::U32)) {
|
if (True(desc.used_types & IR::Type::U32)) {
|
||||||
spv_buffer[BufferAlias::U32] =
|
spv_buffer[BufferAlias::U32] =
|
||||||
DefineBuffer(is_storage, desc.is_written, 2, desc.buffer_type, U32[1]);
|
DefineBuffer(is_storage, desc.is_written, 2, desc.buffer_type, U32[1]);
|
||||||
|
@ -246,7 +246,6 @@ public:
|
|||||||
struct BufferDefinition {
|
struct BufferDefinition {
|
||||||
u32 binding;
|
u32 binding;
|
||||||
BufferType buffer_type;
|
BufferType buffer_type;
|
||||||
const BufferResource& desc;
|
|
||||||
Id offset;
|
Id offset;
|
||||||
Id offset_dwords;
|
Id offset_dwords;
|
||||||
Id size;
|
Id size;
|
||||||
|
Loading…
Reference in New Issue
Block a user