Skip to content

Commit

Permalink
Fixed certain texture copy configurations in GL and D3D11 backends.
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasBanana committed Aug 14, 2023
1 parent e39c319 commit fef40f9
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
2 changes: 1 addition & 1 deletion sources/Renderer/Direct3D11/D3D11CommandBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion sources/Renderer/Direct3D11/Texture/D3D11Texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
23 changes: 17 additions & 6 deletions sources/Renderer/OpenGL/Texture/GLTexture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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<GLsizei>(extent.width),
static_cast<GLsizei>(extent.height),
static_cast<GLsizei>(extent.depth)
Expand Down

0 comments on commit fef40f9

Please sign in to comment.