Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
angle
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
angle
Commits
1636e1b9
Commit
1636e1b9
authored
Jul 12, 2017
by
Commit Bot
Committed by
Gerrit Code Review
Jul 12, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge "D3D11: Clip copy rect to the source framebuffer for copyTexImage3D."
parents
f69ac0a5
bc5d7add
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
129 additions
and
21 deletions
+129
-21
TextureD3D.cpp
src/libANGLE/renderer/d3d/TextureD3D.cpp
+30
-7
WebGLReadOutsideFramebufferTest.cpp
src/tests/gl_tests/WebGLReadOutsideFramebufferTest.cpp
+99
-14
No files found.
src/libANGLE/renderer/d3d/TextureD3D.cpp
View file @
1636e1b9
...
...
@@ -2575,7 +2575,18 @@ gl::Error TextureD3D_3D::copySubImage(const gl::Context *context,
{
ASSERT
(
target
==
GL_TEXTURE_3D
);
GLint
level
=
static_cast
<
GLint
>
(
imageLevel
);
GLint
level
=
static_cast
<
GLint
>
(
imageLevel
);
gl
::
Extents
fbSize
=
source
->
getReadColorbuffer
()
->
getSize
();
gl
::
Rectangle
clippedSourceArea
;
if
(
!
ClipRectangle
(
sourceArea
,
gl
::
Rectangle
(
0
,
0
,
fbSize
.
width
,
fbSize
.
height
),
&
clippedSourceArea
))
{
return
gl
::
NoError
();
}
const
gl
::
Offset
clippedDestOffset
(
destOffset
.
x
+
clippedSourceArea
.
x
-
sourceArea
.
x
,
destOffset
.
y
+
clippedSourceArea
.
y
-
sourceArea
.
y
,
destOffset
.
z
);
// Currently, 3D single-layer blits are broken because we don't know how to make an SRV
// for a single layer of a 3D texture.
...
...
@@ -2584,7 +2595,8 @@ gl::Error TextureD3D_3D::copySubImage(const gl::Context *context,
// if (!canCreateRenderTargetForImage(index))
{
ANGLE_TRY
(
mImageArray
[
level
]
->
copyFromFramebuffer
(
context
,
destOffset
,
sourceArea
,
source
));
ANGLE_TRY
(
mImageArray
[
level
]
->
copyFromFramebuffer
(
context
,
clippedDestOffset
,
clippedSourceArea
,
source
));
mDirtyImages
=
true
;
}
// else
...
...
@@ -3135,11 +3147,22 @@ gl::Error TextureD3D_2DArray::copySubImage(const gl::Context *context,
GLint
level
=
static_cast
<
GLint
>
(
imageLevel
);
gl
::
ImageIndex
index
=
gl
::
ImageIndex
::
Make2DArray
(
level
,
destOffset
.
z
);
gl
::
Extents
fbSize
=
source
->
getReadColorbuffer
()
->
getSize
();
gl
::
Rectangle
clippedSourceArea
;
if
(
!
ClipRectangle
(
sourceArea
,
gl
::
Rectangle
(
0
,
0
,
fbSize
.
width
,
fbSize
.
height
),
&
clippedSourceArea
))
{
return
gl
::
NoError
();
}
const
gl
::
Offset
clippedDestOffset
(
destOffset
.
x
+
clippedSourceArea
.
x
-
sourceArea
.
x
,
destOffset
.
y
+
clippedSourceArea
.
y
-
sourceArea
.
y
,
destOffset
.
z
);
if
(
!
canCreateRenderTargetForImage
(
index
))
{
gl
::
Offset
destLayerOffset
(
destOffset
.
x
,
d
estOffset
.
y
,
0
);
ANGLE_TRY
(
mImageArray
[
level
][
destOffset
.
z
]
->
copyFromFramebuffer
(
context
,
destLayerOffset
,
s
ourceArea
,
source
));
gl
::
Offset
destLayerOffset
(
clippedDestOffset
.
x
,
clippedD
estOffset
.
y
,
0
);
ANGLE_TRY
(
mImageArray
[
level
][
clippedDestOffset
.
z
]
->
copyFromFramebuffer
(
context
,
destLayerOffset
,
clippedS
ourceArea
,
source
));
mDirtyImages
=
true
;
}
else
...
...
@@ -3150,9 +3173,9 @@ gl::Error TextureD3D_2DArray::copySubImage(const gl::Context *context,
{
ANGLE_TRY
(
updateStorageLevel
(
context
,
level
));
ANGLE_TRY
(
mRenderer
->
copyImage2DArray
(
context
,
source
,
s
ourceArea
,
mRenderer
->
copyImage2DArray
(
context
,
source
,
clippedS
ourceArea
,
gl
::
GetUnsizedFormat
(
getInternalFormat
(
getBaseLevel
())),
d
estOffset
,
mTexStorage
,
level
));
clippedD
estOffset
,
mTexStorage
,
level
));
}
}
return
gl
::
NoError
();
...
...
src/tests/gl_tests/WebGLReadOutsideFramebufferTest.cpp
View file @
1636e1b9
...
...
@@ -49,6 +49,24 @@ class PixelRect
glTexParameteri
(
GL_TEXTURE_2D
,
GL_TEXTURE_WRAP_T
,
GL_CLAMP_TO_EDGE
);
}
void
toTexture3D
(
GLuint
texid
,
GLint
depth
)
const
{
glBindTexture
(
GL_TEXTURE_3D
,
texid
);
glTexImage3D
(
GL_TEXTURE_3D
,
0
,
GL_RGBA
,
mWidth
,
mHeight
,
depth
,
0
,
GL_RGBA
,
GL_UNSIGNED_BYTE
,
nullptr
);
for
(
GLint
z
=
0
;
z
<
depth
;
z
++
)
{
glTexSubImage3D
(
GL_TEXTURE_3D
,
0
,
0
,
0
,
z
,
mWidth
,
mHeight
,
1
,
GL_RGBA
,
GL_UNSIGNED_BYTE
,
mData
.
data
());
}
glTexParameteri
(
GL_TEXTURE_3D
,
GL_TEXTURE_MIN_FILTER
,
GL_NEAREST
);
glTexParameteri
(
GL_TEXTURE_3D
,
GL_TEXTURE_MAG_FILTER
,
GL_NEAREST
);
glTexParameteri
(
GL_TEXTURE_3D
,
GL_TEXTURE_WRAP_S
,
GL_CLAMP_TO_EDGE
);
glTexParameteri
(
GL_TEXTURE_3D
,
GL_TEXTURE_WRAP_T
,
GL_CLAMP_TO_EDGE
);
glTexParameteri
(
GL_TEXTURE_3D
,
GL_TEXTURE_WRAP_R
,
GL_CLAMP_TO_EDGE
);
}
void
readFB
(
int
x
,
int
y
)
{
glReadPixels
(
x
,
y
,
mWidth
,
mHeight
,
GL_RGBA
,
GL_UNSIGNED_BYTE
,
mData
.
data
());
...
...
@@ -83,8 +101,17 @@ class PixelRect
void
compare
(
const
PixelRect
&
expected
)
const
{
for
(
int
i
=
0
;
i
<
mWidth
*
mHeight
;
++
i
)
ASSERT_EQ
(
expected
.
mData
[
i
],
mData
[
i
]);
ASSERT_EQ
(
mWidth
,
expected
.
mWidth
);
ASSERT_EQ
(
mHeight
,
expected
.
mHeight
);
for
(
int
x
=
0
;
x
<
mWidth
;
++
x
)
{
for
(
int
y
=
0
;
y
<
mHeight
;
++
y
)
{
ASSERT_EQ
(
expected
.
mData
[
x
+
y
*
mWidth
],
mData
[
x
+
y
*
mWidth
])
<<
"at ("
<<
x
<<
", "
<<
y
<<
")"
;
}
}
}
private
:
...
...
@@ -101,10 +128,10 @@ class WebGLReadOutsideFramebufferTest : public ANGLETest
{
public
:
// Read framebuffer to 'pixelsOut' via glReadPixels.
void
TestReadPixels
(
int
x
,
int
y
,
PixelRect
*
pixelsOut
)
{
pixelsOut
->
readFB
(
x
,
y
);
}
void
TestReadPixels
(
int
x
,
int
y
,
int
,
PixelRect
*
pixelsOut
)
{
pixelsOut
->
readFB
(
x
,
y
);
}
// Read framebuffer to 'pixelsOut' via glCopyTexSubImage2D.
void
TestCopyTexSubImage2D
(
int
x
,
int
y
,
PixelRect
*
pixelsOut
)
void
TestCopyTexSubImage2D
(
int
x
,
int
y
,
int
,
PixelRect
*
pixelsOut
)
{
// Init texture with given pixels.
GLTexture
destTexture
;
...
...
@@ -112,11 +139,23 @@ class WebGLReadOutsideFramebufferTest : public ANGLETest
// Read framebuffer -> texture -> 'pixelsOut'
glCopyTexSubImage2D
(
GL_TEXTURE_2D
,
0
,
0
,
0
,
x
,
y
,
kReadWidth
,
kReadHeight
);
readTexture
(
kReadWidth
,
kReadHeight
,
pixelsOut
);
readTexture2D
(
kReadWidth
,
kReadHeight
,
pixelsOut
);
}
// Read framebuffer to 'pixelsOut' via glCopyTexSubImage3D.
void
TestCopyTexSubImage3D
(
int
x
,
int
y
,
int
z
,
PixelRect
*
pixelsOut
)
{
// Init texture with given pixels.
GLTexture
destTexture
;
pixelsOut
->
toTexture3D
(
destTexture
.
get
(),
kTextureDepth
);
// Read framebuffer -> texture -> 'pixelsOut'
glCopyTexSubImage3D
(
GL_TEXTURE_3D
,
0
,
0
,
0
,
z
,
x
,
y
,
kReadWidth
,
kReadHeight
);
readTexture3D
(
destTexture
,
kReadWidth
,
kReadHeight
,
z
,
pixelsOut
);
}
// Read framebuffer to 'pixelsOut' via glCopyTexImage2D.
void
TestCopyTexImage2D
(
int
x
,
int
y
,
PixelRect
*
pixelsOut
)
void
TestCopyTexImage2D
(
int
x
,
int
y
,
int
,
PixelRect
*
pixelsOut
)
{
// Init texture with given pixels.
GLTexture
destTexture
;
...
...
@@ -124,14 +163,16 @@ class WebGLReadOutsideFramebufferTest : public ANGLETest
// Read framebuffer -> texture -> 'pixelsOut'
glCopyTexImage2D
(
GL_TEXTURE_2D
,
0
,
GL_RGBA
,
x
,
y
,
kReadWidth
,
kReadHeight
,
0
);
readTexture
(
kReadWidth
,
kReadHeight
,
pixelsOut
);
readTexture
2D
(
kReadWidth
,
kReadHeight
,
pixelsOut
);
}
protected
:
static
constexpr
int
kFbWidth
=
128
;
static
constexpr
int
kFbHeight
=
128
;
static
constexpr
int
kTextureDepth
=
16
;
static
constexpr
int
kReadWidth
=
4
;
static
constexpr
int
kReadHeight
=
4
;
static
constexpr
int
kReadLayer
=
2
;
// Tag the framebuffer pixels differently than the initial read buffer pixels, so we know for
// sure which pixels are changed by reading.
...
...
@@ -192,9 +233,19 @@ class WebGLReadOutsideFramebufferTest : public ANGLETest
ANGLETest
::
TearDown
();
}
using
TestFunc
=
void
(
WebGLReadOutsideFramebufferTest
::*
)(
int
x
,
int
y
,
PixelRect
*
dest
);
using
TestFunc
=
void
(
WebGLReadOutsideFramebufferTest
::*
)(
int
x
,
int
y
,
int
z
,
PixelRect
*
dest
);
void
Main2D
(
TestFunc
testFunc
,
bool
zeroOutside
)
{
mainImpl
(
testFunc
,
zeroOutside
,
0
);
}
void
Main3D
(
TestFunc
testFunc
,
bool
zeroOutside
)
{
mainImpl
(
testFunc
,
zeroOutside
,
kReadLayer
);
}
void
Main
(
TestFunc
testFunc
,
bool
zeroOutside
)
void
mainImpl
(
TestFunc
testFunc
,
bool
zeroOutside
,
int
readLayer
)
{
PixelRect
actual
(
kReadWidth
,
kReadHeight
);
PixelRect
expected
(
kReadWidth
,
kReadHeight
);
...
...
@@ -216,7 +267,7 @@ class WebGLReadOutsideFramebufferTest : public ANGLETest
// Read from framebuffer into 'actual.'
glBindFramebuffer
(
GL_FRAMEBUFFER
,
0
);
(
this
->*
testFunc
)(
x
,
y
,
&
actual
);
(
this
->*
testFunc
)(
x
,
y
,
readLayer
,
&
actual
);
glBindFramebuffer
(
GL_FRAMEBUFFER
,
0
);
// Simulate framebuffer read, into 'expected.'
...
...
@@ -230,7 +281,7 @@ class WebGLReadOutsideFramebufferTest : public ANGLETest
// Get contents of current texture by drawing it into a framebuffer then reading with
// glReadPixels().
void
readTexture
(
GLsizei
width
,
GLsizei
height
,
PixelRect
*
out
)
void
readTexture
2D
(
GLsizei
width
,
GLsizei
height
,
PixelRect
*
out
)
{
GLRenderbuffer
colorBuffer
;
glBindRenderbuffer
(
GL_RENDERBUFFER
,
colorBuffer
);
...
...
@@ -246,17 +297,31 @@ class WebGLReadOutsideFramebufferTest : public ANGLETest
out
->
readFB
(
0
,
0
);
}
// Get contents of current texture by drawing it into a framebuffer then reading with
// glReadPixels().
void
readTexture3D
(
GLuint
texture
,
GLsizei
width
,
GLsizei
height
,
int
zSlice
,
PixelRect
*
out
)
{
GLFramebuffer
fbo
;
glBindFramebuffer
(
GL_FRAMEBUFFER
,
fbo
);
glFramebufferTextureLayer
(
GL_FRAMEBUFFER
,
GL_COLOR_ATTACHMENT0
,
texture
,
0
,
zSlice
);
out
->
readFB
(
0
,
0
);
}
PixelRect
mFBData
;
GLuint
mProgram
;
};
class
WebGL2ReadOutsideFramebufferTest
:
public
WebGLReadOutsideFramebufferTest
{
};
// TODO(fjhenigman): Enable each test as part of a CL that lets the test pass.
// Check that readPixels does not set a destination pixel when
// the corresponding source pixel is outside the framebuffer.
TEST_P
(
WebGLReadOutsideFramebufferTest
,
ReadPixels
)
{
Main
(
&
WebGLReadOutsideFramebufferTest
::
TestReadPixels
,
false
);
Main
2D
(
&
WebGLReadOutsideFramebufferTest
::
TestReadPixels
,
false
);
}
// Check that copyTexSubImage2D does not set a destination pixel when
...
...
@@ -270,7 +335,7 @@ TEST_P(WebGLReadOutsideFramebufferTest, CopyTexSubImage2D)
return
;
}
Main
(
&
WebGLReadOutsideFramebufferTest
::
TestCopyTexSubImage2D
,
false
);
Main
2D
(
&
WebGLReadOutsideFramebufferTest
::
TestCopyTexSubImage2D
,
false
);
}
// Check that copyTexImage2D sets (0,0,0,0) for pixels outside the framebuffer.
...
...
@@ -283,7 +348,21 @@ TEST_P(WebGLReadOutsideFramebufferTest, CopyTexImage2D)
return
;
}
Main
(
&
WebGLReadOutsideFramebufferTest
::
TestCopyTexImage2D
,
true
);
Main2D
(
&
WebGLReadOutsideFramebufferTest
::
TestCopyTexImage2D
,
true
);
}
// Check that copyTexSubImage3D does not set a destination pixel when
// the corresponding source pixel is outside the framebuffer.
TEST_P
(
WebGL2ReadOutsideFramebufferTest
,
CopyTexSubImage3D
)
{
if
(
IsDesktopOpenGL
()
||
IsOpenGLES
())
{
std
::
cout
<<
"Robust CopyTexSubImage3D behaviour is not implemented on OpenGL."
<<
std
::
endl
;
return
;
}
Main3D
(
&
WebGLReadOutsideFramebufferTest
::
TestCopyTexSubImage3D
,
false
);
}
ANGLE_INSTANTIATE_TEST
(
WebGLReadOutsideFramebufferTest
,
...
...
@@ -296,4 +375,10 @@ ANGLE_INSTANTIATE_TEST(WebGLReadOutsideFramebufferTest,
ES2_OPENGLES
(),
ES3_OPENGLES
());
ANGLE_INSTANTIATE_TEST
(
WebGL2ReadOutsideFramebufferTest
,
ES3_D3D11
(),
ES3_OPENGL
(),
ES2_OPENGLES
(),
ES3_OPENGLES
());
}
// namespace
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment