Skip to content

Commit 1e494ca

Browse files
Brandon SchadeCommit Bot
authored andcommitted
Vulkan: Add support for EXT_copy_image
Add support for GL_EXT_copy_image which allows image data transfer between image objects. This is implemented by using the vkCmdCopyImage API call. Bug: angleproject:3593 Test: dEQP-GLES31.functional.copy_image.* Change-Id: I30a34a8711b5d2e5834064d7453e03d6ec0df478 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2393955 Commit-Queue: Brandon Schade <b.schade@samsung.com> Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
1 parent 658ede5 commit 1e494ca

28 files changed

+1602
-35
lines changed

src/libANGLE/Caps.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,6 +1040,7 @@ const ExtensionInfoMap &GetExtensionInfoMap()
10401040
map["GL_OES_shader_image_atomic"] = enableableExtension(&Extensions::shaderImageAtomicOES);
10411041
map["GL_NV_robustness_video_memory_purge"] = esOnlyExtension(&Extensions::robustnessVideoMemoryPurgeNV);
10421042
map["GL_ANGLE_get_tex_level_parameter"] = enableableExtension(&Extensions::getTexLevelParameterANGLE);
1043+
map["GL_EXT_copy_image"] = enableableExtension(&Extensions::copyImageEXT);
10431044
// GLES1 extensions
10441045
map["GL_OES_point_size_array"] = enableableExtension(&Extensions::pointSizeArrayOES);
10451046
map["GL_OES_texture_cube_map"] = enableableExtension(&Extensions::textureCubeMapOES);

src/libANGLE/Caps.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,9 @@ struct Extensions
665665

666666
// GL_ANGLE_get_tex_level_parameter
667667
bool getTexLevelParameterANGLE = false;
668+
669+
// GL_EXT_copy_image
670+
bool copyImageEXT = false;
668671
};
669672

670673
// Pointer to a boolean memeber of the Extensions struct

src/libANGLE/Context.cpp

Lines changed: 81 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4122,7 +4122,75 @@ void Context::copyImageSubData(GLuint srcName,
41224122
GLsizei srcHeight,
41234123
GLsizei srcDepth)
41244124
{
4125-
UNIMPLEMENTED();
4125+
// if copy region is zero, the copy is a successful no-op
4126+
if ((srcWidth == 0) || (srcHeight == 0) || (srcDepth == 0))
4127+
{
4128+
return;
4129+
}
4130+
4131+
if (srcTarget == GL_RENDERBUFFER)
4132+
{
4133+
// Source target is a Renderbuffer
4134+
Renderbuffer *readBuffer = getRenderbuffer(FromGL<RenderbufferID>(srcName));
4135+
if (dstTarget == GL_RENDERBUFFER)
4136+
{
4137+
// Destination target is a Renderbuffer
4138+
Renderbuffer *writeBuffer = getRenderbuffer(FromGL<RenderbufferID>(dstName));
4139+
4140+
// Copy Renderbuffer to Renderbuffer
4141+
ANGLE_CONTEXT_TRY(writeBuffer->copyRenderbufferSubData(
4142+
this, readBuffer, srcLevel, srcX, srcY, srcZ, dstLevel, dstX, dstY, dstZ, srcWidth,
4143+
srcHeight, srcDepth));
4144+
}
4145+
else
4146+
{
4147+
// Destination target is a Texture
4148+
ASSERT(dstTarget == GL_TEXTURE_2D || dstTarget == GL_TEXTURE_2D_ARRAY ||
4149+
dstTarget == GL_TEXTURE_3D || dstTarget == GL_TEXTURE_CUBE_MAP);
4150+
4151+
Texture *writeTexture = getTexture(FromGL<TextureID>(dstName));
4152+
ANGLE_CONTEXT_TRY(syncTextureForCopy(writeTexture));
4153+
4154+
// Copy Renderbuffer to Texture
4155+
ANGLE_CONTEXT_TRY(writeTexture->copyRenderbufferSubData(
4156+
this, readBuffer, srcLevel, srcX, srcY, srcZ, dstLevel, dstX, dstY, dstZ, srcWidth,
4157+
srcHeight, srcDepth));
4158+
}
4159+
}
4160+
else
4161+
{
4162+
// Source target is a Texture
4163+
ASSERT(srcTarget == GL_TEXTURE_2D || srcTarget == GL_TEXTURE_2D_ARRAY ||
4164+
srcTarget == GL_TEXTURE_3D || srcTarget == GL_TEXTURE_CUBE_MAP);
4165+
4166+
Texture *readTexture = getTexture(FromGL<TextureID>(srcName));
4167+
ANGLE_CONTEXT_TRY(syncTextureForCopy(readTexture));
4168+
4169+
if (dstTarget == GL_RENDERBUFFER)
4170+
{
4171+
// Destination target is a Renderbuffer
4172+
Renderbuffer *writeBuffer = getRenderbuffer(FromGL<RenderbufferID>(dstName));
4173+
4174+
// Copy Texture to Renderbuffer
4175+
ANGLE_CONTEXT_TRY(writeBuffer->copyTextureSubData(this, readTexture, srcLevel, srcX,
4176+
srcY, srcZ, dstLevel, dstX, dstY,
4177+
dstZ, srcWidth, srcHeight, srcDepth));
4178+
}
4179+
else
4180+
{
4181+
// Destination target is a Texture
4182+
ASSERT(dstTarget == GL_TEXTURE_2D || dstTarget == GL_TEXTURE_2D_ARRAY ||
4183+
dstTarget == GL_TEXTURE_3D || dstTarget == GL_TEXTURE_CUBE_MAP);
4184+
4185+
Texture *writeTexture = getTexture(FromGL<TextureID>(dstName));
4186+
ANGLE_CONTEXT_TRY(syncTextureForCopy(writeTexture));
4187+
4188+
// Copy Texture to Texture
4189+
ANGLE_CONTEXT_TRY(writeTexture->copyTextureSubData(
4190+
this, readTexture, srcLevel, srcX, srcY, srcZ, dstLevel, dstX, dstY, dstZ, srcWidth,
4191+
srcHeight, srcDepth));
4192+
}
4193+
}
41264194
}
41274195

