fix uninitialized instanceParam pointer in TerrainDrawable (use nulltptr instead, and ignore it in PCDX11Material)

This commit is contained in:
Adam Jensen 2023-04-09 17:40:13 +01:00
parent 4d55c0185f
commit 13922a0f64
5 changed files with 14 additions and 4 deletions

View File

@ -5,6 +5,7 @@
namespace cdc {
class CommonRenderTerrain;
class Vector4;
struct RenderTerrainInstanceData;
class CommonRenderTerrainInstance :
@ -12,9 +13,10 @@ class CommonRenderTerrainInstance :
public RenderExternalResource
{
public:
CommonRenderTerrain *renderTerrain;
RenderTerrainInstanceData *instanceData;
CommonRenderTerrain *renderTerrain; // C
RenderTerrainInstanceData *instanceData; // 10
Vector4 *m_pCurrentInstanceParams = 0; // 18
// Vector4 *m_pInstanceParams = 0; // 1C
public:
CommonRenderTerrainInstance(CommonRenderTerrain *renderTerrain);

View File

@ -58,6 +58,8 @@ void PCDX11Material::method_18() {
// TODO
}
static char s_dummyModifierParams[16 * 8] = {0};
void PCDX11Material::setupVertexResources(
uint32_t subMaterialIndex,
MaterialBlobSub* subMat,
@ -109,6 +111,8 @@ void PCDX11Material::setupVertexResources(
}
if (subMat->vsBufferNumRows) {
if (!cbData)
cbData = s_dummyModifierParams;
PCDX11UberConstantBuffer& cb = stateManager->accessCommonCB(4);
auto firstRow = subMat->vsBufferFirstRow;
auto numRows = subMat->vsBufferNumRows;
@ -171,6 +175,8 @@ void PCDX11Material::setupPixelResources(
}
if (subMat->psBufferNumRows) {
if (!cbData)
cbData = s_dummyModifierParams;
PCDX11UberConstantBuffer& cb = stateManager->accessCommonCB(4);
auto firstRow = subMat->psBufferFirstRow;
auto numRows = subMat->psBufferNumRows;

View File

@ -44,6 +44,7 @@ void PCDX11RenderTerrain::hackDraw(CommonRenderTerrainInstance *instance, Matrix
terrainState->m_toWorld = *matrix;
terrainState->m_pInstanceData = instance->instanceData;
terrainState->nextEntry = nullptr;
terrainState->m_pInstanceParams = instance->m_pCurrentInstanceParams;
// instead of queueing the terrainstate on the renderdevice
// build the drawables right now

View File

@ -30,6 +30,7 @@ PCDX11TerrainDrawable::PCDX11TerrainDrawable(
m_numGeoms = numGeoms;
m_flags = flags;
m_pLocalToWorld = &pState->m_toWorld;
m_pInstanceParams = pState->m_pInstanceParams;
}
void PCDX11TerrainDrawable::draw1(uint32_t funcSetIndex, IRenderDrawable *drawable, IRenderDrawable *prevDrawable) {

View File

@ -19,7 +19,7 @@ struct PCDX11TerrainState {
// PCDX11DeferredLight *m_pLights[128]; // 10
Matrix m_toWorld; // 210
RenderTerrainInstanceData *m_pInstanceData; // 250
// Vector *m_pInstanceParams; // 254
Vector4 *m_pInstanceParams; // 254
// bool m_shadowOnly; // 258
// IRenderTerrainInstance::NodeDrawData **m_ppDrawDatas;
PCDX11TerrainState *nextEntry; // 260