; --probe-vkmem (runtime/tex_probe.c test_gpa_read): one invocation reads a 32-bit word of guest memory through the ; device address table as the game's translated shaders do, by the table's layout (runtime/vk_gpa.c): L1 at word 16, ; one entry per 16 MiB; L2 blocks of 4096 page entries from word 65552; word 2 holds the word index of the records, ; four words each, the first two the buffer's device address minus the guest address of its byte 0. The pool that ; holds the word is never a descriptor of the shader: only the table (binding 0) and a result word (binding 1) are. ; An address no page maps gives 0. Written in SPIR-V assembly (spirv-as; no GLSL compiler in the build). As GLSL: ; #extension GL_EXT_buffer_reference : require ; layout(local_size_x = 1) in; ; layout(std430, binding = 0) readonly buffer Table { uint t[]; }; ; layout(std430, binding = 1) buffer Result { uint r[]; }; ; layout(push_constant) uniform Push { uint64_t guest; } pc; ; layout(buffer_reference, std430, buffer_reference_align = 4) readonly buffer Word { uint v; }; ; void main() { ; uint rec = t[65552u + (t[16u + uint(pc.guest >> 24)] << 12) + (uint(pc.guest >> 12) & 4095u)]; ; if (rec == 0u) { r[0] = 0u; return; } ; uint at = t[2] + (rec << 2); ; r[0] = Word(pc.guest + (uint64_t(t[at]) | uint64_t(t[at + 1u]) << 32)).v; ; } OpCapability Shader OpCapability Int64 OpCapability PhysicalStorageBufferAddresses OpExtension "SPV_KHR_physical_storage_buffer" OpMemoryModel PhysicalStorageBuffer64 GLSL450 OpEntryPoint GLCompute %main "main" %table %result %push OpExecutionMode %main LocalSize 1 1 1 OpDecorate %_runtimearr_uint ArrayStride 4 OpDecorate %Words Block OpMemberDecorate %Words 0 Offset 0 OpDecorate %table DescriptorSet 0 OpDecorate %table Binding 0 OpDecorate %result DescriptorSet 0 OpDecorate %result Binding 1 OpDecorate %Push Block OpMemberDecorate %Push 0 Offset 0 %void = OpTypeVoid %uint = OpTypeInt 32 0 %ulong = OpTypeInt 64 0 %bool = OpTypeBool %fn = OpTypeFunction %void %_runtimearr_uint = OpTypeRuntimeArray %uint %Words = OpTypeStruct %_runtimearr_uint %ptr_words = OpTypePointer StorageBuffer %Words %_ptr_StorageBuffer_uint = OpTypePointer StorageBuffer %uint %table = OpVariable %ptr_words StorageBuffer %result = OpVariable %ptr_words StorageBuffer %Push = OpTypeStruct %ulong %ptr_push = OpTypePointer PushConstant %Push %push = OpVariable %ptr_push PushConstant %_ptr_PushConstant_ulong = OpTypePointer PushConstant %ulong %_ptr_PhysicalStorageBuffer_uint = OpTypePointer PhysicalStorageBuffer %uint %uint_0 = OpConstant %uint 0 %uint_1 = OpConstant %uint 1 %uint_2 = OpConstant %uint 2 %uint_4 = OpConstant %uint 4 %uint_12 = OpConstant %uint 12 %uint_16 = OpConstant %uint 16 %uint_24 = OpConstant %uint 24 %uint_32 = OpConstant %uint 32 %uint_4095 = OpConstant %uint 4095 %uint_65552 = OpConstant %uint 65552 %main = OpFunction %void None %fn %entry = OpLabel %28 = OpAccessChain %_ptr_PushConstant_ulong %push %uint_0 %guest = OpLoad %ulong %28 %30 = OpShiftRightLogical %ulong %guest %uint_24 %31 = OpUConvert %uint %30 %59 = OpIAdd %uint %31 %uint_16 %32 = OpAccessChain %_ptr_StorageBuffer_uint %table %uint_0 %59 %block = OpLoad %uint %32 %34 = OpShiftRightLogical %ulong %guest %uint_12 %35 = OpUConvert %uint %34 %page = OpBitwiseAnd %uint %35 %uint_4095 %62 = OpShiftLeftLogical %uint %block %uint_12 %63 = OpIAdd %uint %uint_65552 %62 %42 = OpIAdd %uint %63 %page %37 = OpAccessChain %_ptr_StorageBuffer_uint %table %uint_0 %42 %rec = OpLoad %uint %37 %out = OpAccessChain %_ptr_StorageBuffer_uint %result %uint_0 %uint_0 %mapped = OpINotEqual %bool %rec %uint_0 OpSelectionMerge %done None OpBranchConditional %mapped %is_mapped %not_mapped %is_mapped = OpLabel %43 = OpAccessChain %_ptr_StorageBuffer_uint %table %uint_0 %uint_2 %recs = OpLoad %uint %43 %45 = OpShiftLeftLogical %uint %rec %uint_2 %at = OpIAdd %uint %recs %45 %47 = OpAccessChain %_ptr_StorageBuffer_uint %table %uint_0 %at %48 = OpLoad %uint %47 %49 = OpIAdd %uint %at %uint_1 %50 = OpAccessChain %_ptr_StorageBuffer_uint %table %uint_0 %49 %51 = OpLoad %uint %50 %52 = OpUConvert %ulong %48 %53 = OpUConvert %ulong %51 %54 = OpShiftLeftLogical %ulong %53 %uint_32 %delta = OpBitwiseOr %ulong %52 %54 %56 = OpIAdd %ulong %guest %delta %ptr = OpConvertUToPtr %_ptr_PhysicalStorageBuffer_uint %56 %value = OpLoad %uint %ptr Aligned 4 OpStore %out %value OpBranch %done %not_mapped = OpLabel OpStore %out %uint_0 OpBranch %done %done = OpLabel OpReturn OpFunctionEnd