Skip to content

Commit 832fd76

Browse files
committed
Initialize buffer and texture handles with VRHI_INVALID_HANDLE in vhState struct
1 parent 2fe12cb commit 832fd76

2 files changed

Lines changed: 23 additions & 5 deletions

File tree

test/test_state.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ UTEST_F( State, MultipleSlots )
9595

9696
EXPECT_EQ( r1.viewRect, state1.viewRect );
9797
EXPECT_EQ( r2.viewRect, state2.viewRect );
98+
99+
vhState s;
100+
vhGetState( id1, s.DirtyAll() );
101+
vhGetState( id2, s.DirtyAll() );
98102
}
99103

100104
UTEST_F( State, InvalidId )
@@ -129,6 +133,9 @@ UTEST_F( State, BasicSetGet )
129133
EXPECT_EQ( retrieved.projMatrix, state.projMatrix );
130134
ASSERT_GT( retrieved.worldMatrix.size(), 0 );
131135
EXPECT_EQ( retrieved.worldMatrix[0], state.worldMatrix[0] );
136+
137+
vhState s;
138+
vhSetState( id, s.DirtyAll() );
132139
}
133140

134141
UTEST_F( State, Attachments )
@@ -155,6 +162,9 @@ UTEST_F( State, Attachments )
155162
EXPECT_EQ( retrieved.colourAttachment[0].texture, 101u );
156163
EXPECT_EQ( retrieved.colourAttachment[0].mipLevel, 1u );
157164
EXPECT_EQ( retrieved.depthAttachment.texture, 201u );
165+
166+
vhState s;
167+
vhSetState( id, s.DirtyAll() );
158168
}
159169

160170
UTEST_F( State, Extensions )
@@ -251,6 +261,9 @@ UTEST_F( State, BackendPropagation )
251261
// Verify it doesn't bleed to other states
252262
vhState otherState;
253263
EXPECT_FALSE( vhGetState( 999, otherState ) );
264+
265+
vhState s;
266+
vhSetState( id, s.DirtyAll() );
254267
}
255268

256269
UTEST_F( State, IndividualAccessors )
@@ -353,6 +366,9 @@ UTEST_F( State, DebugFlags )
353366
vhState retrieved = {};
354367
ASSERT_TRUE( vhGetState( id, retrieved ) );
355368
EXPECT_EQ( retrieved.debugFlags, VRHI_STATE_DEBUG_LOG_MISSING_BINDINGS );
369+
370+
vhState s;
371+
vhSetState( id, s.DirtyAll() );
356372
}
357373

358374
UTEST_F( State, Hashing_GraphicsPipeline )
@@ -859,4 +875,7 @@ UTEST_F( State, MissingFieldsCheck )
859875
// Indirect Params
860876
EXPECT_EQ( ret.indirectParams.buffer, dummyBuf );
861877
EXPECT_EQ( ret.indirectParams.byteOffset, 128u );
878+
879+
vhState s;
880+
vhSetState( id, s.DirtyAll() );
862881
}

vrhi.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,6 @@ struct vhState
730730
glm::u8vec4 clearColorUInt = glm::u8vec4( 0 );
731731
float clearDepth = 1.0f;
732732
uint8_t clearStencil = 0;
733-
734733
uint64_t stencilState = 0;
735734

736735
glm::vec4 pushConstants = glm::vec4( 0.0f, 0.0f, 0.0f, 0.0f );
@@ -760,7 +759,7 @@ struct vhState
760759

761760
struct VertexBinding
762761
{
763-
vhBuffer buffer;
762+
vhBuffer buffer = VRHI_INVALID_HANDLE;
764763
uint8_t stream = 0;
765764
uint32_t startVertex = 0;
766765
uint32_t numVertices = UINT32_MAX;
@@ -770,7 +769,7 @@ struct vhState
770769

771770
struct IndexBinding
772771
{
773-
vhBuffer buffer;
772+
vhBuffer buffer = VRHI_INVALID_HANDLE;
774773
uint32_t firstIndex = 0;
775774
uint32_t numIndices = UINT32_MAX;
776775
uint64_t byteOffset = 0;
@@ -781,7 +780,7 @@ struct vhState
781780
{
782781
const char* name = nullptr; // Setting this will autofill slot and computeUAV.
783782
int32_t slot = -1;
784-
vhTexture texture;
783+
vhTexture texture = VRHI_INVALID_HANDLE;
785784
nvrhi::Format formatOverride = nvrhi::Format::UNKNOWN;
786785
nvrhi::TextureSubresourceSet subresources = nvrhi::TextureSubresourceSet( 0, 1, 0, nvrhi::TextureSubresourceSet::AllArraySlices );
787786
nvrhi::TextureDimension dimensionOverride = nvrhi::TextureDimension::Unknown;
@@ -793,7 +792,7 @@ struct vhState
793792
{
794793
const char* name = nullptr; // Setting this will autofill slot and computeUAV.
795794
int32_t slot = -1;
796-
vhBuffer buffer;
795+
vhBuffer buffer = VRHI_INVALID_HANDLE;
797796
uint64_t byteOffset = 0;
798797
uint64_t byteSize = 0;
799798
bool computeUAV = false;

0 commit comments

Comments
 (0)