| 848 | } |
| 849 | |
| 850 | void generateInputResourceOffsetTable(InputResourceOffsets* outTable, ShaderBinaryInfo* sb) |
| 851 | { |
| 852 | SCE_GNM_ASSERT(outTable != NULL); |
| 853 | //SCE_GNM_ASSERT(shaderStage <= kShaderStageCount); |
| 854 | |
| 855 | // Get resource info to populate ShaderResourceOffsets |
| 856 | //ShaderBinaryInfo const *shaderBinaryInfo = (ShaderBinaryInfo const*)((uintptr_t)shaderCode + shaderCodeSizeInBytes - sizeof(ShaderBinaryInfo)); |
| 857 | ShaderBinaryInfo const *shaderBinaryInfo = sb; |
| 858 | //SCE_GNM_ASSERT((*(reinterpret_cast<uint64_t const*>(shaderBinaryInfo->m_signature)) & kShaderBinaryInfoSignatureMask) == kShaderBinaryInfoSignatureU64); |
| 859 | |
| 860 | // Get usage masks and input usage slots |
| 861 | |
| 862 | uint32_t const* usageMasks = reinterpret_cast<unsigned int const*>((unsigned char const*)shaderBinaryInfo - shaderBinaryInfo->m_chunkUsageBaseOffsetInDW * 4); |
| 863 | int32_t inputUsageSlotsCount = shaderBinaryInfo->m_numInputUsageSlots; |
| 864 | InputUsageSlot const* inputUsageSlots = (InputUsageSlot const*)usageMasks - inputUsageSlotsCount; |
| 865 | |
| 866 | // Cache shader input information into the ShaderResource Offsets table |
| 867 | __builtin_memset(outTable, 0xFF, sizeof(InputResourceOffsets)); |
| 868 | outTable->initSupportedResourceCounts(); |
| 869 | //outTable->shaderStage = isDispatchDraw && shaderStage == kShaderStageCs ? kShaderStageAsynchronousCompute : shaderStage; |
| 870 | //outTable->isSrtShader = isSrtUsed; |
| 871 | int32_t lastUserDataResourceSizeInDwords = 0; |
| 872 | uint16_t requiredMemorySizeInDwords = 0; |
| 873 | |
| 874 | // Here we handle all immediate resources s[1:16] plus s[16:48] (extended user data) |
| 875 | // resources that go into the extended user data also have "immediate" usage type, although they are stored in a table (not loaded by the SPI) |
| 876 | for (int32_t i = 0; i < inputUsageSlotsCount; ++i) |
| 877 | { |
| 878 | uint8_t apiSlot = inputUsageSlots[i].m_apiSlot; |
| 879 | uint8_t startRegister = inputUsageSlots[i].m_startRegister; |
| 880 | bool isVSharp = (inputUsageSlots[i].m_resourceType == 0); |
| 881 | uint16_t vsharpFlag = (isVSharp) ? kResourceIsVSharp : 0; |
| 882 | |
| 883 | uint16_t extendedRegisterOffsetInDwords = (startRegister >= kMaxUserDataCount) ? |
| 884 | (startRegister - kMaxUserDataCount) : 0; |
| 885 | requiredMemorySizeInDwords = (requiredMemorySizeInDwords > extendedRegisterOffsetInDwords) ? |
| 886 | requiredMemorySizeInDwords : extendedRegisterOffsetInDwords; |
| 887 | |
| 888 | // Handle immediate resources, including some pointer types |
| 889 | switch (inputUsageSlots[i].m_usageType) |
| 890 | { |
| 891 | case kShaderInputUsageImmGdsCounterRange: |
| 892 | outTable->appendConsumeCounterSgpr = startRegister; |
| 893 | break; |
| 894 | |
| 895 | case kShaderInputUsageImmGdsMemoryRange: |
| 896 | outTable->gdsMemoryRangeSgpr = startRegister; |
| 897 | break; |
| 898 | |
| 899 | case kShaderInputUsageImmLdsEsGsSize: |
| 900 | outTable->ldsEsGsSizeSgpr = startRegister; |
| 901 | break; |
| 902 | |
| 903 | case kShaderInputUsageSubPtrFetchShader: |
| 904 | SCE_GNM_ASSERT(apiSlot == 0); |
| 905 | outTable->fetchShaderPtrSgpr = startRegister; |
| 906 | break; |
| 907 |
no test coverage detected