diff --git a/sources/Renderer/Direct3D11/D3D11CommandBuffer.cpp b/sources/Renderer/Direct3D11/D3D11CommandBuffer.cpp index 9c243ba53d..f5ea4f5e07 100644 --- a/sources/Renderer/Direct3D11/D3D11CommandBuffer.cpp +++ b/sources/Renderer/Direct3D11/D3D11CommandBuffer.cpp @@ -472,7 +472,7 @@ void D3D11CommandBuffer::CopyTexture( auto& dstTextureD3D = LLGL_CAST(D3D11Texture&, dstTexture); auto& srcTextureD3D = LLGL_CAST(D3D11Texture&, srcTexture); - const Offset3D dstOffset = CalcTextureOffset(dstTexture.GetType(), dstLocation.offset, dstLocation.arrayLayer); + const Offset3D dstOffset = CalcTextureOffset(dstTexture.GetType(), dstLocation.offset); const D3D11_BOX srcBox = srcTextureD3D.CalcRegion(srcLocation.offset, extent); context_->CopySubresourceRegion( diff --git a/sources/Renderer/Direct3D11/Texture/D3D11Texture.cpp b/sources/Renderer/Direct3D11/Texture/D3D11Texture.cpp index a3f8872e36..cfb72b0d08 100644 --- a/sources/Renderer/Direct3D11/Texture/D3D11Texture.cpp +++ b/sources/Renderer/Direct3D11/Texture/D3D11Texture.cpp @@ -343,7 +343,7 @@ static void CreateD3D11TextureSubresourceCopyWithCPUAccess( desc.Usage = outTextureUsage; desc.BindFlags = 0; desc.CPUAccessFlags = cpuAccessFlags; - desc.MiscFlags = (desc.MiscFlags & D3D11_RESOURCE_MISC_TEXTURECUBE); + desc.MiscFlags = 0; // Don't adopt D3D11_RESOURCE_MISC_TEXTURECUBE here for CPU access textures } outTexture.tex2D = DXCreateTexture2D(device, desc); } diff --git a/sources/Renderer/OpenGL/Texture/GLTexture.cpp b/sources/Renderer/OpenGL/Texture/GLTexture.cpp index 78a6ba669c..210d3f3744 100644 --- a/sources/Renderer/OpenGL/Texture/GLTexture.cpp +++ b/sources/Renderer/OpenGL/Texture/GLTexture.cpp @@ -399,6 +399,15 @@ void GLTexture::TexParameterSwizzle( #ifdef GL_ARB_copy_image +// For glCopyImageSubData, the array lazer is always specified in the Z-coordinate +static Offset3D ToGLArrayTextureOffset(TextureType type, const Offset3D& offset) +{ + if (type == TextureType::Texture1DArray) + return Offset3D{ offset.x, 0, offset.y }; + else + return offset; +} + static void GLCopyImageSubData( GLTexture& dstTexture, GLint dstLevel, @@ -409,19 +418,21 @@ static void GLCopyImageSubData( const Extent3D& extent) { /* Copy raw data of texture directly (GL 4.3+) */ + const Offset3D dstOffsetGL = ToGLArrayTextureOffset(dstTexture.GetType(), dstOffset); + const Offset3D srcOffsetGL = ToGLArrayTextureOffset(srcTexture.GetType(), srcOffset); glCopyImageSubData( srcTexture.GetID(), GLTypes::Map(srcTexture.GetType()), srcLevel, - srcOffset.x, - srcOffset.y, - srcOffset.z, + srcOffsetGL.x, + srcOffsetGL.y, + srcOffsetGL.z, dstTexture.GetID(), GLTypes::Map(dstTexture.GetType()), dstLevel, - dstOffset.x, - dstOffset.y, - dstOffset.z, + dstOffsetGL.x, + dstOffsetGL.y, + dstOffsetGL.z, static_cast(extent.width), static_cast(extent.height), static_cast(extent.depth)