mirror of
https://github.com/KytyPS5/KytyPS5.git
synced 2026-10-27 16:02:37 +00:00
shader: bound storage buffers by pushed binding sizes instead of OpArrayLength
This commit is contained in:
1 parent
7524e8f79e
commit
ba7f9969ef
7 files changed
+96
-38
No files matched your search
+16
-19
@@ -7464,7 +7464,7 @@ void TestNewShaderRecompilerMubufFormatTranslation() {
|
||||
CheckSpirvBinaryValidates(result.spirv);
|
||||
}
|
||||
|
||||
void TestNewShaderRecompilerFormattedStoreUsesRuntimeArrayLengthOnly() {
|
||||
void TestNewShaderRecompilerFormattedStoreUsesRuntimeBindingSizeOnly() {
|
||||
const uint32_t shader[] = {
|
||||
EncodeMubuf0(0x04),
|
||||
EncodeMubuf1(0, 0, 1), // buffer_store_format_x
|
||||
@@ -7491,8 +7491,9 @@ void TestNewShaderRecompilerFormattedStoreUsesRuntimeArrayLengthOnly() {
|
||||
CheckSpirvBinaryValidates(result.spirv);
|
||||
|
||||
const auto source = DisassembleSpirvBinary(result.spirv);
|
||||
Check((source.find("OpArrayLength") != std::string::npos),
|
||||
"formatted store SPIR-V lacks runtime storage-buffer bounds check");
|
||||
Check(source.find("OpULessThan") != std::string::npos &&
|
||||
source.find("OpArrayLength") == std::string::npos,
|
||||
"formatted store SPIR-V lacks a bounds check against its pushed binding size");
|
||||
Check(
|
||||
!SpirvSourceHasInstructionUsing(source, "OpULessThan", "%uint_5"),
|
||||
"formatted store SPIR-V baked descriptor NumRecords into a store guard");
|
||||
@@ -10638,19 +10639,18 @@ void TestNewShaderRecompilerBufferLoadsGuardedByExec() {
|
||||
const auto source = DisassembleSpirvBinary(result.spirv);
|
||||
const auto exec_branch =
|
||||
source.find("OpBranchConditional", 0);
|
||||
const auto array_length =
|
||||
source.find("OpArrayLength", 0);
|
||||
const auto bounds_branch = source.find("OpBranchConditional", array_length);
|
||||
const auto bounds = source.find("OpULessThan", 0);
|
||||
const auto bounds_branch = source.find("OpBranchConditional", bounds);
|
||||
const auto element_access = source.find("OpAccessChain %_ptr_StorageBuffer_uint", 0);
|
||||
Check(exec_branch != std::string::npos,
|
||||
"buffer load SPIR-V lacks EXEC guard branch");
|
||||
Check(array_length != std::string::npos,
|
||||
"buffer load SPIR-V lacks storage buffer array-length bounds check");
|
||||
Check(bounds != std::string::npos,
|
||||
"buffer load SPIR-V lacks storage buffer bounds check");
|
||||
Check(bounds_branch != std::string::npos,
|
||||
"buffer load SPIR-V lacks storage buffer bounds branch");
|
||||
Check(element_access != std::string::npos,
|
||||
"buffer load SPIR-V lacks storage element access");
|
||||
Check(exec_branch < array_length,
|
||||
Check(exec_branch < bounds,
|
||||
"buffer load bounds check was emitted outside EXEC guard");
|
||||
Check(bounds_branch < element_access,
|
||||
"buffer load storage element pointer was formed before bounds guard");
|
||||
@@ -10683,13 +10683,12 @@ void TestNewShaderRecompilerBufferAtomicsGuardedByBounds() {
|
||||
CheckSpirvBinaryValidates(result.spirv);
|
||||
|
||||
const auto source = DisassembleSpirvBinary(result.spirv);
|
||||
const auto array_length =
|
||||
source.find("OpArrayLength", 0);
|
||||
const auto bounds_branch = source.find("OpBranchConditional", array_length);
|
||||
const auto bounds = source.find("OpULessThan", 0);
|
||||
const auto bounds_branch = source.find("OpBranchConditional", bounds);
|
||||
const auto atomic = source.find(test.spirv, 0);
|
||||
const auto memory_barrier =
|
||||
source.find("OpMemoryBarrier", atomic);
|
||||
Check(array_length != std::string::npos &&
|
||||
Check(bounds != std::string::npos &&
|
||||
bounds_branch != std::string::npos &&
|
||||
atomic != std::string::npos &&
|
||||
memory_barrier != std::string::npos,
|
||||
@@ -10738,14 +10737,13 @@ void TestCapturedBufferAtomicsX2() {
|
||||
"64-bit buffer atomic storage view does not use eight-byte elements");
|
||||
Check(CountSourceOccurrences(source, "Aliased") == 2u,
|
||||
"both storage-buffer views must declare that they alias");
|
||||
const auto array_length =
|
||||
source.find("OpArrayLength", 0);
|
||||
const auto bounds_branch = source.find("OpBranchConditional", array_length);
|
||||
const auto bounds = source.find("OpULessThan", 0);
|
||||
const auto bounds_branch = source.find("OpBranchConditional", bounds);
|
||||
const auto atomic =
|
||||
source.find(test.spirv_name, 0);
|
||||
const auto memory_barrier =
|
||||
source.find("OpMemoryBarrier", atomic);
|
||||
Check(array_length != std::string::npos &&
|
||||
Check(bounds != std::string::npos &&
|
||||
bounds_branch != std::string::npos &&
|
||||
atomic != std::string::npos && bounds_branch < atomic,
|
||||
"64-bit buffer atomic was not guarded by storage-buffer bounds");
|
||||
@@ -16577,7 +16575,6 @@ void TestNewShaderRecompilerSpirvSizeBaselines() {
|
||||
.variables = 2,
|
||||
.loads = 9,
|
||||
.stores = 4,
|
||||
.array_lengths = 2,
|
||||
.phis = 5,
|
||||
.labels = 34,
|
||||
.selection_merges = 10,
|
||||
@@ -16778,7 +16775,7 @@ int main() {
|
||||
TestNewShaderRecompilerNativeWideBufferIr();
|
||||
TestNewShaderRecompilerScalarB64LaneTranslation();
|
||||
TestNewShaderRecompilerMubufFormatTranslation();
|
||||
TestNewShaderRecompilerFormattedStoreUsesRuntimeArrayLengthOnly();
|
||||
TestNewShaderRecompilerFormattedStoreUsesRuntimeBindingSizeOnly();
|
||||
TestNewShaderRecompilerTypedBufferTranslation();
|
||||
TestNewShaderRecompilerDsReadWrite2Translation();
|
||||
TestNewShaderRecompilerDsWideAndAtomicTranslation();
|
||||
|
||||
Reference in new issue
Block a user