diff --git a/glslang b/glslang index c8720ad..cb9c7d7 160000 --- a/glslang +++ b/glslang @@ -1 +1 @@ -Subproject commit c8720ad209ba609f80a736dc777887c805b7b2f5 +Subproject commit cb9c7d7bd57c09fd73c5aadfc881c0140b64fcdb diff --git a/include/boo/graphicsdev/IGraphicsCommandQueue.hpp b/include/boo/graphicsdev/IGraphicsCommandQueue.hpp index e84a530..f41bc81 100644 --- a/include/boo/graphicsdev/IGraphicsCommandQueue.hpp +++ b/include/boo/graphicsdev/IGraphicsCommandQueue.hpp @@ -32,7 +32,7 @@ struct IGraphicsCommandQueue virtual void drawInstances(size_t start, size_t count, size_t instCount)=0; virtual void drawInstancesIndexed(size_t start, size_t count, size_t instCount)=0; - virtual void resolveBindTexture(ITextureR* texture, const SWindowRect& rect, bool tlOrigin)=0; + virtual void resolveBindTexture(ITextureR* texture, const SWindowRect& rect, bool tlOrigin, bool color, bool depth)=0; virtual void resolveDisplay(ITextureR* source)=0; virtual void execute()=0; diff --git a/include/boo/graphicsdev/Metal.hpp b/include/boo/graphicsdev/Metal.hpp index 4d6f95c..2021dd0 100644 --- a/include/boo/graphicsdev/Metal.hpp +++ b/include/boo/graphicsdev/Metal.hpp @@ -49,7 +49,8 @@ public: ITextureSA* newStaticArrayTexture(size_t width, size_t height, size_t layers, TextureFormat fmt, const void* data, size_t sz); ITextureD* newDynamicTexture(size_t width, size_t height, TextureFormat fmt); - ITextureR* newRenderTexture(size_t width, size_t height); + ITextureR* newRenderTexture(size_t width, size_t height, + bool enableShaderColorBinding, bool enableShaderDepthBinding); bool bindingNeedsVertexFormat() const {return false;} IVertexFormat* newVertexFormat(size_t elementCount, const VertexElementDescriptor* elements); diff --git a/lib/graphicsdev/GL.cpp b/lib/graphicsdev/GL.cpp index bd20f9b..86ac46e 100644 --- a/lib/graphicsdev/GL.cpp +++ b/lib/graphicsdev/GL.cpp @@ -767,6 +767,8 @@ struct GLCommandQueue : IGraphicsCommandQueue }; }; const ITextureR* resolveTex; + bool resolveColor : 1; + bool resolveDepth : 1; Command(Op op) : m_op(op) {} }; std::vector m_cmdBufs[3]; @@ -980,15 +982,15 @@ struct GLCommandQueue : IGraphicsCommandQueue const GLTextureR* tex = static_cast(cmd.resolveTex); GLenum target = (tex->m_samples > 1) ? GL_TEXTURE_2D_MULTISAMPLE : GL_TEXTURE_2D; glBindFramebuffer(GL_READ_FRAMEBUFFER, tex->m_fbo); - glReadBuffer(GL_BACK); + //glReadBuffer(GL_FRONT); glActiveTexture(GL_TEXTURE9); - if (tex->m_bindTexs[0]) + if (cmd.resolveColor && tex->m_bindTexs[0]) { glBindTexture(target, tex->m_bindTexs[0]); glCopyTexSubImage2D(target, 0, cmd.rect.location[0], cmd.rect.location[1], cmd.rect.location[0], cmd.rect.location[1], cmd.rect.size[0], cmd.rect.size[1]); } - if (tex->m_bindTexs[1]) + if (cmd.resolveDepth && tex->m_bindTexs[1]) { glBindTexture(target, tex->m_bindTexs[1]); glCopyTexSubImage2D(target, 0, cmd.rect.location[0], cmd.rect.location[1], @@ -1134,14 +1136,16 @@ struct GLCommandQueue : IGraphicsCommandQueue cmds.back().instCount = instCount; } - void resolveBindTexture(ITextureR* texture, const SWindowRect& rect, bool tlOrigin) + void resolveBindTexture(ITextureR* texture, const SWindowRect& rect, bool tlOrigin, bool color, bool depth) { std::vector& cmds = m_cmdBufs[m_fillBuf]; cmds.emplace_back(Command::Op::ResolveBindTexture); cmds.back().resolveTex = texture; cmds.back().rect = rect; + cmds.back().resolveColor = color; + cmds.back().resolveDepth = depth; if (tlOrigin) - cmds.back().rect.location[1] = static_cast(texture)->m_height - rect.location[1]; + cmds.back().rect.location[1] = static_cast(texture)->m_height - rect.location[1] - rect.size[1]; } void resolveDisplay(ITextureR* source) diff --git a/lib/graphicsdev/Metal.mm b/lib/graphicsdev/Metal.mm index c5ce392..a555a60 100644 --- a/lib/graphicsdev/Metal.mm +++ b/lib/graphicsdev/Metal.mm @@ -678,6 +678,11 @@ struct MetalCommandQueue : IGraphicsCommandQueue instanceCount:instCount]; } + void resolveBindTexture(ITextureR* texture, const SWindowRect& rect, bool tlOrigin, bool color, bool depth) + { + + } + MetalTextureR* m_needsDisplay = nullptr; void resolveDisplay(ITextureR* source) { @@ -892,7 +897,8 @@ ITextureD* MetalDataFactory::newDynamicTexture(size_t width, size_t height, Text m_deferredData->m_DTexs.emplace_back(retval); return retval; } -ITextureR* MetalDataFactory::newRenderTexture(size_t width, size_t height) +ITextureR* MetalDataFactory::newRenderTexture(size_t width, size_t height, + bool enableShaderColorBinding, bool enableShaderDepthBinding) { MetalTextureR* retval = new MetalTextureR(m_ctx, width, height, m_sampleCount); if (!m_deferredData.get())