mirror of
https://github.com/KytyPS5/KytyPS5.git
synced 2026-10-28 22:06:59 +01:00
shader: emit 16-bit packs with a zero high lane as a mask
This commit is contained in:
@@ -135,6 +135,8 @@ void Translator::V_PACK_B32_F16(const Decoder::Instruction& inst) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
IR::U32 Translator::PackU16Lanes(IR::U32 low, IR::U32 high) {
|
IR::U32 Translator::PackU16Lanes(IR::U32 low, IR::U32 high) {
|
||||||
|
// A zero high lane zero-extends; descriptor tracking bounds a mask, not a bitfield insert.
|
||||||
|
if (high == IR::Value(0u)) return ir.BitwiseAnd(low, IR::U32(IR::Value(0xffffu)));
|
||||||
return IR::U32(
|
return IR::U32(
|
||||||
ir.Emit(IR::ValueOpcode::BitFieldInsert, {low, high, IR::Value(16u), IR::Value(16u)}));
|
ir.Emit(IR::ValueOpcode::BitFieldInsert, {low, high, IR::Value(16u), IR::Value(16u)}));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9553,6 +9553,28 @@ void TestNativeConstantSamplerSelection() {
|
|||||||
CheckSpirvBinaryValidates(result.spirv);
|
CheckSpirvBinaryValidates(result.spirv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TestPackedZeroHighSamplerTableKey() {
|
||||||
|
// s_pack_ll_b32_b16 with a zero high lane zero-extends a GPU-selected table key, so the
|
||||||
|
// sampler table stays bounded to 64Ki records.
|
||||||
|
const uint32_t shader[] = {
|
||||||
|
EncodeMubuf0(0x0c, 0, true), EncodeMubuf1(1, 3, 0), EncodeSopp(0x0c, 0),
|
||||||
|
EncodeVop1(0x02, 28, 257), EncodeSop2(0x32, 29, 28, 128),
|
||||||
|
EncodeSop2(0x1e, 30, 29, 132),
|
||||||
|
EncodeSmem0(0x0a, 24, 4), 30u << 25u, EncodeSopp(0x0c, 0),
|
||||||
|
EncodeMimg0(0x20, 0x1), EncodeMimg1(0, 4, 6, 2),
|
||||||
|
EncodeExp0(0x00, 0x1), EncodeExp1(0, 0, 0, 0),
|
||||||
|
EncodeSopp(0x01),
|
||||||
|
};
|
||||||
|
auto options = MakeCompileOptions(ShaderType::Pixel);
|
||||||
|
options.user_data = ImageTestUserData();
|
||||||
|
const auto translated = ShaderRecompiler::TranslateProgram(shader, options);
|
||||||
|
const auto plan = ShaderRecompiler::IR::ExtractResourcePlan(translated.program);
|
||||||
|
const auto& indirect =
|
||||||
|
plan.descriptor_sources[plan.info.samplers.at(0).source].indirect_descriptor;
|
||||||
|
Check(indirect && indirect->table_stride == 16u && indirect->table_maximum == 0xffffu,
|
||||||
|
"a zero-extended sampler table key lost its 16-bit bound");
|
||||||
|
}
|
||||||
|
|
||||||
void TestBoundedMaterialBufferStores(bool scalar_key) {
|
void TestBoundedMaterialBufferStores(bool scalar_key) {
|
||||||
// Captured batch search and descriptor waterfall, with deformation arithmetic removed.
|
// Captured batch search and descriptor waterfall, with deformation arithmetic removed.
|
||||||
const uint32_t shader[] = {
|
const uint32_t shader[] = {
|
||||||
@@ -16815,6 +16837,7 @@ int main() {
|
|||||||
TestNativeGuardedSamplerSource(false);
|
TestNativeGuardedSamplerSource(false);
|
||||||
TestNativeGuardedSamplerSource(true);
|
TestNativeGuardedSamplerSource(true);
|
||||||
TestNativeConstantSamplerSelection();
|
TestNativeConstantSamplerSelection();
|
||||||
|
TestPackedZeroHighSamplerTableKey();
|
||||||
for (const bool scalar_key : {false, true}) TestBoundedMaterialBufferStores(scalar_key);
|
for (const bool scalar_key : {false, true}) TestBoundedMaterialBufferStores(scalar_key);
|
||||||
TestNativeDescriptorProvenanceKeepsGpuSelection();
|
TestNativeDescriptorProvenanceKeepsGpuSelection();
|
||||||
TestCfgSiblingSharedExit();
|
TestCfgSiblingSharedExit();
|
||||||
|
|||||||
Reference in New Issue
Block a user