diff options
| author | Egor Yusov <egor.yusov@gmail.com> | 2019-04-19 14:41:40 +0000 |
|---|---|---|
| committer | Egor Yusov <egor.yusov@gmail.com> | 2019-04-19 14:41:40 +0000 |
| commit | 375f659389e88fd650bf6863edc86e781b026694 (patch) | |
| tree | 31c85a39fa48f65a733e3c85878ccc3cb96c0c7c /Graphics/GraphicsEngineOpenGL | |
| parent | Fixed handling compressed textures in TextureUploaderGL; fixed non-compressed... (diff) | |
| download | DiligentCore-375f659389e88fd650bf6863edc86e781b026694.tar.gz DiligentCore-375f659389e88fd650bf6863edc86e781b026694.zip | |
Fixed unpack buffer offsets in GL back-end
Diffstat (limited to 'Graphics/GraphicsEngineOpenGL')
7 files changed, 44 insertions, 11 deletions
diff --git a/Graphics/GraphicsEngineOpenGL/src/Texture1DArray_OGL.cpp b/Graphics/GraphicsEngineOpenGL/src/Texture1DArray_OGL.cpp index 4b14bfdb..bf051ff3 100644 --- a/Graphics/GraphicsEngineOpenGL/src/Texture1DArray_OGL.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/Texture1DArray_OGL.cpp @@ -136,7 +136,10 @@ void Texture1DArray_OGL::UpdateData( GLContextState& ContextState, DstBox.MaxX - DstBox.MinX, 1, TransferAttribs.PixelFormat, TransferAttribs.DataType, - SubresData.pData); + // If a non-zero named buffer object is bound to the GL_PIXEL_UNPACK_BUFFER target, 'data' is treated + // as a byte offset into the buffer object's data store. + // https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glTexSubImage2D.xhtml + SubresData.pSrcBuffer != nullptr ? reinterpret_cast<void*>(static_cast<size_t>(SubresData.SrcOffset)) : SubresData.pData); CHECK_GL_ERROR("Failed to update subimage data"); diff --git a/Graphics/GraphicsEngineOpenGL/src/Texture1D_OGL.cpp b/Graphics/GraphicsEngineOpenGL/src/Texture1D_OGL.cpp index bcff1681..87b7f4b1 100644 --- a/Graphics/GraphicsEngineOpenGL/src/Texture1D_OGL.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/Texture1D_OGL.cpp @@ -131,7 +131,10 @@ void Texture1D_OGL::UpdateData( GLContextState& ContextState, DstBox.MinX, DstBox.MaxX - DstBox.MinX, TransferAttribs.PixelFormat, TransferAttribs.DataType, - SubresData.pData); + // If a non-zero named buffer object is bound to the GL_PIXEL_UNPACK_BUFFER target, 'data' is treated + // as a byte offset into the buffer object's data store. + // https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/glTexSubImage1D.xml + SubresData.pSrcBuffer != nullptr ? reinterpret_cast<void*>(static_cast<size_t>(SubresData.SrcOffset)) : SubresData.pData); CHECK_GL_ERROR("Failed to update subimage data"); if(UnpackBuffer != 0) diff --git a/Graphics/GraphicsEngineOpenGL/src/Texture2DArray_OGL.cpp b/Graphics/GraphicsEngineOpenGL/src/Texture2DArray_OGL.cpp index a87bff16..cf94dc9a 100644 --- a/Graphics/GraphicsEngineOpenGL/src/Texture2DArray_OGL.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/Texture2DArray_OGL.cpp @@ -185,7 +185,10 @@ void Texture2DArray_OGL::UpdateData(GLContextState& ContextState, // the format, dimensions, and contents of the compressed image( too little or // too much data ), ((DstBox.MaxY - DstBox.MinY + 3)/4) * SubresData.Stride, - SubresData.pData); + // If a non-zero named buffer object is bound to the GL_PIXEL_UNPACK_BUFFER target, 'data' is treated + // as a byte offset into the buffer object's data store. + // https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glCompressedTexSubImage3D.xhtml + SubresData.pSrcBuffer != nullptr ? reinterpret_cast<void*>(static_cast<size_t>(SubresData.SrcOffset)) : SubresData.pData); } else { @@ -204,7 +207,10 @@ void Texture2DArray_OGL::UpdateData(GLContextState& ContextState, DstBox.MaxY - DstBox.MinY, 1, TransferAttribs.PixelFormat, TransferAttribs.DataType, - SubresData.pData); + // If a non-zero named buffer object is bound to the GL_PIXEL_UNPACK_BUFFER target, 'data' is treated + // as a byte offset into the buffer object's data store. + // https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glTexSubImage3D.xhtml + SubresData.pSrcBuffer != nullptr ? reinterpret_cast<void*>(static_cast<size_t>(SubresData.SrcOffset)) : SubresData.pData); } CHECK_GL_ERROR("Failed to update subimage data"); diff --git a/Graphics/GraphicsEngineOpenGL/src/Texture2D_OGL.cpp b/Graphics/GraphicsEngineOpenGL/src/Texture2D_OGL.cpp index fab45d69..7bb07d1c 100644 --- a/Graphics/GraphicsEngineOpenGL/src/Texture2D_OGL.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/Texture2D_OGL.cpp @@ -187,7 +187,10 @@ void Texture2D_OGL::UpdateData( GLContextState& ContextState, // the format, dimensions, and contents of the compressed image( too little or // too much data ), ((DstBox.MaxY - DstBox.MinY + 3)/4) * SubresData.Stride, - SubresData.pData); + // If a non-zero named buffer object is bound to the GL_PIXEL_UNPACK_BUFFER target, 'data' is treated + // as a byte offset into the buffer object's data store. + // https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glCompressedTexSubImage2D.xhtml + SubresData.pSrcBuffer != nullptr ? reinterpret_cast<void*>(static_cast<size_t>(SubresData.SrcOffset)) : SubresData.pData); } else { @@ -204,7 +207,10 @@ void Texture2D_OGL::UpdateData( GLContextState& ContextState, DstBox.MaxX - DstBox.MinX, DstBox.MaxY - DstBox.MinY, TransferAttribs.PixelFormat, TransferAttribs.DataType, - SubresData.pData); + // If a non-zero named buffer object is bound to the GL_PIXEL_UNPACK_BUFFER target, 'data' is treated + // as a byte offset into the buffer object's data store. + // https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glTexSubImage2D.xhtml + SubresData.pSrcBuffer != nullptr ? reinterpret_cast<void*>(static_cast<size_t>(SubresData.SrcOffset)) : SubresData.pData); } CHECK_GL_ERROR("Failed to update subimage data"); diff --git a/Graphics/GraphicsEngineOpenGL/src/Texture3D_OGL.cpp b/Graphics/GraphicsEngineOpenGL/src/Texture3D_OGL.cpp index 53ddccb7..129001d6 100644 --- a/Graphics/GraphicsEngineOpenGL/src/Texture3D_OGL.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/Texture3D_OGL.cpp @@ -147,7 +147,10 @@ void Texture3D_OGL::UpdateData( GLContextState& ContextState, DstBox.MaxY - DstBox.MinY, DstBox.MaxZ - DstBox.MinZ, TransferAttribs.PixelFormat, TransferAttribs.DataType, - SubresData.pData); + // If a non-zero named buffer object is bound to the GL_PIXEL_UNPACK_BUFFER target, 'data' is treated + // as a byte offset into the buffer object's data store. + // https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glTexSubImage3D.xhtml + SubresData.pSrcBuffer != nullptr ? reinterpret_cast<void*>(static_cast<size_t>(SubresData.SrcOffset)) : SubresData.pData); CHECK_GL_ERROR("Failed to update subimage data"); diff --git a/Graphics/GraphicsEngineOpenGL/src/TextureCubeArray_OGL.cpp b/Graphics/GraphicsEngineOpenGL/src/TextureCubeArray_OGL.cpp index 21304f39..ea7f7d6a 100644 --- a/Graphics/GraphicsEngineOpenGL/src/TextureCubeArray_OGL.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/TextureCubeArray_OGL.cpp @@ -175,7 +175,10 @@ void TextureCubeArray_OGL::UpdateData( GLContextState& ContextState, // the format, dimensions, and contents of the compressed image( too little or // too much data ), ((DstBox.MaxY - DstBox.MinY + 3)/4) * SubresData.Stride, - SubresData.pData); + // If a non-zero named buffer object is bound to the GL_PIXEL_UNPACK_BUFFER target, 'data' is treated + // as a byte offset into the buffer object's data store. + // https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glCompressedTexSubImage3D.xhtml + SubresData.pSrcBuffer != nullptr ? reinterpret_cast<void*>(static_cast<size_t>(SubresData.SrcOffset)) : SubresData.pData); } else { @@ -202,7 +205,10 @@ void TextureCubeArray_OGL::UpdateData( GLContextState& ContextState, DstBox.MaxY - DstBox.MinY, 1, TransferAttribs.PixelFormat, TransferAttribs.DataType, - SubresData.pData); + // If a non-zero named buffer object is bound to the GL_PIXEL_UNPACK_BUFFER target, 'data' is treated + // as a byte offset into the buffer object's data store. + // https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glTexSubImage3D.xhtml + SubresData.pSrcBuffer != nullptr ? reinterpret_cast<void*>(static_cast<size_t>(SubresData.SrcOffset)) : SubresData.pData); } CHECK_GL_ERROR("Failed to update subimage data"); diff --git a/Graphics/GraphicsEngineOpenGL/src/TextureCube_OGL.cpp b/Graphics/GraphicsEngineOpenGL/src/TextureCube_OGL.cpp index bb55c9ad..d979002e 100644 --- a/Graphics/GraphicsEngineOpenGL/src/TextureCube_OGL.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/TextureCube_OGL.cpp @@ -188,7 +188,10 @@ void TextureCube_OGL::UpdateData( GLContextState& ContextState, // the format, dimensions, and contents of the compressed image( too little or // too much data ), ((DstBox.MaxY - DstBox.MinY + 3)/4) * SubresData.Stride, - SubresData.pData); + // If a non-zero named buffer object is bound to the GL_PIXEL_UNPACK_BUFFER target, 'data' is treated + // as a byte offset into the buffer object's data store. + // https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glCompressedTexSubImage2D.xhtml + SubresData.pSrcBuffer != nullptr ? reinterpret_cast<void*>(static_cast<size_t>(SubresData.SrcOffset)) : SubresData.pData); } else { @@ -207,7 +210,10 @@ void TextureCube_OGL::UpdateData( GLContextState& ContextState, DstBox.MaxX - DstBox.MinX, DstBox.MaxY - DstBox.MinY, TransferAttribs.PixelFormat, TransferAttribs.DataType, - SubresData.pData); + // If a non-zero named buffer object is bound to the GL_PIXEL_UNPACK_BUFFER target, 'data' is treated + // as a byte offset into the buffer object's data store. + // https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glTexSubImage2D.xhtml + SubresData.pSrcBuffer != nullptr ? reinterpret_cast<void*>(static_cast<size_t>(SubresData.SrcOffset)) : SubresData.pData); } CHECK_GL_ERROR("Failed to update subimage data"); |