41284196
void Context::framebufferTexture2D(GLenum target,
@@ -4862,6 +4930,18 @@ angle::Result Context::syncStateForClear()
48624930
return syncState(mClearDirtyBits, mClearDirtyObjects, Command::Clear);
48634931
}
48644932

4933+
angle::Result Context::syncTextureForCopy(Texture *texture)
4934+
{
4935+
ASSERT(texture);
4936+
// Sync texture not active but scheduled for a copy
4937+
if (texture->hasAnyDirtyBit())
4938+
{
4939+
return texture->syncState(this, Command::Other);
4940+
}
4941+
4942+
return angle::Result::Continue;
4943+
}
4944+
48654945
void Context::activeShaderProgram(ProgramPipelineID pipeline, ShaderProgramID program)
48664946
{
48674947
Program *shaderProgram = getProgramNoResolveLink(program);

src/libANGLE/Context.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,7 @@ class Context final : public egl::LabeledObject, angle::NonCopyable, public angl
653653
angle::Result syncStateForTexImage();
654654
angle::Result syncStateForBlit();
655655
angle::Result syncStateForClear();
656+
angle::Result syncTextureForCopy(Texture *texture);
656657

657658
VertexArray *checkVertexArrayAllocation(VertexArrayID vertexArrayHandle);
658659
TransformFeedback *checkTransformFeedbackAllocation(TransformFeedbackID transformFeedback);

src/libANGLE/ErrorStrings.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ MSG kEnumRequiresGLES30 = "Enum requires GLES 3.0";
104104
MSG kEnumRequiresGLES31 = "Enum requires GLES 3.1";
105105
MSG kES1or32Required = "OpenGL ES 1.x or 3.2 Required";
106106
MSG kES31Required = "OpenGL ES 3.1 Required";
107+
MSG kES32Required = "OpenGL ES 3.2 Required";
107108
MSG kES3Required = "OpenGL ES 3.0 Required.";
108109
MSG kExceedsComputeWorkGroupCountX = "num_groups_x cannot be greater than MAX_COMPUTE_WORK_GROUP_COUNT[0]";
109110
MSG kExceedsComputeWorkGroupCountY = "num_groups_y cannot be greater than MAX_COMPUTE_WORK_GROUP_COUNT[1]";
@@ -150,6 +151,7 @@ MSG kImageSizeTooSmall = "imageSize is too small.";
150151
MSG kImmutableMemoryObject = "The memory object is immutable.";
151152
MSG kImmutableTextureBound = "The value of TEXTURE_IMMUTABLE_FORMAT for the texture currently bound to target on the active texture unit is true.";
152153
MSG kIncompatibleDrawModeAgainstGeometryShader = "Primitive mode is incompatible with the input primitive type of the geometry shader.";
154+
MSG kIncompatibleTextures = "Texture formats are not compatible";
153155
MSG kIndexExceedsActiveUniformBlockCount = "Index exceeds active uniform block count.";
154156
MSG kIndexExceedsMaxActiveUniform = "Index must be less than program active uniform count.";
155157
MSG kIndexExceedsMaxActiveUniformBlock = "Index must be less than program active uniform block count.";
@@ -191,6 +193,7 @@ MSG kInvalidCombinedImageUnit = "Specified unit must be in [GL_TEXTURE0, GL_TEXT
191193
MSG kInvalidComponents = "Invalid components.";
192194
MSG kInvalidCompressedFormat = "Not a valid compressed texture format.";
193195
MSG kInvalidCompressedImageSize = "Invalid compressed image size.";
196+
MSG kInvalidCompressedRegionSize = "Invalid region for compressed texture format.";
194197
MSG kInvalidConstantColor = "CONSTANT_COLOR (or ONE_MINUS_CONSTANT_COLOR) and CONSTANT_ALPHA (or ONE_MINUS_CONSTANT_ALPHA) cannot be used together as source and destination color factors in the blend function.";
195198
MSG kInvalidCopyCombination = "Invalid copy texture format combination.";
196199
MSG kInvalidCoverageComponents = "components is not one of GL_RGB, GL_RGBA, GL_ALPHA or GL_NONE.";
@@ -395,6 +398,7 @@ MSG kNonPositiveDrawTextureDimension = "Both width and height argument of drawn
395398
MSG kNoProgramBinaryFormats = "No program binary formats supported.";
396399
MSG kNoReadFramebuffer = "No active read framebuffer.";
397400
MSG kNoSampleAlphaToCoveragesLimitation = "Current renderer doesn't support alpha-to-coverage.";
401+
MSG kNotTextureComplete = "The texture is not complete.";
398402
MSG kNoTransformArray = "No transform array given.";
399403
MSG kNoTransformFeedbackOutputVariables = "The active program has specified no output variables to record.";
400404
MSG kNoZeroDivisor = "At least one enabled attribute must have a divisor of zero.";

src/libANGLE/Renderbuffer.cpp

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,48 @@ angle::Result Renderbuffer::setStorageEGLImageTarget(const Context *context, egl
169169
return angle::Result::Continue;
170170
}
171171

172+
angle::Result Renderbuffer::copyRenderbufferSubData(Context *context,
173+
const gl::Renderbuffer *srcBuffer,
174+
GLint srcLevel,
175+
GLint srcX,
176+
GLint srcY,
177+
GLint srcZ,
178+
GLint dstLevel,
179+
GLint dstX,
180+
GLint dstY,
181+
GLint dstZ,
182+
GLsizei srcWidth,
183+
GLsizei srcHeight,
184+
GLsizei srcDepth)
185+
{
186+
ANGLE_TRY(mImplementation->copyRenderbufferSubData(context, srcBuffer, srcLevel, srcX, srcY,
187+
srcZ, dstLevel, dstX, dstY, dstZ, srcWidth,
188+
srcHeight, srcDepth));
189+
190+
return angle::Result::Continue;
191+
}
192+
193+
angle::Result Renderbuffer::copyTextureSubData(Context *context,
194+
const gl::Texture *srcTexture,
195+
GLint srcLevel,
196+
GLint srcX,
197+
GLint srcY,
198+
GLint srcZ,
199+
GLint dstLevel,
200+
GLint dstX,
201+
GLint dstY,
202+
GLint dstZ,
203+
GLsizei srcWidth,
204+
GLsizei srcHeight,
205+
GLsizei srcDepth)
206+
{
207+
ANGLE_TRY(mImplementation->copyTextureSubData(context, srcTexture, srcLevel, srcX, srcY, srcZ,
208+
dstLevel, dstX, dstY, dstZ, srcWidth, srcHeight,
209+
srcDepth));
210+
211+
return angle::Result::Continue;
212+
}
213+
172214
rx::RenderbufferImpl *Renderbuffer::getImplementation() const
173215
{
174216
ASSERT(mImplementation);

src/libANGLE/Renderbuffer.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,34 @@ class Renderbuffer final : public RefCountObject<RenderbufferID>,
9090
MultisamplingMode mode);
9191
angle::Result setStorageEGLImageTarget(const Context *context, egl::Image *imageTarget);
9292

93+
angle::Result copyRenderbufferSubData(Context *context,
94+
const gl::Renderbuffer *srcBuffer,
95+
GLint srcLevel,
96+
GLint srcX,
97+
GLint srcY,
98+
GLint srcZ,
99+
GLint dstLevel,
100+
GLint dstX,
101+
GLint dstY,
102+
GLint dstZ,
103+
GLsizei srcWidth,
104+
GLsizei srcHeight,
105+
GLsizei srcDepth);
106+
107+
angle::Result copyTextureSubData(Context *context,
108+
const gl::Texture *srcTexture,
109+
GLint srcLevel,
110+
GLint srcX,
111+
GLint srcY,
112+
GLint srcZ,
113+
GLint dstLevel,
114+
GLint dstX,
115+
GLint dstY,
116+
GLint dstZ,
117+
GLsizei srcWidth,
118+
GLsizei srcHeight,
119+
GLsizei srcDepth);
120+
93121
rx::RenderbufferImpl *getImplementation() const;
94122

95123
GLsizei getWidth() const;

src/libANGLE/Texture.cpp

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1326,6 +1326,52 @@ angle::Result Texture::copySubImage(Context *context,
13261326
return angle::Result::Continue;
13271327
}
13281328

1329+
angle::Result Texture::copyRenderbufferSubData(Context *context,
1330+
const gl::Renderbuffer *srcBuffer,
1331+
GLint srcLevel,
1332+
GLint srcX,
1333+
GLint srcY,
1334+
GLint srcZ,
1335+
GLint dstLevel,
1336+
GLint dstX,
1337+
GLint dstY,
1338+
GLint dstZ,
1339+
GLsizei srcWidth,
1340+
GLsizei srcHeight,
1341+
GLsizei srcDepth)
1342+
{
1343+
ANGLE_TRY(mTexture->copyRenderbufferSubData(context, srcBuffer, srcLevel, srcX, srcY, srcZ,
1344+
dstLevel, dstX, dstY, dstZ, srcWidth, srcHeight,
1345+
srcDepth));
1346+
1347+
signalDirtyStorage(InitState::Initialized);
1348+
1349+
return angle::Result::Continue;
1350+
}
1351+
1352+
angle::Result Texture::copyTextureSubData(Context *context,
1353+
const gl::Texture *srcTexture,
1354+
GLint srcLevel,
1355+
GLint srcX,
1356+
GLint srcY,
1357+
GLint srcZ,
1358+
GLint dstLevel,
1359+
GLint dstX,
1360+
GLint dstY,
1361+
GLint dstZ,
1362+
GLsizei srcWidth,
1363+
GLsizei srcHeight,
1364+
GLsizei srcDepth)
1365+
{
1366+
ANGLE_TRY(mTexture->copyTextureSubData(context, srcTexture, srcLevel, srcX, srcY, srcZ,
1367+
dstLevel, dstX, dstY, dstZ, srcWidth, srcHeight,
1368+
srcDepth));
1369+
1370+
signalDirtyStorage(InitState::Initialized);
1371+
1372+
return angle::Result::Continue;
1373+
}
1374+
13291375
angle::Result Texture::copyTexture(Context *context,
13301376
TextureTarget target,
13311377
GLint level,

src/libANGLE/Texture.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,34 @@ class Texture final : public RefCountObject<TextureID>,
390390
const Rectangle &sourceArea,
391391
Framebuffer *source);
392392

393+
angle::Result copyRenderbufferSubData(Context *context,
394+
const gl::Renderbuffer *srcBuffer,
395+
GLint srcLevel,
396+
GLint srcX,
397+
GLint srcY,
398+
GLint srcZ,
399+
GLint dstLevel,
400+
GLint dstX,
401+
GLint dstY,
402+
GLint dstZ,
403+
GLsizei srcWidth,
404+
GLsizei srcHeight,
405+
GLsizei srcDepth);
406+
407+
angle::Result copyTextureSubData(Context *context,
408+
const gl::Texture *srcTexture,
409+
GLint srcLevel,
410+
GLint srcX,
411+
GLint srcY,
412+
GLint srcZ,
413+
GLint dstLevel,
414+
GLint dstX,
415+
GLint dstY,
416+
GLint dstZ,
417+
GLsizei srcWidth,
418+
GLsizei srcHeight,
419+
GLsizei srcDepth);
420+
393421
angle::Result copyTexture(Context *context,
394422
TextureTarget target,
395423
GLint level,

0 commit comments

Comments
 (0)