diff --git a/code/components/rage-formats-x/include/convert/gtaDrawable_five_rdr3.h b/code/components/rage-formats-x/include/convert/gtaDrawable_five_rdr3.h index f3e7450165..99439ad027 100644 --- a/code/components/rage-formats-x/include/convert/gtaDrawable_five_rdr3.h +++ b/code/components/rage-formats-x/include/convert/gtaDrawable_five_rdr3.h @@ -754,8 +754,9 @@ rdr3::grmShaderGroup* convert(five::grmShaderGroup* shaderGroup) for (int i = 0; i < textureRefs.size(); i++, idx++) { - *(uint32_t*)(&firstArg[(idx * 8) + 0]) = std::get<0>(textureRefs[i]); - *(uint32_t*)(&firstArg[(idx * 8) + 4]) = 0; // the game should guess this from hash as we don't match + args[idx].hash = std::get<0>(textureRefs[i]); + args[idx].texture.resourceClass = 0; + args[idx].texture.index = idx; } for (int i = 0; i < paramRefs.size(); i++, idx++) @@ -770,13 +771,12 @@ rdr3::grmShaderGroup* convert(five::grmShaderGroup* shaderGroup) size_t paramPtrSize = sizeof(uintptr_t) * 4 * shader->m_parameterData->numCBuffers; size_t paramDataSize = 4 * (16 * paramRefs.size()); - size_t texRefDataSize = (8 * textureRefs.size()); + size_t texRefDataSize = 4 * (8 * textureRefs.size()); size_t finalParamSize = (paramPtrSize + paramDataSize + texRefDataSize + shader->m_parameterData->numSamplers); - // we are allocating (final size * 2) so we can account for the game wanting to stuff its corrections in here - shader->m_parameterDataSize = finalParamSize * 2; + shader->m_parameterDataSize = finalParamSize; - auto paramBuffer = (char*)rdr3::pgStreamManager::Allocate(finalParamSize * 2, false, nullptr); + auto paramBuffer = (char*)rdr3::pgStreamManager::Allocate(finalParamSize, false, nullptr); auto prs = (rdr3::grmShaderParameter*)(paramBuffer); auto trs = (rdr3::grmShaderParameter*)(paramBuffer + paramPtrSize + paramDataSize); //rdr3::pgStreamManager::Allocate(sizeof(rdr3::grmShaderParameter) * textureRefs.size(), false, nullptr); @@ -785,6 +785,12 @@ rdr3::grmShaderGroup* convert(five::grmShaderGroup* shaderGroup) trs[i].SetValue(std::get<1>(textureRefs[i])); } + // we like to have 3 copies + for (int i = textureRefs.size(); i < textureRefs.size() * 4; i++) + { + trs[i].SetValue(0); + } + shader->m_textureRefs = trs; { diff --git a/code/components/rage-formats-x/include/rmcDrawable.h b/code/components/rage-formats-x/include/rmcDrawable.h index b40e65452f..08b832ba33 100644 --- a/code/components/rage-formats-x/include/rmcDrawable.h +++ b/code/components/rage-formats-x/include/rmcDrawable.h @@ -167,7 +167,7 @@ namespace sga private: void* m_texturePtr; // filled at runtime - uint8_t m_pad[56]; + uint8_t m_pad[64]; public: ShaderResourceView() @@ -176,7 +176,7 @@ namespace sga 0x01, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; memcpy(m_pad, f, sizeof(m_pad)); @@ -218,8 +218,7 @@ class grcTexture : #elif defined(RAGE_FORMATS_GAME_RDR3) // sga::Texture uint32_t m_blockSize; - uint16_t m_blockCount; - uint16_t m_blockPad; + uint32_t m_blockCount; union { uint32_t m_flags; @@ -234,7 +233,7 @@ class grcTexture : uint8_t m_tileMode; // 0x0D? uint8_t m_antiAliasType; // 0 uint8_t m_levels; - bool m_unkFlag; // format-related + uint8_t m_unk11; // format-related uint8_t m_unk12; uint8_t m_unk13; // sga::imageParams end @@ -242,6 +241,9 @@ class grcTexture : pgPtr m_name; pgPtr m_srv; pgPtr m_pixelData; + uint32_t m_unk18; + uint32_t m_unk19; + uint64_t m_unk20; #endif public: @@ -282,11 +284,13 @@ class grcTexture : m_tileMode = 0xD; m_antiAliasType = 0; - m_unkFlag = false; + m_unk11 = 0; m_unk12 = 0; m_unk13 = 0; m_usageCount = 1; - m_blockPad = 0; + m_unk18 = 0; + m_unk19 = 0; + m_unk20 = 0; #endif } @@ -1096,8 +1100,8 @@ class grcTextureRef : public datBase memset(m_pad, 0, sizeof(m_pad)); memset(m_pad2, 0, sizeof(m_pad2)); - m_const1 = 1; - m_const2 = 2; + m_const1 = 0; + m_const2 = 0; } inline char* GetName()