MCPcopy Create free account
hub / github.com/baldurk/renderdoc / GetSize_InitialState

Method GetSize_InitialState

renderdoc/driver/gl/gl_initstate.cpp:979–1098  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

977}
978
979uint64_t GLResourceManager::GetSize_InitialState(ResourceId resid, const GLInitialContents &initial)
980{
981 if(initial.type == eResBuffer)
982 {
983 // buffers just have their contents, no metadata needed
984 return initial.bufferLength + WriteSerialiser::GetChunkAlignment() + 64;
985 }
986 else if(initial.type == eResProgram)
987 {
988 // need to estimate based on how many bindings and uniforms there are. This is a rare path -
989 // only happening when a program is created at runtime in the middle of a frameand we didn't
990 // prepare its initial contents. So we take a less efficient route by just serialising the
991 // current contents and using that as our size estimate, then throwing away the contents.
992 WriteSerialiser ser(new StreamWriter(4 * 1024), Ownership::Stream);
993
994 SCOPED_SERIALISE_CHUNK(SystemChunk::InitialContents);
995
996 GLResource res = GetResource(resid);
997
998 SERIALISE_ELEMENT(resid).TypedAs("GLResource"_lit);
999 SERIALISE_ELEMENT(res.Namespace);
1000
1001 PerStageReflections stages;
1002 m_Driver->FillReflectionArray(GetID(res), stages);
1003
1004 SerialiseProgramBindings(ser, CaptureState::ActiveCapturing, stages, res.name);
1005 SerialiseProgramUniforms(ser, CaptureState::ActiveCapturing, stages, res.name, NULL);
1006
1007 return ser.GetWriter()->GetOffset() + 256;
1008 }
1009 else if(initial.type == eResTexture)
1010 {
1011 uint64_t ret = 0;
1012
1013 ret += sizeof(TextureStateInitialData) + 64;
1014
1015 const TextureStateInitialData &TextureState = initial.tex;
1016
1017 // in these cases, no more data is serialised
1018 if(TextureState.internalformat == eGL_NONE || TextureState.type == eGL_TEXTURE_BUFFER ||
1019 TextureState.isView)
1020 return ret;
1021
1022 bool isCompressed = IsCompressedFormat(TextureState.internalformat);
1023
1024 GLenum fmt = eGL_NONE;
1025 GLenum type = eGL_NONE;
1026
1027 if(!isCompressed)
1028 {
1029 fmt = GetBaseFormat(TextureState.internalformat);
1030 type = GetDataType(TextureState.internalformat);
1031 }
1032
1033 // otherwise loop over all the mips and estimate their size
1034 for(int i = 0; i < TextureState.mips; i++)
1035 {
1036 uint32_t w = RDCMAX(TextureState.width >> i, 1U);

Callers

nothing calls this directly

Calls 11

SerialiseProgramBindingsFunction · 0.85
SerialiseProgramUniformsFunction · 0.85
IsCompressedFormatFunction · 0.85
GetBaseFormatFunction · 0.85
GetDataTypeFunction · 0.85
RDCMAXFunction · 0.85
GetCompressedByteSizeFunction · 0.85
FillReflectionArrayMethod · 0.80
GetWriterMethod · 0.80
GetByteSizeFunction · 0.70
GetOffsetMethod · 0.45

Tested by

no test coverage detected