mirror of
https://github.com/KytyPS5/KytyPS5.git
synced 2026-10-29 08:41:20 +00:00
shader: share packed color component encoding
This commit is contained in:
1 parent
87d938139d
commit
fb213e8ae5
3 files changed
+21
-10
No files matched your search
@@ -642,19 +642,13 @@ uint32_t StoreTexel(ValueEmitContext& ctx, const IR::MemoryInfo& mem, uint32_t d
|
|||||||
}
|
}
|
||||||
if (converted) {
|
if (converted) {
|
||||||
if (!selected) continue;
|
if (!selected) continue;
|
||||||
auto value = EncodeFormattedStoreComponent(ctx.state, info, component, raw, mem.data_bits);
|
|
||||||
if (!packed) {
|
if (!packed) {
|
||||||
values[component] = value;
|
values[component] =
|
||||||
|
EncodeFormattedStoreComponent(ctx.state, info, component, raw, mem.data_bits);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (info.type == Format::ComponentType::Uint) {
|
const auto value =
|
||||||
value = EmitUMin32(ctx.state, value,
|
EncodePackedColorComponent(ctx.state, info, component, raw, mem.data_bits);
|
||||||
ConstantU32(ctx.state, (1u << info.component_bits[component]) - 1u));
|
|
||||||
}
|
|
||||||
if (info.component_bit_offset[component] != 0u) {
|
|
||||||
value = Binary(ctx.state, spv::OpShiftLeftLogical, TypeU32(ctx.state), value,
|
|
||||||
ConstantU32(ctx.state, info.component_bit_offset[component]));
|
|
||||||
}
|
|
||||||
packed_value = packed_value == zero ? value
|
packed_value = packed_value == zero ? value
|
||||||
: Binary(ctx.state, spv::OpBitwiseOr, TypeU32(ctx.state), packed_value, value);
|
: Binary(ctx.state, spv::OpBitwiseOr, TypeU32(ctx.state), packed_value, value);
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -459,6 +459,9 @@ uint32_t NormalizeFormatComponent(EmitterState& state, const Format::BufferForma
|
|||||||
uint32_t EncodeFormattedStoreComponent(EmitterState& state, const Format::BufferFormatInfo& info,
|
uint32_t EncodeFormattedStoreComponent(EmitterState& state, const Format::BufferFormatInfo& info,
|
||||||
uint32_t component, uint32_t data, uint32_t data_bits);
|
uint32_t component, uint32_t data, uint32_t data_bits);
|
||||||
|
|
||||||
|
uint32_t EncodePackedColorComponent(EmitterState& state, const Format::BufferFormatInfo& info,
|
||||||
|
uint32_t component, uint32_t data, uint32_t data_bits);
|
||||||
|
|
||||||
spv::Op SpirvAtomicOpcode(IR::ValueOpcode opcode);
|
spv::Op SpirvAtomicOpcode(IR::ValueOpcode opcode);
|
||||||
|
|
||||||
uint32_t EmitAtomicOperation(ValueEmitContext& ctx, const IR::Inst& inst, uint32_t pointer,
|
uint32_t EmitAtomicOperation(ValueEmitContext& ctx, const IR::Inst& inst, uint32_t pointer,
|
||||||
|
|||||||
@@ -480,6 +480,20 @@ uint32_t EncodeFormattedStoreComponent(EmitterState& state, const Format::Buffer
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t EncodePackedColorComponent(EmitterState& state, const Format::BufferFormatInfo& info,
|
||||||
|
uint32_t component, uint32_t data, uint32_t data_bits) {
|
||||||
|
auto value = EncodeFormattedStoreComponent(state, info, component, data, data_bits);
|
||||||
|
if (info.type == Format::ComponentType::Uint) {
|
||||||
|
value = EmitUMin32(state, value,
|
||||||
|
ConstantU32(state, (1u << info.component_bits[component]) - 1u));
|
||||||
|
}
|
||||||
|
if (info.component_bit_offset[component] != 0u) {
|
||||||
|
value = Binary(state, spv::OpShiftLeftLogical, TypeU32(state), value,
|
||||||
|
ConstantU32(state, info.component_bit_offset[component]));
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
spv::Op SpirvAtomicOpcode(IR::ValueOpcode opcode) {
|
spv::Op SpirvAtomicOpcode(IR::ValueOpcode opcode) {
|
||||||
switch (opcode) {
|
switch (opcode) {
|
||||||
case IR::ValueOpcode::SharedAtomicCmpSwap64:
|
case IR::ValueOpcode::SharedAtomicCmpSwap64:
|
||||||
|
|||||||
Reference in new issue
Block a user