Partial TexSubImage after FBO rendering overwrites entire image.

TRAC #11439 * Store texel data in IDirect3DSurface9 rather than client memory. * TexSubImage uploads new data immediately. * Fix 5551 texture format conversion. Author: Andrew Lewycky Signed-off-by: Nicolas Capens Signed-off-by: Daniel Koch git-svn-id: https://angleproject.googlecode.com/svn/trunk@53 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent bbb6cd0c
...@@ -55,16 +55,19 @@ class Texture : public Colorbuffer ...@@ -55,16 +55,19 @@ class Texture : public Colorbuffer
// Helper structure representing a single image layer // Helper structure representing a single image layer
struct Image struct Image
{ {
Image();
~Image();
GLsizei width; GLsizei width;
GLsizei height; GLsizei height;
GLenum format; GLenum format;
std::vector<unsigned char> pixels; bool dirty;
};
void copyImage(const D3DLOCKED_RECT &lock, D3DFORMAT format, const Image &image); IDirect3DSurface9 *surface;
};
static D3DFORMAT selectFormat(const Image &image); static D3DFORMAT selectFormat(GLenum format);
static int pixelSize(GLenum format, GLenum type); static int pixelSize(GLenum format, GLenum type);
int imagePitch(const Image& img) const; int imagePitch(const Image& img) const;
...@@ -80,6 +83,8 @@ class Texture : public Colorbuffer ...@@ -80,6 +83,8 @@ class Texture : public Colorbuffer
virtual IDirect3DBaseTexture9 *createTexture() = 0; virtual IDirect3DBaseTexture9 *createTexture() = 0;
virtual void updateTexture() = 0; virtual void updateTexture() = 0;
virtual bool dirtyImageData() const = 0;
bool mDirtyMetaData; // FIXME: would be private but getRenderTarget is still implemented through the derived classes and they need it. bool mDirtyMetaData; // FIXME: would be private but getRenderTarget is still implemented through the derived classes and they need it.
private: private:
...@@ -87,8 +92,6 @@ class Texture : public Colorbuffer ...@@ -87,8 +92,6 @@ class Texture : public Colorbuffer
IDirect3DBaseTexture9 *mBaseTexture; // This is a weak pointer. The derived class is assumed to own a strong pointer. IDirect3DBaseTexture9 *mBaseTexture; // This is a weak pointer. The derived class is assumed to own a strong pointer.
bool mDirtyImageData;
void loadImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, void loadImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type,
const void *input, std::size_t outputPitch, void *output) const; const void *input, std::size_t outputPitch, void *output) const;
}; };
...@@ -114,6 +117,10 @@ class Texture2D : public Texture ...@@ -114,6 +117,10 @@ class Texture2D : public Texture
virtual IDirect3DBaseTexture9 *createTexture(); virtual IDirect3DBaseTexture9 *createTexture();
virtual void updateTexture(); virtual void updateTexture();
virtual bool dirtyImageData() const;
void commitRect(GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height);
Image mImageArray[MAX_TEXTURE_LEVELS]; Image mImageArray[MAX_TEXTURE_LEVELS];
IDirect3DTexture9 *mTexture; IDirect3DTexture9 *mTexture;
...@@ -145,9 +152,12 @@ class TextureCubeMap : public Texture ...@@ -145,9 +152,12 @@ class TextureCubeMap : public Texture
virtual IDirect3DBaseTexture9 *createTexture(); virtual IDirect3DBaseTexture9 *createTexture();
virtual void updateTexture(); virtual void updateTexture();
virtual bool dirtyImageData() const;
static unsigned int faceIndex(GLenum face); static unsigned int faceIndex(GLenum face);
void setImage(int face, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); void setImage(int face, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels);
void commitRect(GLenum faceTarget, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height);
Image mImageArray[6][MAX_TEXTURE_LEVELS]; Image mImageArray[6][MAX_TEXTURE_LEVELS];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment