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
1beb1db8
Commit
1beb1db8
authored
Sep 18, 2013
by
Jamie Madill
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enable unpack buffer support for initializing 2D textures in TexImage2D.
TRAC #23843 Signed-off-by: Geoff Lang Signed-off-by: Shannon Woods
parent
efb2a6ff
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
3 deletions
+51
-3
Texture.cpp
src/libGLESv2/Texture.cpp
+49
-3
Texture.h
src/libGLESv2/Texture.h
+2
-0
No files found.
src/libGLESv2/Texture.cpp
View file @
1beb1db8
...
@@ -21,6 +21,8 @@
...
@@ -21,6 +21,8 @@
#include "libGLESv2/renderer/Renderer.h"
#include "libGLESv2/renderer/Renderer.h"
#include "libGLESv2/renderer/TextureStorage.h"
#include "libGLESv2/renderer/TextureStorage.h"
#include "libEGL/Surface.h"
#include "libEGL/Surface.h"
#include "libGLESv2/Buffer.h"
#include "libGLESv2/renderer/BufferStorage.h"
namespace
gl
namespace
gl
{
{
...
@@ -273,13 +275,46 @@ void Texture::setImage(const PixelUnpackState &unpack, GLenum type, const void *
...
@@ -273,13 +275,46 @@ void Texture::setImage(const PixelUnpackState &unpack, GLenum type, const void *
{
{
// We no longer need the "GLenum format" parameter to TexImage to determine what data format "pixels" contains.
// We no longer need the "GLenum format" parameter to TexImage to determine what data format "pixels" contains.
// From our image internal format we know how many channels to expect, and "type" gives the format of pixel's components.
// From our image internal format we know how many channels to expect, and "type" gives the format of pixel's components.
if
(
pixels
!=
NULL
)
const
void
*
pixelData
=
pixels
;
if
(
unpack
.
pixelBuffer
.
id
()
!=
0
)
{
// Do a CPU readback here, if we have an unpack buffer bound and the fast GPU path is not supported
Buffer
*
pixelBuffer
=
unpack
.
pixelBuffer
.
get
();
ptrdiff_t
offset
=
reinterpret_cast
<
ptrdiff_t
>
(
pixels
);
const
void
*
bufferData
=
pixelBuffer
->
getStorage
()
->
getData
();
pixelData
=
static_cast
<
const
unsigned
char
*>
(
bufferData
)
+
offset
;
}
if
(
pixelData
!=
NULL
)
{
{
image
->
loadData
(
0
,
0
,
0
,
image
->
getWidth
(),
image
->
getHeight
(),
image
->
getDepth
(),
unpack
.
alignment
,
type
,
pixel
s
);
image
->
loadData
(
0
,
0
,
0
,
image
->
getWidth
(),
image
->
getHeight
(),
image
->
getDepth
(),
unpack
.
alignment
,
type
,
pixel
Data
);
mDirtyImages
=
true
;
mDirtyImages
=
true
;
}
}
}
}
bool
Texture
::
fastUnpackPixels
(
const
PixelUnpackState
&
unpack
,
const
void
*
pixels
,
const
Box
&
destArea
,
GLenum
sizedInternalFormat
,
GLenum
type
,
GLint
level
)
{
if
(
destArea
.
width
<=
0
&&
destArea
.
height
<=
0
&&
destArea
.
depth
<=
0
)
{
return
true
;
}
// In order to perform the fast copy through the shader, we must have the right format, and be able
// to create a render target.
if
(
IsFastCopyBufferToTextureSupported
(
sizedInternalFormat
,
mRenderer
->
getCurrentClientVersion
()))
{
unsigned
int
offset
=
reinterpret_cast
<
unsigned
int
>
(
pixels
);
rx
::
RenderTarget
*
destRenderTarget
=
getStorage
(
true
)
->
getStorageInstance
()
->
getRenderTarget
(
level
);
return
mRenderer
->
fastCopyBufferToTexture
(
unpack
,
offset
,
destRenderTarget
,
sizedInternalFormat
,
type
,
destArea
);
}
// Return false if we do not support fast unpack
return
false
;
}
void
Texture
::
setCompressedImage
(
GLsizei
imageSize
,
const
void
*
pixels
,
rx
::
Image
*
image
)
void
Texture
::
setCompressedImage
(
GLsizei
imageSize
,
const
void
*
pixels
,
rx
::
Image
*
image
)
{
{
if
(
pixels
!=
NULL
)
if
(
pixels
!=
NULL
)
...
@@ -470,7 +505,18 @@ void Texture2D::setImage(GLint level, GLsizei width, GLsizei height, GLint inter
...
@@ -470,7 +505,18 @@ void Texture2D::setImage(GLint level, GLsizei width, GLsizei height, GLint inter
:
GetSizedInternalFormat
(
format
,
type
,
clientVersion
);
:
GetSizedInternalFormat
(
format
,
type
,
clientVersion
);
redefineImage
(
level
,
sizedInternalFormat
,
width
,
height
);
redefineImage
(
level
,
sizedInternalFormat
,
width
,
height
);
Texture
::
setImage
(
unpack
,
type
,
pixels
,
mImageArray
[
level
]);
// Attempt a fast gpu copy of the pixel data to the surface
// If we want to support rendering (which is necessary for GPU unpack buffers), level 0 must be complete
Box
destArea
(
0
,
0
,
0
,
getWidth
(
level
),
getHeight
(
level
),
1
);
if
(
unpack
.
pixelBuffer
.
id
()
!=
0
&&
isLevelComplete
(
0
)
&&
fastUnpackPixels
(
unpack
,
pixels
,
destArea
,
sizedInternalFormat
,
type
,
level
))
{
// Ensure we don't overwrite our newly initialized data
mImageArray
[
level
]
->
markClean
();
}
else
{
Texture
::
setImage
(
unpack
,
type
,
pixels
,
mImageArray
[
level
]);
}
}
}
void
Texture2D
::
bindTexImage
(
egl
::
Surface
*
surface
)
void
Texture2D
::
bindTexImage
(
egl
::
Surface
*
surface
)
...
...
src/libGLESv2/Texture.h
View file @
1beb1db8
...
@@ -113,6 +113,8 @@ class Texture : public RefCountObject
...
@@ -113,6 +113,8 @@ class Texture : public RefCountObject
void
setCompressedImage
(
GLsizei
imageSize
,
const
void
*
pixels
,
rx
::
Image
*
image
);
void
setCompressedImage
(
GLsizei
imageSize
,
const
void
*
pixels
,
rx
::
Image
*
image
);
bool
subImageCompressed
(
GLint
xoffset
,
GLint
yoffset
,
GLint
zoffset
,
GLsizei
width
,
GLsizei
height
,
GLsizei
depth
,
bool
subImageCompressed
(
GLint
xoffset
,
GLint
yoffset
,
GLint
zoffset
,
GLsizei
width
,
GLsizei
height
,
GLsizei
depth
,
GLenum
format
,
GLsizei
imageSize
,
const
void
*
pixels
,
rx
::
Image
*
image
);
GLenum
format
,
GLsizei
imageSize
,
const
void
*
pixels
,
rx
::
Image
*
image
);
bool
fastUnpackPixels
(
const
PixelUnpackState
&
unpack
,
const
void
*
pixels
,
const
Box
&
destArea
,
GLenum
sizedInternalFormat
,
GLenum
type
,
GLint
level
);
GLint
creationLevels
(
GLsizei
width
,
GLsizei
height
,
GLsizei
depth
)
const
;
GLint
creationLevels
(
GLsizei
width
,
GLsizei
height
,
GLsizei
depth
)
const
;
GLint
creationLevels
(
GLsizei
width
,
GLsizei
height
)
const
;
GLint
creationLevels
(
GLsizei
width
,
GLsizei
height
)
const
;
...
...
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