@@ -5422,14 +5422,17 @@ bool WrappedOpenGL::Serialise_glTextureBufferRangeEXT(GLuint texture, GLenum tar
54225422 m_Textures[liveId].internalFormat = fmt;
54235423 }
54245424
5425+ GLuint buf = 0 ;
5426+
5427+ if (GetResourceManager ()->HasLiveResource (bufid))
5428+ buf = GetResourceManager ()->GetLiveResource (bufid).name ;
5429+
54255430 if (Target != eGL_NONE)
54265431 m_Real.glTextureBufferRangeEXT (GetResourceManager ()->GetLiveResource (texid).name , Target, fmt,
5427- GetResourceManager ()->GetLiveResource (bufid).name ,
5428- (GLintptr)offs, (GLsizeiptr)Size);
5432+ buf, (GLintptr)offs, (GLsizeiptr)Size);
54295433 else
5430- m_Real.glTextureBufferRange (GetResourceManager ()->GetLiveResource (texid).name , fmt,
5431- GetResourceManager ()->GetLiveResource (bufid).name , (GLintptr)offs,
5432- (GLsizei)Size);
5434+ m_Real.glTextureBufferRange (GetResourceManager ()->GetLiveResource (texid).name , fmt, buf,
5435+ (GLintptr)offs, (GLsizei)Size);
54335436 }
54345437
54355438 return true ;
@@ -5449,11 +5452,26 @@ void WrappedOpenGL::Common_glTextureBufferRangeEXT(ResourceId texId, GLenum targ
54495452 GLResourceRecord *record = GetResourceManager ()->GetResourceRecord (texId);
54505453 RDCASSERT (record);
54515454
5455+ ResourceId bufid = GetResourceManager ()->GetID (BufferRes (GetCtx (), buffer));
5456+
54525457 if (record->datatype == eGL_TEXTURE_BINDING_BUFFER &&
54535458 m_Textures[texId].internalFormat == internalformat && m_State == WRITING_IDLE )
54545459 {
54555460 GetResourceManager ()->MarkDirtyResource (texId);
5456- GetResourceManager ()->MarkDirtyResource (BufferRes (GetCtx (), buffer));
5461+
5462+ if (bufid != ResourceId ())
5463+ {
5464+ GetResourceManager ()->MarkDirtyResource (bufid);
5465+
5466+ // this will lead to an accumulation of parents if the texture is continually rebound, but
5467+ // this is unavoidable as we don't want to add tons of infrastructure just to track this
5468+ // edge case.
5469+ GLResourceRecord *bufRecord = GetResourceManager ()->GetResourceRecord (bufid);
5470+
5471+ if (bufRecord)
5472+ record->AddParent (bufRecord);
5473+ }
5474+
54575475 return ;
54585476 }
54595477
@@ -5463,18 +5481,24 @@ void WrappedOpenGL::Common_glTextureBufferRangeEXT(ResourceId texId, GLenum targ
54635481
54645482 if (m_State == WRITING_CAPFRAME )
54655483 {
5466- ResourceId bufid = GetResourceManager ()->GetID (BufferRes (GetCtx (), buffer));
5467-
54685484 m_ContextRecord->AddChunk (scope.Get ());
54695485 m_MissingTracks.insert (record->GetResourceID ());
5470- m_MissingTracks.insert (bufid);
54715486 GetResourceManager ()->MarkResourceFrameReferenced (record->GetResourceID (), eFrameRef_Read);
5472- GetResourceManager ()->MarkResourceFrameReferenced (bufid, eFrameRef_Read);
5487+
5488+ if (bufid != ResourceId ())
5489+ {
5490+ m_MissingTracks.insert (bufid);
5491+ GetResourceManager ()->MarkResourceFrameReferenced (bufid, eFrameRef_Read);
5492+ }
54735493 }
54745494 else
54755495 {
54765496 record->AddChunk (scope.Get ());
5477- record->AddParent (GetResourceManager ()->GetResourceRecord (BufferRes (GetCtx (), buffer)));
5497+
5498+ GLResourceRecord *bufRecord = GetResourceManager ()->GetResourceRecord (bufid);
5499+
5500+ if (bufRecord)
5501+ record->AddParent (bufRecord);
54785502 }
54795503 }
54805504
@@ -5588,11 +5612,26 @@ void WrappedOpenGL::Common_glTextureBufferEXT(ResourceId texId, GLenum target,
55885612 GLResourceRecord *record = GetResourceManager ()->GetResourceRecord (texId);
55895613 RDCASSERT (record);
55905614
5615+ ResourceId bufid = GetResourceManager ()->GetID (BufferRes (GetCtx (), buffer));
5616+
55915617 if (record->datatype == eGL_TEXTURE_BINDING_BUFFER &&
55925618 m_Textures[texId].internalFormat == internalformat && m_State == WRITING_IDLE )
55935619 {
55945620 GetResourceManager ()->MarkDirtyResource (texId);
5595- GetResourceManager ()->MarkDirtyResource (BufferRes (GetCtx (), buffer));
5621+
5622+ if (bufid != ResourceId ())
5623+ {
5624+ GetResourceManager ()->MarkDirtyResource (bufid);
5625+
5626+ // this will lead to an accumulation of parents if the texture is continually rebound, but
5627+ // this is unavoidable as we don't want to add tons of infrastructure just to track this
5628+ // edge case.
5629+ GLResourceRecord *bufRecord = GetResourceManager ()->GetResourceRecord (bufid);
5630+
5631+ if (bufRecord)
5632+ record->AddParent (bufRecord);
5633+ }
5634+
55965635 return ;
55975636 }
55985637
@@ -5603,27 +5642,41 @@ void WrappedOpenGL::Common_glTextureBufferEXT(ResourceId texId, GLenum target,
56035642
56045643 if (m_State == WRITING_CAPFRAME )
56055644 {
5606- ResourceId bufid = GetResourceManager ()->GetID (BufferRes (GetCtx (), buffer));
5607-
56085645 m_ContextRecord->AddChunk (chunk);
56095646 m_MissingTracks.insert (record->GetResourceID ());
5610- m_MissingTracks.insert (bufid);
56115647 GetResourceManager ()->MarkResourceFrameReferenced (record->GetResourceID (), eFrameRef_Read);
5612- GetResourceManager ()->MarkResourceFrameReferenced (bufid, eFrameRef_Read);
5648+
5649+ if (bufid != ResourceId ())
5650+ {
5651+ m_MissingTracks.insert (bufid);
5652+ GetResourceManager ()->MarkResourceFrameReferenced (bufid, eFrameRef_Read);
5653+ }
56135654 }
56145655 else
56155656 {
56165657 record->AddChunk (chunk);
5617- record->AddParent (GetResourceManager ()->GetResourceRecord (BufferRes (GetCtx (), buffer)));
5658+
5659+ GLResourceRecord *bufRecord = GetResourceManager ()->GetResourceRecord (bufid);
5660+
5661+ if (bufRecord)
5662+ record->AddParent (bufRecord);
56185663 }
56195664 }
56205665
56215666 {
5622- uint32_t size = 1 ;
5623- m_Real.glGetNamedBufferParameterivEXT (buffer, eGL_BUFFER_SIZE, (GLint *)&size);
5624- m_Textures[texId].width =
5625- uint32_t (size) /
5626- uint32_t (GetByteSize (1 , 1 , 1 , GetBaseFormat (internalformat), GetDataType (internalformat)));
5667+ if (buffer != 0 )
5668+ {
5669+ uint32_t size = 1 ;
5670+ m_Real.glGetNamedBufferParameterivEXT (buffer, eGL_BUFFER_SIZE, (GLint *)&size);
5671+ m_Textures[texId].width =
5672+ uint32_t (size) /
5673+ uint32_t (GetByteSize (1 , 1 , 1 , GetBaseFormat (internalformat), GetDataType (internalformat)));
5674+ }
5675+ else
5676+ {
5677+ m_Textures[texId].width = 1 ;
5678+ }
5679+
56275680 m_Textures[texId].height = 1 ;
56285681 m_Textures[texId].depth = 1 ;
56295682 if (target != eGL_NONE)
0 commit comments