diff --git a/source/game_sa/Pipelines/CustomBuilding/CustomBuildingDNPipeline.cpp b/source/game_sa/Pipelines/CustomBuilding/CustomBuildingDNPipeline.cpp index 07bac68ba3..e74b54a5e6 100644 --- a/source/game_sa/Pipelines/CustomBuilding/CustomBuildingDNPipeline.cpp +++ b/source/game_sa/Pipelines/CustomBuilding/CustomBuildingDNPipeline.cpp @@ -3,33 +3,48 @@ #include "CustomBuildingDNPipeline.h" #include "CustomCarEnvMapPipeline.h" +uint32& s_Magic1 = StaticRef(); +uint32& s_Magic2 = StaticRef(); + void CCustomBuildingDNPipeline::InjectHooks() { RH_ScopedClass(CCustomBuildingDNPipeline); RH_ScopedCategory("Pipelines"); RH_ScopedInstall(ExtraVertColourPluginAttach, 0x5D72E0); - RH_ScopedInstall(pluginExtraVertColourConstructorCB, 0x5D6D10, { .reversed = false }); - RH_ScopedInstall(pluginExtraVertColourDestructorCB, 0x5D6D30, { .reversed = false }); - RH_ScopedInstall(pluginExtraVertColourStreamReadCB, 0x5D6DE0, { .reversed = false }); - RH_ScopedInstall(pluginExtraVertColourStreamWriteCB, 0x5D6D80, { .reversed = false }); - RH_ScopedInstall(pluginExtraVertColourStreamGetSizeCB, 0x5D6DC0, { .reversed = false }); - RH_ScopedInstall(PreRenderUpdate, 0x5D7200, { .reversed = false }); + RH_ScopedInstall(pluginExtraVertColourConstructorCB, 0x5D6D10); + RH_ScopedInstall(pluginExtraVertColourDestructorCB, 0x5D6D30); + RH_ScopedInstall(pluginExtraVertColourStreamReadCB, 0x5D6DE0); + RH_ScopedInstall(pluginExtraVertColourStreamWriteCB, 0x5D6D80); + RH_ScopedInstall(pluginExtraVertColourStreamGetSizeCB, 0x5D6DC0); + RH_ScopedInstall(PreRenderUpdate, 0x5D7200); RH_ScopedInstall(PreRenderUpdateRpAtomicCB, 0x5D72A0); RH_ScopedInstall(CreatePipe, 0x5D7100); RH_ScopedInstall(DestroyPipe, 0x5D5FA0); RH_ScopedInstall(CreateCustomObjPipe, 0x5D6750); RH_ScopedInstall(CustomPipeAtomicSetup, 0x5D71C0); + RH_ScopedInstall(SetFxEnvTexture, 0x5D9570); } // 0x5D72E0 bool CCustomBuildingDNPipeline::ExtraVertColourPluginAttach() { - ms_extraVertColourPluginOffset = -1; - ms_extraVertColourPluginOffset = RpGeometryRegisterPlugin(12, EXTRA_VERTCOLOUR_PLUGIN_ID, pluginExtraVertColourConstructorCB, pluginExtraVertColourDestructorCB, nullptr); - if (ms_extraVertColourPluginOffset == -1) { + if ((ms_extraVertColourPluginOffset = RpGeometryRegisterPlugin( + sizeof(ExtraVertColour), + rwID_EXTRAVERCOLOURPLUGIN, + pluginExtraVertColourConstructorCB, + pluginExtraVertColourDestructorCB, + nullptr + )) == -1 + ) { return false; } - if (RpGeometryRegisterPluginStream(EXTRA_VERTCOLOUR_PLUGIN_ID, pluginExtraVertColourStreamReadCB, pluginExtraVertColourStreamWriteCB, pluginExtraVertColourStreamGetSizeCB) < 0) { + if (RpGeometryRegisterPluginStream( + rwID_EXTRAVERCOLOURPLUGIN, + pluginExtraVertColourStreamReadCB, + pluginExtraVertColourStreamWriteCB, + pluginExtraVertColourStreamGetSizeCB + ) == -1 + ) { ms_extraVertColourPluginOffset = -1; return false; } @@ -38,38 +53,109 @@ bool CCustomBuildingDNPipeline::ExtraVertColourPluginAttach() { } // 0x5D6D10 -void* CCustomBuildingDNPipeline::pluginExtraVertColourConstructorCB(void* object, int32 offsetInObject, int32 sizeInObject) { - return plugin::CallAndReturn(object, offsetInObject, sizeInObject); +void* CCustomBuildingDNPipeline::pluginExtraVertColourConstructorCB(void* object, RwInt32 offsetInObject, RwInt32 sizeInObject) { + const auto self = GetExtraVertColourPtr(object); + + self->NightColors = nullptr; + self->DayColors = nullptr; + self->Intensity = 0.f; + + return object; } // 0x5D6D30 -void* CCustomBuildingDNPipeline::pluginExtraVertColourDestructorCB(void* object, int32 offsetInObject, int32 sizeInObject) { - return plugin::CallAndReturn(object, offsetInObject, sizeInObject); +void* CCustomBuildingDNPipeline::pluginExtraVertColourDestructorCB(void* object, RwInt32 offsetInObject, RwInt32 sizeInObject) { + const auto self = GetExtraVertColourPtr(object); + + for (const auto ptr : { &self->NightColors, &self->DayColors }) { + CMemoryMgr::Free(std::exchange(*ptr, nullptr)); + } + + return object; } // 0x5D6DE0 -RwStream* CCustomBuildingDNPipeline::pluginExtraVertColourStreamReadCB(RwStream* stream, int32 binaryLength, void* object, int32 offsetInObject, int32 sizeInObject) { - return plugin::CallAndReturn(stream, binaryLength, object, offsetInObject, sizeInObject); +RwStream* CCustomBuildingDNPipeline::pluginExtraVertColourStreamReadCB( + RwStream* stream, + RwInt32 binaryLength, + void* object, + RwInt32 offsetInObject, + RwInt32 sizeInObject +) { + const auto self = GetExtraVertColourPtr(object); + const auto geo = static_cast(object); + + uint32 magicNumber; + VERIFY(RwStreamRead(stream, &magicNumber, sizeof(magicNumber)) != 0); + + if (magicNumber) { + const auto numVerts = (size_t)RpGeometryGetNumVertices(geo); + + for (const auto ptr : { &self->NightColors, &self->DayColors }) { + *ptr = static_cast(CMemoryMgr::Malloc(sizeof(RwRGBA) * numVerts)); + } + self->Intensity = 1.f; + + VERIFY(RwStreamRead(stream, self->NightColors, sizeof(RwRGBA) * numVerts) != 0); + + if (const auto preLitColors = RpGeometryGetPreLightColors(geo)) { + rng::copy(std::span{ preLitColors, numVerts }, self->DayColors); + } + } + + return stream; } // 0x5D6D80 -RwStream* CCustomBuildingDNPipeline::pluginExtraVertColourStreamWriteCB(RwStream* stream, int32 binaryLength, const void* object, int32 offsetInObject, int32 sizeInObject) { - return plugin::CallAndReturn(stream, binaryLength, object, offsetInObject, sizeInObject); +RwStream* CCustomBuildingDNPipeline::pluginExtraVertColourStreamWriteCB(RwStream* stream, RwInt32 binaryLength, const void* object, RwInt32 offsetInObject, RwInt32 sizeInObject) { + const auto self = GetExtraVertColourPtr(object); + const auto geo = static_cast(object); + + RwStreamWrite(stream, &self->NightColors, sizeof(self->NightColors)); + if (self->NightColors) { + RwStreamWrite(stream, self->NightColors, sizeof(RwRGBA) * RpGeometryGetNumVertices(geo)); + } + return stream; } // 0x5D6DC0 -int32 CCustomBuildingDNPipeline::pluginExtraVertColourStreamGetSizeCB(const void* object, int32 offsetInObject, int32 sizeInObject) { - return plugin::CallAndReturn(object, offsetInObject, sizeInObject); +RwInt32 CCustomBuildingDNPipeline::pluginExtraVertColourStreamGetSizeCB(const void* object, RwInt32 offsetInObject, RwInt32 sizeInObject) { + const auto geo = static_cast(object); + + return 2 * sizeof(RwRGBA) * RpGeometryGetNumVertices(geo) /*Day and Night colors*/ + sizeof(ExtraVertColour::Intensity); +} + +// 0x5D5FC0 +bool AtomicHasNVCPipeline(RpAtomic* atomic) { + return atomic->pipeline == CCustomBuildingDNPipeline::ObjPipeline; +} + +// 0x5D6850 [AKA `NVC__Process`] +void NVCPipelineProcess(RpAtomic* a, float DNBalance) { + plugin::Call<0x5D6850>(a, DNBalance); } // 0x5D7200 -void CCustomBuildingDNPipeline::PreRenderUpdate(RpAtomic* atomic, bool ignoreDNBalanceParam) { - plugin::Call<0x5D7200, RpAtomic*, bool>(atomic, ignoreDNBalanceParam); +void CCustomBuildingDNPipeline::PreRenderUpdate(RpAtomic* a, bool ignoreDNBalanceParam) { + if (!a) { + return; + } + if (!AtomicHasNVCPipeline(a)) { + return; + } + const auto intensity = std::abs(GetExtraVertColourPtr(RpAtomicGetGeometry(a))->Intensity - m_fDNBalanceParam); + if (intensity <= 0.01f && !ignoreDNBalanceParam) { + return; + } + if (((uint32)a / 0x70) % 16 != s_Magic1 && !s_Magic2 && !ignoreDNBalanceParam && intensity <= 0.3f) { + return; + } + NVCPipelineProcess(a, m_fDNBalanceParam); } // 0x5D72A0 RpAtomic* CCustomBuildingDNPipeline::PreRenderUpdateRpAtomicCB(RpAtomic* atomic, void* data) { - PreRenderUpdate(atomic, reinterpret_cast(data)); + PreRenderUpdate(atomic, *reinterpret_cast(data)); return atomic; } @@ -82,18 +168,19 @@ bool CCustomBuildingDNPipeline::CreatePipe() { // 0x5D6750 RxPipeline* CCustomBuildingDNPipeline::CreateCustomObjPipe() { auto pipeline = RxPipelineCreate(); - auto nodeDefinition = RxNodeDefinitionGetD3D9AtomicAllInOne(); - if (!pipeline) + auto nodeDef = RxNodeDefinitionGetD3D9AtomicAllInOne(); + if (!pipeline) { return nullptr; + } auto lockedPipe = RxPipelineLock(pipeline); - if (!lockedPipe || !RxLockedPipeAddFragment(lockedPipe, 0, nodeDefinition, 0) || !RxLockedPipeUnlock(lockedPipe)) { - _rxPipelineDestroy(pipeline); + if (!lockedPipe || !RxLockedPipeAddFragment(lockedPipe, 0, nodeDef, 0) || !RxLockedPipeUnlock(lockedPipe)) { + RxPipelineDestroy(pipeline); return nullptr; } - auto node = RxPipelineFindNodeByName(pipeline, nodeDefinition->name, nullptr, nullptr); - if (*reinterpret_cast(0xC02C20)) { // read only + auto node = RxPipelineFindNodeByName(pipeline, nodeDef->name, nullptr, nullptr); + if (*reinterpret_cast(0xC02C20)) { // read only (0 by default) RxD3D9AllInOneSetInstanceCallBack(node, RxD3D9AllInOneGetInstanceCallBack(node)); RxD3D9AllInOneSetReinstanceCallBack(node, CustomPipeInstanceCB); } else { @@ -101,16 +188,17 @@ RxPipeline* CCustomBuildingDNPipeline::CreateCustomObjPipe() { RxD3D9AllInOneSetReinstanceCallBack(node, RxD3D9AllInOneGetReinstanceCallBack(node)); } RxD3D9AllInOneSetRenderCallBack(node, CustomPipeRenderCB); - pipeline->pluginId = CUSTOM_BUILDING_DN_PIPELINE_ID; + + pipeline->pluginId = CUSTOM_BUILDING_DN_PIPELINE_ID; pipeline->pluginData = CUSTOM_BUILDING_DN_PIPELINE_ID; + return pipeline; } // 0x5D5FA0 void CCustomBuildingDNPipeline::DestroyPipe() { if (ObjPipeline) { - _rxPipelineDestroy(ObjPipeline); - ObjPipeline = nullptr; + RxPipelineDestroy(std::exchange(ObjPipeline, nullptr)); } } @@ -135,10 +223,10 @@ RpAtomic* CCustomBuildingDNPipeline::CustomPipeAtomicSetup(RpAtomic* atomic) { // android, unused uint32 CCustomBuildingDNPipeline::UsesThisPipeline(RpAtomic* atomic) { return atomic->pipeline - - ObjPipeline - + (atomic->pipeline == ObjPipeline) // AtomicHasNVCPipeline 0x5D5FC0 - + ObjPipeline - - atomic->pipeline; + - ObjPipeline + + (atomic->pipeline == ObjPipeline) // AtomicHasNVCPipeline 0x5D5FC0 + + ObjPipeline + - atomic->pipeline; } // 0x5D7120 @@ -152,12 +240,18 @@ void CCustomBuildingDNPipeline::CustomPipeRenderCB(RwResEntry* entry, void* obje } // 0x5D6E90 -void* CCustomBuildingDNPipeline::GetExtraVertColourPtr(RpGeometry* geometry) { - return *RWPLUGINOFFSET(void*, geometry, ms_extraVertColourPluginOffset); // todo: return type +ExtraVertColour* CCustomBuildingDNPipeline::GetExtraVertColourPtr(const void* geometry) { + return RWPLUGINOFFSET(ExtraVertColour, geometry, ms_extraVertColourPluginOffset); } -void CCustomBuildingDNPipeline::SetFxEnvTexture(RpMaterial* material, RwTexture* texture) { - plugin::Call<0x5D9570, RpMaterial*, RwTexture*>(material, texture); +// 0x5D9570 +CustomEnvMapPipeMaterialData* CCustomBuildingDNPipeline::SetFxEnvTexture(CustomEnvMapPipeMaterialData** inOutEnvMapData) { + if (*inOutEnvMapData == &CCustomCarEnvMapPipeline::fakeEnvMapPipeMatData) { + if (*inOutEnvMapData = CCustomCarEnvMapPipeline::m_gEnvMapPipeMatDataPool->New()) { + **inOutEnvMapData = CCustomCarEnvMapPipeline::fakeEnvMapPipeMatData; + } + } + return *inOutEnvMapData; } RwTexture* CCustomBuildingDNPipeline::GetFxEnvTexture(RpMaterial* material) { diff --git a/source/game_sa/Pipelines/CustomBuilding/CustomBuildingDNPipeline.h b/source/game_sa/Pipelines/CustomBuilding/CustomBuildingDNPipeline.h index 3ba5b31b59..db66582e0f 100644 --- a/source/game_sa/Pipelines/CustomBuilding/CustomBuildingDNPipeline.h +++ b/source/game_sa/Pipelines/CustomBuilding/CustomBuildingDNPipeline.h @@ -4,9 +4,20 @@ struct RxOpenGLMeshInstanceData; -constexpr auto EXTRA_VERTCOLOUR_PLUGIN_ID = 0x253F2F9; +/*! +* @brief ExtraVertColour plugin unique RW plugin ID +*/ +#define rwID_EXTRAVERCOLOURPLUGIN MAKECHUNKID(rwVENDORID_DEVELOPER, 0xF9) + constexpr auto CUSTOM_BUILDING_DN_PIPELINE_ID = 0x0; +//! Extra Vertex Colour plugin data [Inside RpGeometry] +struct ExtraVertColour { // AKA `gtaVertexColorPlugin` + RwRGBA *NightColors, *DayColors; // heap allocated + float Intensity; +}; +VALIDATE_SIZE(ExtraVertColour, 12); // 24 on Android + class CCustomBuildingDNPipeline { public: static inline float& m_fDNBalanceParam = *(float*)0x8D12C0; // 1.0f @@ -30,19 +41,19 @@ class CCustomBuildingDNPipeline { static void PreRenderUpdate(RpAtomic* atomic, bool ignoreDNBalanceParam); static RpAtomic* PreRenderUpdateRpAtomicCB(RpAtomic* atomic, void* data); - static void* pluginExtraVertColourConstructorCB(void* object, int32 offsetInObject, int32 sizeInObject); - static void* pluginExtraVertColourDestructorCB(void* object, int32 offsetInObject, int32 sizeInObject); - static RwStream* pluginExtraVertColourStreamReadCB(RwStream* stream, int32 binaryLength, void* object, int32 offsetInObject, int32 sizeInObject); - static RwStream* pluginExtraVertColourStreamWriteCB(RwStream* stream, int32 binaryLength, const void* object, int32 offsetInObject, int32 sizeInObject); - static int32 pluginExtraVertColourStreamGetSizeCB(const void* object, int32 offsetInObject, int32 sizeInObject); + static void* pluginExtraVertColourConstructorCB(void* object, RwInt32 offsetInObject, RwInt32 sizeInObject); + static void* pluginExtraVertColourDestructorCB(void* object, RwInt32 offsetInObject, RwInt32 sizeInObject); + static RwStream* pluginExtraVertColourStreamReadCB(RwStream* stream, RwInt32 binaryLength, void* object, RwInt32 offsetInObject, RwInt32 sizeInObject); + static RwStream* pluginExtraVertColourStreamWriteCB(RwStream* stream, RwInt32 binaryLength, const void* object, RwInt32 offsetInObject, RwInt32 sizeInObject); + static RwInt32 pluginExtraVertColourStreamGetSizeCB(const void* object, RwInt32 offsetInObject, RwInt32 sizeInObject); static RpMaterial* CustomPipeMaterialSetup(RpMaterial* material, void* a2); static void CustomPipeRenderCB(RwResEntry* entry, void* object, uint8 type, uint32 flags); - static void* GetExtraVertColourPtr(RpGeometry* geometry); + static ExtraVertColour* GetExtraVertColourPtr(const void* geometry); static RwTexture* GetFxEnvTexture(RpMaterial* material); - static void SetFxEnvTexture(RpMaterial* material, RwTexture* texture); + static CustomEnvMapPipeMaterialData* SetFxEnvTexture(CustomEnvMapPipeMaterialData** envMapData); static float GetFxEnvScaleX(RpMaterial* material); static float GetFxEnvScaleY(RpMaterial* material); diff --git a/source/game_sa/RenderWare/rw/rwcore.h b/source/game_sa/RenderWare/rw/rwcore.h index 8560d2fd88..260a8a2095 100644 --- a/source/game_sa/RenderWare/rw/rwcore.h +++ b/source/game_sa/RenderWare/rw/rwcore.h @@ -668,6 +668,263 @@ struct RxPipeline typedef RxPipelineNode * (*RxPipelineNodeOutputCallBack) (RxPipelineNode * node, RxPipelineNode * outputnode, void *callbackdata); + + +#ifdef RWDEBUG +#define RXCHECKFORUSERTRAMPLING(_pipeline) \ + ( _rwPipelineCheckForTramplingOfNodePrivateSpace(_pipeline) ) +#endif /* RWDEBUG */ + +#if (!defined(RXCHECKFORUSERTRAMPLING)) +#define RXCHECKFORUSERTRAMPLING(_pipeline) /* No op */ +#endif /* (!defined(RXCHECKFORUSERTRAMPLING)) */ + + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +extern void +RxPipelineSetFreeListCreateParams( RwInt32 blockSize, RwInt32 numBlocksToPrealloc ); + +extern RwBool +_rxPipelineOpen(void); + +extern RwBool +_rxPipelineClose(void); + +extern RwBool +rxPipelinePluginsAttach(void); + +extern RxPipeline * +RxPipelineCreate(void); + + +extern void +_rxPipelineDestroy(RxPipeline * Pipeline); + +#define _RxPipelineDestroy(_ppln) _rxPipelineDestroy(_ppln) +#define RxPipelineDestroy(_ppln) (_rxPipelineDestroy(_ppln), TRUE) + +extern RxHeap * +RxHeapGetGlobalHeap(void); + +extern RxPipeline * +RxPipelineExecute(RxPipeline * pipeline, + void * data, + RwBool heapReset); + +extern RxPacket * +RxPacketCreate(RxPipelineNode * node); + +extern RxCluster * +RxClusterSetStride(RxCluster * cluster, + RwInt32 stride); + +extern RxCluster * +RxClusterSetExternalData(RxCluster * cluster, + void *data, + RwInt32 stride, + RwInt32 numElements); + +extern RxCluster * +RxClusterSetData(RxCluster * cluster, + void *data, + RwInt32 stride, + RwInt32 numElements); + +/* underlying PacketDestroy function */ +extern void +_rxPacketDestroy(RxPacket * Packet); + +/* more convenient parameterization */ +#define RxPacketDestroy(pk, self) \ + ( _rxPacketDestroy(pk) ) + +#if (defined(RWDEBUG)) +extern RxPacket *RxPacketFetch(RxPipelineNode * Node); +extern void RxPacketDispatch(RxPacket * packet, + RwUInt32 output, + RxPipelineNode * self); +extern void RxPacketDispatchToPipeline(RxPacket * packet, + RxPipeline * dest, + RxPipelineNode * self); +#else /* (defined(RWDEBUG)) */ +#define RxPacketFetch(_self) \ + rxPacketFetchMacro(_self) +#define RxPacketDispatch( _packet, _output, _self) \ + rxPacketDispatchMacro(_packet, _output, _self) +#define RxPacketDispatchToPipeline( _packet, _pipeline, _self) \ + rxPacketDispatchToPipelineMacro(_packet, _pipeline, _self) +#endif /* (defined(RWDEBUG)) */ + +#define RxClusterInitialiseData(_clstr, _nmlmnts, _strd) \ + ( RxClusterInitializeData((_clstr), (_nmlmnts), (_strd)) ) +extern RxCluster * +RxClusterInitializeData(RxCluster *cluster, RwUInt32 numElements, RwUInt16 stride); + +extern RxCluster * +RxClusterResizeData(RxCluster *CurrentCluster, RwUInt32 NumElements); + +extern RxCluster * +RxClusterDestroyData(RxCluster *CurrentCluster); + +#if (defined(RWDEBUG)) + +extern RxCluster *RxClusterLockRead(RxPacket * packet, RwUInt32 clusterIndex); + +#else /* !RWDEBUG */ + +#define RXCLSLOT(PKT, CLIND) \ + ((PKT)->inputToClusterSlot[(CLIND)]) + +#define RxClusterLockRead(PKT, CLIND) \ + ( (((RwInt32)RXCLSLOT(PKT, CLIND)) == -1) ? \ + ((RxCluster *)NULL) : \ + (RxClusterResetCursor(&PKT->clusters[RXCLSLOT(PKT, CLIND)]), \ + &PKT->clusters[RXCLSLOT(PKT, CLIND)]) ) + +#endif /* !RWDEBUG */ + +extern RxCluster * +RxClusterLockWrite(RxPacket * packet, + RwUInt32 clusterIndex, + RxPipelineNode * node); + +extern void +RxClusterUnlock(RxCluster * cluster); + +extern RwUInt32 +RxPipelineNodeSendConfigMsg(RxPipelineNode * dest, + RwUInt32 msg, + RwUInt32 intparam, + void *ptrparam); + +extern RxPipelineNode * +RxPipelineNodeForAllConnectedOutputs(RxPipelineNode * node, + RxPipeline * pipeline, + RxPipelineNodeOutputCallBack callbackfn, + void *callbackdata); + +/* Cluster attributes api [pipeline construction time] */ + +extern RxPipelineCluster * +RxPipelineNodeGetPipelineCluster(RxPipelineNode *node, + RwUInt32 clustersOfInterestIndex); + +extern RwUInt32 +RxPipelineClusterGetCreationAttributes(RxPipelineCluster *cluster); + +extern RxPipelineCluster * +RxPipelineClusterSetCreationAttributes(RxPipelineCluster *cluster, + RwUInt32 creationAttributes); + +/* Cluster attributes api [pipeline execution time] */ + +extern RwUInt32 +RxClusterGetAttributes(RxCluster *cluster); + +extern RxCluster * +RxClusterSetAttributes(RxCluster *cluster, RwUInt32 attributes); + + +extern void +_rxEmbeddedPacketBetweenPipelines(RxPipeline * fromPipeline, + RxPipeline * toPipeline); + +extern RxPipelineNode * +_rxEmbeddedPacketBetweenNodes(RxPipeline *pipeline, + RxPipelineNode *nodeFrom, + RwUInt32 whichOutput); + +extern RxExecutionContext _rxExecCtxGlobal; + +/* Summary of dispatch rules: + * o nodes that never fetch are safe to dispatch NULL, whether + * nodes above pass them a packet or not + * o if you destroy the packet you can dispatch(NULL,,) + * o if you fetch/create and dispatch(NULL), it doesn't really + * matter - the packet'll get passed on anyway */ + +/* TODO: there's currently no way to prematurely terminate the pipeline + * without doing so as an error condition. You should create an + * enum for the exit code, either RXNODEEXITCONTINUE, RXNODEEXITTERMINATE + * or RXNODEEXTTERMINATEERROR and then test for RXNODEEXITCONTINUE in + * the below macros rather than FALSE. */ + +/* TODO: _packet redundant here... create a new macro and legacy wrapper */ +#define rxPacketDispatchMacro(_packet, _output, _self) \ +MACRO_START \ +{ \ + RxPipeline *curPipeline = _rxExecCtxGlobal.pipeline; \ + \ + /* _packet is now an obsolete parameter */ \ + \ + if ( FALSE != _rxExecCtxGlobal.exitCode ) \ + { \ + RxPipelineNode *nextNode = \ + _rxEmbeddedPacketBetweenNodes(curPipeline, \ + _self, \ + (_output)); \ + if ( nextNode != NULL ) \ + { \ + RwUInt32 exitCode = \ + nextNode->nodeDef->nodeMethods.nodeBody( \ + nextNode, &(_rxExecCtxGlobal.params)); \ + /* Don't overwrite 'error' with 'success' */ \ + if (FALSE == exitCode) _rxExecCtxGlobal.exitCode = exitCode; \ + } \ + } \ + if ( curPipeline->embeddedPacketState > rxPKST_UNUSED \ + /* !UNUSED and !PACKETLESS */ ) \ + { \ + curPipeline->embeddedPacketState = rxPKST_INUSE; \ + _rxPacketDestroy(curPipeline->embeddedPacket); \ + } \ +} \ +MACRO_STOP + +/* TODO: _self redundant here... create a new macro and legacy wrapper */ +#define rxPacketDispatchToPipelineMacro(_packet, _pipeline, _self) \ +MACRO_START \ +{ \ + RxPipeline *toPipeline = (_pipeline); \ + \ + /* _packet is now an obsolete parameter */ \ + \ + if ( FALSE != _rxExecCtxGlobal.exitCode ) \ + { \ + RwUInt32 exitCode; \ + RxPipeline *fromPipeline = _rxExecCtxGlobal.pipeline; /* save */ \ + _rxEmbeddedPacketBetweenPipelines(fromPipeline, \ + toPipeline); \ + _rxExecCtxGlobal.pipeline = toPipeline; /* modify */ \ + exitCode = \ + toPipeline->nodes[0].nodeDef->nodeMethods.nodeBody( \ + &toPipeline->nodes[0], &(_rxExecCtxGlobal.params)); \ + if ( FALSE == exitCode ) _rxExecCtxGlobal.exitCode = exitCode; \ + _rxExecCtxGlobal.pipeline = fromPipeline; /* restore */ \ + } \ + if ( toPipeline->embeddedPacketState > rxPKST_UNUSED \ + /* !UNUSED and !PACKETLESS */ ) \ + { \ + toPipeline->embeddedPacketState = rxPKST_INUSE; \ + _rxPacketDestroy(toPipeline->embeddedPacket); \ + } \ +} \ +MACRO_STOP + +#define rxPacketFetchMacro(_node) \ + ( ((_rxExecCtxGlobal.pipeline)->embeddedPacketState == rxPKST_PENDING) ?\ + ((_rxExecCtxGlobal.pipeline)->embeddedPacketState = rxPKST_INUSE, \ + (_rxExecCtxGlobal.pipeline)->embeddedPacket) : \ + (NULL) ) + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + /*--- Automatically derived from: C:/daily/rwsdk/src/pipe/p2/d3d9/nodeD3D9SubmitNoLight.h ---*/