void WrappedOpenGL::glLinkProgram(GLuint program) { m_Real.glLinkProgram(program); if(m_State >= WRITING) { GLResourceRecord *record = GetResourceManager()->GetResourceRecord(ProgramRes(GetCtx(), program)); RDCASSERT(record); { SCOPED_SERIALISE_CONTEXT(LINKPROGRAM); Serialise_glLinkProgram(program); record->AddChunk(scope.Get()); } } }
void WrappedOpenGL::glShaderStorageBlockBinding(GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding) { m_Real.glShaderStorageBlockBinding(program, storageBlockIndex, storageBlockBinding); if(m_State >= WRITING) { GLResourceRecord *record = GetResourceManager()->GetResourceRecord(ProgramRes(GetCtx(), program)); RDCASSERT(record); { SCOPED_SERIALISE_CONTEXT(STORAGE_BLOCKBIND); Serialise_glShaderStorageBlockBinding(program, storageBlockIndex, storageBlockBinding); record->AddChunk(scope.Get()); } } }
void WrappedOpenGL::glNamedStringARB(GLenum type, GLint namelen, const GLchar *name, GLint stringlen, const GLchar *str) { m_Real.glNamedStringARB(type, namelen, name, stringlen, str); if(m_State >= WRITING) { SCOPED_SERIALISE_CONTEXT(NAMEDSTRING); Serialise_glNamedStringARB(type, namelen, name, stringlen, str); // if a program repeatedly created/destroyed named strings this will fill up with useless // strings, // but chances are that won't be the case - a few will be created at init time and that's it m_DeviceRecord->AddChunk(scope.Get()); } }
void WrappedOpenGL::glTexStorage1D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width) { m_Real.glTexStorage1D(target, levels, internalformat, width); if(m_State >= WRITING) { GLResourceRecord *record = m_TextureRecord[m_TextureUnit]; RDCASSERT(record); SCOPED_SERIALISE_CONTEXT(TEXSTORAGE1D); Serialise_glTextureStorage1DEXT(GetResourceManager()->GetCurrentResource(record->GetResourceID()).name, target, levels, internalformat, width); record->AddChunk(scope.Get()); } }
void WrappedOpenGL::glShaderSource(GLuint shader, GLsizei count, const GLchar* const *string, const GLint *length) { m_Real.glShaderSource(shader, count, string, length); if(m_State >= WRITING) { GLResourceRecord *record = GetResourceManager()->GetResourceRecord(ShaderRes(GetCtx(), shader)); RDCASSERT(record); { SCOPED_SERIALISE_CONTEXT(SHADERSOURCE); Serialise_glShaderSource(shader, count, string, length); record->AddChunk(scope.Get()); } } }
void WrappedOpenGL::glCompileShader(GLuint shader) { m_Real.glCompileShader(shader); if(m_State >= WRITING) { GLResourceRecord *record = GetResourceManager()->GetResourceRecord(ShaderRes(GetCtx(), shader)); RDCASSERT(record); { SCOPED_SERIALISE_CONTEXT(COMPILESHADER); Serialise_glCompileShader(shader); record->AddChunk(scope.Get()); } } }
void WrappedOpenGL::glBindFragDataLocation(GLuint program, GLuint color, const GLchar *name) { m_Real.glBindFragDataLocation(program, color, name); if(m_State >= WRITING) { GLResourceRecord *record = GetResourceManager()->GetResourceRecord(ProgramRes(GetCtx(), program)); RDCASSERT(record); { SCOPED_SERIALISE_CONTEXT(BINDFRAGDATA_LOCATION); Serialise_glBindFragDataLocation(program, color, name); record->AddChunk(scope.Get()); } } }
void WrappedOpenGL::glCompileShaderIncludeARB(GLuint shader, GLsizei count, const GLchar *const*path, const GLint *length) { m_Real.glCompileShaderIncludeARB(shader, count, path, length); if(m_State >= WRITING) { GLResourceRecord *record = GetResourceManager()->GetResourceRecord(ShaderRes(GetCtx(), shader)); RDCASSERT(record); { SCOPED_SERIALISE_CONTEXT(COMPILESHADERINCLUDE); Serialise_glCompileShaderIncludeARB(shader, count, path, length); record->AddChunk(scope.Get()); } } }
void WrappedOpenGL::glProgramParameteri(GLuint program, GLenum pname, GLint value) { m_Real.glProgramParameteri(program, pname, value); if(m_State >= WRITING) { GLResourceRecord *record = GetResourceManager()->GetResourceRecord(ProgramRes(GetCtx(), program)); RDCASSERT(record); { SCOPED_SERIALISE_CONTEXT(PROGRAMPARAMETER); Serialise_glProgramParameteri(program, pname, value); record->AddChunk(scope.Get()); } } }
void WrappedOpenGL::glTexBufferRange(GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size) { m_Real.glTexBufferRange(target, internalformat, buffer, offset, size); if(m_State >= WRITING) { GLResourceRecord *record = m_TextureRecord[m_TextureUnit]; RDCASSERT(record); SCOPED_SERIALISE_CONTEXT(TEXBUFFER_RANGE); Serialise_glTextureBufferRangeEXT(GetResourceManager()->GetCurrentResource(record->GetResourceID()).name, target, internalformat, buffer, offset, size); record->AddChunk(scope.Get()); } }
void WrappedOpenGL::glBindSamplers(GLuint first, GLsizei count, const GLuint *samplers) { m_Real.glBindSamplers(first, count, samplers); if(m_State == WRITING_CAPFRAME) { SCOPED_SERIALISE_CONTEXT(BIND_SAMPLERS); Serialise_glBindSamplers(first, count, samplers); m_ContextRecord->AddChunk(scope.Get()); for(GLsizei i = 0; i < count; i++) if(samplers != NULL && samplers[i] != 0) GetResourceManager()->MarkResourceFrameReferenced(SamplerRes(GetCtx(), samplers[i]), eFrameRef_Read); } }
void WrappedOpenGL::glTransformFeedbackVaryings(GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode) { m_Real.glTransformFeedbackVaryings(program, count, varyings, bufferMode); if(m_State >= WRITING) { GLResourceRecord *record = GetResourceManager()->GetResourceRecord(ProgramRes(GetCtx(), program)); RDCASSERT(record); { SCOPED_SERIALISE_CONTEXT(FEEDBACK_VARYINGS); Serialise_glTransformFeedbackVaryings(program, count, varyings, bufferMode); record->AddChunk(scope.Get()); } } }
void WrappedOpenGL::glBindProgramPipeline(GLuint pipeline) { m_Real.glBindProgramPipeline(pipeline); GetCtxData().m_ProgramPipeline = pipeline; if(m_State == WRITING_CAPFRAME) { SCOPED_SERIALISE_CONTEXT(BIND_PROGRAMPIPE); Serialise_glBindProgramPipeline(pipeline); m_ContextRecord->AddChunk(scope.Get()); GetResourceManager()->MarkResourceFrameReferenced(ProgramPipeRes(GetCtx(), pipeline), eFrameRef_Read); } }
VkResult WrappedVulkan::vkCreateBufferView( VkDevice device, const VkBufferViewCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkBufferView* pView) { VkBufferViewCreateInfo unwrappedInfo = *pCreateInfo; unwrappedInfo.buffer = Unwrap(unwrappedInfo.buffer); VkResult ret = ObjDisp(device)->CreateBufferView(Unwrap(device), &unwrappedInfo, pAllocator, pView); if(ret == VK_SUCCESS) { ResourceId id = GetResourceManager()->WrapResource(Unwrap(device), *pView); if(m_State >= WRITING) { Chunk *chunk = NULL; { CACHE_THREAD_SERIALISER(); SCOPED_SERIALISE_CONTEXT(CREATE_BUFFER_VIEW); Serialise_vkCreateBufferView(localSerialiser, device, pCreateInfo, NULL, pView); chunk = scope.Get(); } VkResourceRecord *bufferRecord = GetRecord(pCreateInfo->buffer); VkResourceRecord *record = GetResourceManager()->AddResourceRecord(*pView); record->AddChunk(chunk); record->AddParent(bufferRecord); // store the base resource record->baseResource = bufferRecord->baseResource; record->sparseInfo = bufferRecord->sparseInfo; } else { GetResourceManager()->AddLiveResource(id, *pView); m_CreationInfo.m_BufferView[id].Init(GetResourceManager(), m_CreationInfo, &unwrappedInfo); } } return ret; }
void WrappedOpenGL::glPixelStorei(GLenum pname, GLint param) { m_Real.glPixelStorei(pname, param); if(m_State >= WRITING) { SCOPED_SERIALISE_CONTEXT(PIXELSTORE); Serialise_glPixelStorei(pname, param); if(m_TextureRecord[m_TextureUnit]) m_TextureRecord[m_TextureUnit]->AddChunk(scope.Get()); else if(m_State == WRITING_IDLE) m_DeviceRecord->AddChunk(scope.Get()); else if(m_State == WRITING_CAPFRAME) m_ContextRecord->AddChunk(scope.Get()); } }
HRESULT WrappedID3D12Device::CreateCommandQueue(const D3D12_COMMAND_QUEUE_DESC *pDesc, REFIID riid, void **ppCommandQueue) { if(ppCommandQueue == NULL) return m_pDevice->CreateCommandQueue(pDesc, riid, NULL); if(riid != __uuidof(ID3D12CommandQueue)) return E_NOINTERFACE; ID3D12CommandQueue *real = NULL; HRESULT ret = m_pDevice->CreateCommandQueue(pDesc, riid, (void **)&real); if(SUCCEEDED(ret)) { SCOPED_LOCK(m_D3DLock); WrappedID3D12CommandQueue *wrapped = new WrappedID3D12CommandQueue(real, this, m_pSerialiser, m_State); if(m_State >= WRITING) { SCOPED_SERIALISE_CONTEXT(CREATE_COMMAND_QUEUE); Serialise_CreateCommandQueue(pDesc, riid, (void **)&wrapped); m_DeviceRecord->AddChunk(scope.Get()); } else { GetResourceManager()->AddLiveResource(wrapped->GetResourceID(), wrapped); } if(pDesc->Type == D3D12_COMMAND_LIST_TYPE_DIRECT) { if(m_Queue != NULL) RDCERR("Don't support multiple queues yet!"); m_Queue = wrapped; CreateInternalResources(); } *ppCommandQueue = (ID3D12CommandQueue *)wrapped; } return ret; }
VkResult WrappedVulkan::vkQueueWaitIdle(VkQueue queue) { VkResult ret = ObjDisp(queue)->QueueWaitIdle(Unwrap(queue)); if(m_State >= WRITING_CAPFRAME) { CACHE_THREAD_SERIALISER(); SCOPED_SERIALISE_CONTEXT(QUEUE_WAIT_IDLE); Serialise_vkQueueWaitIdle(localSerialiser, queue); m_FrameCaptureRecord->AddChunk(scope.Get()); GetResourceManager()->MarkResourceFrameReferenced(GetResID(queue), eFrameRef_Read); } return ret; }
void WrappedOpenGL::glTextureView(GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers) { m_Real.glTextureView(texture, target, origtexture, internalformat, minlevel, numlevels, minlayer, numlayers); if(m_State >= WRITING) { ResourceRecord *record = GetResourceManager()->GetResourceRecord(TextureRes(texture)); ResourceRecord *origrecord = GetResourceManager()->GetResourceRecord(TextureRes(origtexture)); RDCASSERT(record && origrecord); SCOPED_SERIALISE_CONTEXT(TEXTURE_VIEW); Serialise_glTextureView(texture, target, origtexture, internalformat, minlevel, numlevels, minlayer, numlayers); record->AddChunk(scope.Get()); record->AddParent(origrecord); } }
void WrappedOpenGL::glNamedFramebufferTextureLayerEXT(GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer) { m_Real.glNamedFramebufferTextureLayerEXT(framebuffer, attachment, texture, level, layer); if(m_State >= WRITING) { GLResourceRecord *record = GetResourceManager()->GetResourceRecord(FramebufferRes(GetCtx(), framebuffer)); SCOPED_SERIALISE_CONTEXT(FRAMEBUFFER_TEXLAYER); Serialise_glNamedFramebufferTextureLayerEXT(framebuffer, attachment, texture, level, layer); if(m_State == WRITING_IDLE) record->AddChunk(scope.Get()); else m_ContextRecord->AddChunk(scope.Get()); } }
HRESULT WrappedID3D11Device::CreateBlendState1(const D3D11_BLEND_DESC1 *pBlendStateDesc, ID3D11BlendState1 **ppBlendState) { if(m_pDevice1 == NULL) return E_NOINTERFACE; if(ppBlendState == NULL) return m_pDevice1->CreateBlendState1(pBlendStateDesc, NULL); ID3D11BlendState1 *real = NULL; HRESULT ret = m_pDevice1->CreateBlendState1(pBlendStateDesc, &real); if(SUCCEEDED(ret)) { SCOPED_LOCK(m_D3DLock); // duplicate states can be returned, if Create is called with a previous descriptor if(GetResourceManager()->HasWrapper(real)) { real->Release(); *ppBlendState = (ID3D11BlendState1 *)GetResourceManager()->GetWrapper(real); (*ppBlendState)->AddRef(); return ret; } ID3D11BlendState1 *wrapped = new WrappedID3D11BlendState1(real, this); CachedObjectsGarbageCollect(); { RDCASSERT(m_CachedStateObjects.find(wrapped) == m_CachedStateObjects.end()); wrapped->AddRef(); InternalRef(); m_CachedStateObjects.insert(wrapped); } if(m_State >= WRITING) { SCOPED_SERIALISE_CONTEXT(CREATE_BLEND_STATE1); Serialise_CreateBlendState1(pBlendStateDesc, &wrapped); m_DeviceRecord->AddChunk(scope.Get()); } *ppBlendState = wrapped; } return ret; }
HRESULT WrappedID3D12Device::CreateComputePipelineState(const D3D12_COMPUTE_PIPELINE_STATE_DESC *pDesc, REFIID riid, void **ppPipelineState) { D3D12_COMPUTE_PIPELINE_STATE_DESC unwrappedDesc = *pDesc; unwrappedDesc.pRootSignature = Unwrap(unwrappedDesc.pRootSignature); if(ppPipelineState == NULL) return m_pDevice->CreateComputePipelineState(&unwrappedDesc, riid, NULL); if(riid != __uuidof(ID3D12PipelineState)) return E_NOINTERFACE; ID3D12PipelineState *real = NULL; HRESULT ret = m_pDevice->CreateComputePipelineState(&unwrappedDesc, riid, (void **)&real); if(SUCCEEDED(ret)) { SCOPED_LOCK(m_D3DLock); WrappedID3D12PipelineState *wrapped = new WrappedID3D12PipelineState(real, this); if(m_State >= WRITING) { SCOPED_SERIALISE_CONTEXT(CREATE_COMPUTE_PIPE); Serialise_CreateComputePipelineState(pDesc, riid, (void **)&wrapped); D3D12ResourceRecord *record = GetResourceManager()->AddResourceRecord(wrapped->GetResourceID()); record->type = Resource_PipelineState; record->Length = 0; wrapped->SetResourceRecord(record); record->AddParent(GetRecord(pDesc->pRootSignature)); record->AddChunk(scope.Get()); } else { GetResourceManager()->AddLiveResource(wrapped->GetResourceID(), wrapped); } *ppPipelineState = (ID3D12PipelineState *)wrapped; } return ret; }
void WrappedOpenGL::glTextureSubImage2DEXT(GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels) { m_Real.glTextureSubImage2DEXT(texture, target, level, xoffset, yoffset, width, height, format, type, pixels); if(m_State >= WRITING) { GLResourceRecord *record = GetResourceManager()->GetResourceRecord(TextureRes(texture)); RDCASSERT(record); SCOPED_SERIALISE_CONTEXT(TEXSUBIMAGE2D); Serialise_glTextureSubImage2DEXT(texture, target, level, xoffset, yoffset, width, height, format, type, pixels); if(m_State == WRITING_CAPFRAME) m_ContextRecord->AddChunk(scope.Get()); else record->AddChunk(scope.Get()); } }
void WrappedOpenGL::glTextureStorage3DEXT(GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth) { m_Real.glTextureStorage3DEXT(texture, target, levels, internalformat, width, height, depth); if(m_State >= WRITING) { GLResourceRecord *record = GetResourceManager()->GetResourceRecord(TextureRes(texture)); RDCASSERT(record); SCOPED_SERIALISE_CONTEXT(TEXSTORAGE3D); Serialise_glTextureStorage3DEXT(texture, target, levels, internalformat, width, height, depth); if(m_State == WRITING_CAPFRAME) m_ContextRecord->AddChunk(scope.Get()); else record->AddChunk(scope.Get()); } }
void WrappedOpenGL::glTextureParameterfvEXT(GLuint texture, GLenum target, GLenum pname, const GLfloat *params) { m_Real.glTextureParameterfvEXT(texture, target, pname, params); if(m_State >= WRITING) { GLResourceRecord *record = GetResourceManager()->GetResourceRecord(TextureRes(texture)); RDCASSERT(record); SCOPED_SERIALISE_CONTEXT(TEXPARAMETERFV); Serialise_glTextureParameterfvEXT(texture, target, pname, params); if(m_State == WRITING_IDLE) record->AddChunk(scope.Get()); else m_ContextRecord->AddChunk(scope.Get()); } }
void WrappedVulkan::vkCmdSetLineWidth(VkCommandBuffer cmdBuffer, float lineWidth) { SCOPED_DBG_SINK(); ObjDisp(cmdBuffer)->CmdSetLineWidth(Unwrap(cmdBuffer), lineWidth); if(m_State >= WRITING) { VkResourceRecord *record = GetRecord(cmdBuffer); CACHE_THREAD_SERIALISER(); SCOPED_SERIALISE_CONTEXT(SET_LINE_WIDTH); Serialise_vkCmdSetLineWidth(localSerialiser, cmdBuffer, lineWidth); record->AddChunk(scope.Get()); } }
void WrappedVulkan::vkCmdSetBlendConstants(VkCommandBuffer cmdBuffer, const float *blendConst) { SCOPED_DBG_SINK(); ObjDisp(cmdBuffer)->CmdSetBlendConstants(Unwrap(cmdBuffer), blendConst); if(m_State >= WRITING) { VkResourceRecord *record = GetRecord(cmdBuffer); CACHE_THREAD_SERIALISER(); SCOPED_SERIALISE_CONTEXT(SET_BLEND_CONST); Serialise_vkCmdSetBlendConstants(localSerialiser, cmdBuffer, blendConst); record->AddChunk(scope.Get()); } }
void WrappedOpenGL::glAttachShader(GLuint program, GLuint shader) { m_Real.glAttachShader(program, shader); if(m_State >= WRITING && program != 0 && shader != 0) { GLResourceRecord *progRecord = GetResourceManager()->GetResourceRecord(ProgramRes(GetCtx(), program)); GLResourceRecord *shadRecord = GetResourceManager()->GetResourceRecord(ShaderRes(GetCtx(), shader)); RDCASSERT(progRecord && shadRecord); { SCOPED_SERIALISE_CONTEXT(ATTACHSHADER); Serialise_glAttachShader(program, shader); progRecord->AddParent(shadRecord); progRecord->AddChunk(scope.Get()); } } }
void WrappedOpenGL::glDetachShader(GLuint program, GLuint shader) { m_Real.glDetachShader(program, shader); // check that shader still exists, it might have been deleted. If it has, it's not too important // that we detach the shader (only important if the program will attach it elsewhere). if(m_State >= WRITING && program != 0 && shader != 0 && GetResourceManager()->HasCurrentResource(ShaderRes(GetCtx(), shader))) { GLResourceRecord *progRecord = GetResourceManager()->GetResourceRecord(ProgramRes(GetCtx(), program)); RDCASSERT(progRecord); { SCOPED_SERIALISE_CONTEXT(DETACHSHADER); Serialise_glDetachShader(program, shader); progRecord->AddChunk(scope.Get()); } } }
void WrappedOpenGL::glTexSubImage1D(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels) { m_Real.glTexSubImage1D(target, level, xoffset, width, format, type, pixels); if(m_State >= WRITING) { GLResourceRecord *record = m_TextureRecord[m_TextureUnit]; RDCASSERT(record); SCOPED_SERIALISE_CONTEXT(TEXSUBIMAGE1D); Serialise_glTextureSubImage1DEXT(GetResourceManager()->GetCurrentResource(record->GetResourceID()).name, target, level, xoffset, width, format, type, pixels); if(m_State == WRITING_CAPFRAME) m_ContextRecord->AddChunk(scope.Get()); else record->AddChunk(scope.Get()); } }
void WrappedOpenGL::glTexParameterf(GLenum target, GLenum pname, GLfloat param) { m_Real.glTexParameterf(target, pname, param); if(m_State >= WRITING) { GLResourceRecord *record = m_TextureRecord[m_TextureUnit]; RDCASSERT(record); SCOPED_SERIALISE_CONTEXT(TEXPARAMETERF); Serialise_glTextureParameterfEXT(GetResourceManager()->GetCurrentResource(record->GetResourceID()).name, target, pname, param); if(m_State == WRITING_IDLE) record->AddChunk(scope.Get()); else m_ContextRecord->AddChunk(scope.Get()); } }