Commit 50bba309 by Nicolas Capens

Refactor Image creation.

Customize construction for each use case. Bug 26851951 Change-Id: Ic10166bbfeaf11e800fec2a6470446b76e49b825 Reviewed-on: https://swiftshader-review.googlesource.com/4710Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com> Tested-by: 's avatarNicolas Capens <capn@google.com>
parent b2022a76
...@@ -31,16 +31,12 @@ sw::Format SelectInternalFormat(GLenum format, GLenum type); ...@@ -31,16 +31,12 @@ sw::Format SelectInternalFormat(GLenum format, GLenum type);
GLsizei ComputePitch(GLsizei width, GLenum format, GLenum type, GLint alignment); GLsizei ComputePitch(GLsizei width, GLenum format, GLenum type, GLint alignment);
GLsizei ComputeCompressedSize(GLsizei width, GLsizei height, GLenum format); GLsizei ComputeCompressedSize(GLsizei width, GLsizei height, GLenum format);
static inline sw::Resource *getParentResource(egl::Texture *texture)
{
return texture ? texture->getResource() : nullptr;
}
class Image : public sw::Surface, public gl::Object class Image : public sw::Surface, public gl::Object
{ {
public: public:
// 2D texture image
Image(Texture *parentTexture, GLsizei width, GLsizei height, GLenum format, GLenum type) Image(Texture *parentTexture, GLsizei width, GLsizei height, GLenum format, GLenum type)
: sw::Surface(getParentResource(parentTexture), width, height, 1, SelectInternalFormat(format, type), true, true), : sw::Surface(parentTexture->getResource(), width, height, 1, SelectInternalFormat(format, type), true, true),
width(width), height(height), format(format), type(type), internalFormat(SelectInternalFormat(format, type)), depth(1), width(width), height(height), format(format), type(type), internalFormat(SelectInternalFormat(format, type)), depth(1),
parentTexture(parentTexture) parentTexture(parentTexture)
{ {
...@@ -48,8 +44,9 @@ public: ...@@ -48,8 +44,9 @@ public:
Object::addRef(); Object::addRef();
} }
Image(Texture *parentTexture, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, int pitchP = 0) // 3D texture image
: sw::Surface(getParentResource(parentTexture), width, height, depth, SelectInternalFormat(format, type), true, true, pitchP), Image(Texture *parentTexture, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type)
: sw::Surface(parentTexture->getResource(), width, height, depth, SelectInternalFormat(format, type), true, true),
width(width), height(height), format(format), type(type), internalFormat(SelectInternalFormat(format, type)), depth(depth), width(width), height(height), format(format), type(type), internalFormat(SelectInternalFormat(format, type)), depth(depth),
parentTexture(parentTexture) parentTexture(parentTexture)
{ {
...@@ -57,9 +54,21 @@ public: ...@@ -57,9 +54,21 @@ public:
Object::addRef(); Object::addRef();
} }
Image(GLsizei width, GLsizei height, sw::Format internalFormat, int multiSampleDepth, bool lockable, bool renderTarget) // Native EGL image
: sw::Surface(nullptr, width, height, multiSampleDepth, internalFormat, lockable, renderTarget), Image(GLsizei width, GLsizei height, GLenum format, GLenum type, int pitchP)
width(width), height(height), format(0 /*GL_NONE*/), type(0 /*GL_NONE*/), internalFormat(internalFormat), depth(multiSampleDepth), parentTexture(nullptr) : sw::Surface(nullptr, width, height, depth, SelectInternalFormat(format, type), true, true, pitchP),
width(width), height(height), format(format), type(type), internalFormat(SelectInternalFormat(format, type)), depth(depth),
parentTexture(nullptr)
{
shared = true;
Object::addRef();
}
// Render target
Image(GLsizei width, GLsizei height, sw::Format internalFormat, int multiSampleDepth, bool lockable)
: sw::Surface(nullptr, width, height, multiSampleDepth, internalFormat, lockable, true),
width(width), height(height), format(0 /*GL_NONE*/), type(0 /*GL_NONE*/), internalFormat(internalFormat), depth(multiSampleDepth),
parentTexture(nullptr)
{ {
shared = false; shared = false;
Object::addRef(); Object::addRef();
...@@ -206,14 +215,13 @@ class AndroidNativeImage : public egl::Image ...@@ -206,14 +215,13 @@ class AndroidNativeImage : public egl::Image
{ {
public: public:
explicit AndroidNativeImage(ANativeWindowBuffer *nativeBuffer) explicit AndroidNativeImage(ANativeWindowBuffer *nativeBuffer)
: egl::Image(0, nativeBuffer->width, nativeBuffer->height, 1, : egl::Image(nativeBuffer->width, nativeBuffer->height,
GLPixelFormatFromAndroid(nativeBuffer->format), GLPixelFormatFromAndroid(nativeBuffer->format),
GLPixelTypeFromAndroid(nativeBuffer->format), GLPixelTypeFromAndroid(nativeBuffer->format),
nativeBuffer->stride), nativeBuffer->stride),
nativeBuffer(nativeBuffer) nativeBuffer(nativeBuffer)
{ {
nativeBuffer->common.incRef(&nativeBuffer->common); nativeBuffer->common.incRef(&nativeBuffer->common);
markShared();
} }
private: private:
......
...@@ -223,7 +223,7 @@ namespace es1 ...@@ -223,7 +223,7 @@ namespace es1
if(height > OUTLINE_RESOLUTION) if(height > OUTLINE_RESOLUTION)
{ {
ERR("Invalid parameters: %dx%d", width, height); ERR("Invalid parameters: %dx%d", width, height);
return 0; return nullptr;
} }
bool lockable = true; bool lockable = true;
...@@ -251,12 +251,12 @@ namespace es1 ...@@ -251,12 +251,12 @@ namespace es1
UNREACHABLE(format); UNREACHABLE(format);
} }
egl::Image *surface = new egl::Image(width, height, format, multiSampleDepth, lockable, true); egl::Image *surface = new egl::Image(width, height, format, multiSampleDepth, lockable);
if(!surface) if(!surface)
{ {
ERR("Out of memory"); ERR("Out of memory");
return 0; return nullptr;
} }
return surface; return surface;
...@@ -267,15 +267,15 @@ namespace es1 ...@@ -267,15 +267,15 @@ namespace es1
if(height > OUTLINE_RESOLUTION) if(height > OUTLINE_RESOLUTION)
{ {
ERR("Invalid parameters: %dx%d", width, height); ERR("Invalid parameters: %dx%d", width, height);
return 0; return nullptr;
} }
egl::Image *surface = new egl::Image(width, height, format, multiSampleDepth, lockable, true); egl::Image *surface = new egl::Image(width, height, format, multiSampleDepth, lockable);
if(!surface) if(!surface)
{ {
ERR("Out of memory"); ERR("Out of memory");
return 0; return nullptr;
} }
return surface; return surface;
......
...@@ -333,12 +333,12 @@ Texture2D::Texture2D(GLuint name) : Texture(name) ...@@ -333,12 +333,12 @@ Texture2D::Texture2D(GLuint name) : Texture(name)
{ {
for(int i = 0; i < MIPMAP_LEVELS; i++) for(int i = 0; i < MIPMAP_LEVELS; i++)
{ {
image[i] = 0; image[i] = nullptr;
} }
mSurface = NULL; mSurface = nullptr;
mColorbufferProxy = NULL; mColorbufferProxy = nullptr;
mProxyRefs = 0; mProxyRefs = 0;
} }
...@@ -351,7 +351,7 @@ Texture2D::~Texture2D() ...@@ -351,7 +351,7 @@ Texture2D::~Texture2D()
if(image[i]) if(image[i])
{ {
image[i]->unbind(this); image[i]->unbind(this);
image[i] = 0; image[i] = nullptr;
} }
} }
...@@ -359,11 +359,11 @@ Texture2D::~Texture2D() ...@@ -359,11 +359,11 @@ Texture2D::~Texture2D()
if(mSurface) if(mSurface)
{ {
mSurface->setBoundTexture(NULL); mSurface->setBoundTexture(nullptr);
mSurface = NULL; mSurface = nullptr;
} }
mColorbufferProxy = NULL; mColorbufferProxy = nullptr;
} }
// We need to maintain a count of references to renderbuffers acting as // We need to maintain a count of references to renderbuffers acting as
...@@ -383,7 +383,7 @@ void Texture2D::releaseProxy(const Renderbuffer *proxy) ...@@ -383,7 +383,7 @@ void Texture2D::releaseProxy(const Renderbuffer *proxy)
if(mProxyRefs == 0) if(mProxyRefs == 0)
{ {
mColorbufferProxy = NULL; mColorbufferProxy = nullptr;
} }
} }
...@@ -478,7 +478,7 @@ void Texture2D::bindTexImage(egl::Surface *surface) ...@@ -478,7 +478,7 @@ void Texture2D::bindTexImage(egl::Surface *surface)
if(image[level]) if(image[level])
{ {
image[level]->unbind(this); image[level]->unbind(this);
image[level] = 0; image[level] = nullptr;
} }
} }
...@@ -495,7 +495,7 @@ void Texture2D::releaseTexImage() ...@@ -495,7 +495,7 @@ void Texture2D::releaseTexImage()
if(image[level]) if(image[level])
{ {
image[level]->unbind(this); image[level]->unbind(this);
image[level] = 0; image[level] = nullptr;
} }
} }
} }
...@@ -721,10 +721,10 @@ Renderbuffer *Texture2D::getRenderbuffer(GLenum target) ...@@ -721,10 +721,10 @@ Renderbuffer *Texture2D::getRenderbuffer(GLenum target)
{ {
if(target != GL_TEXTURE_2D) if(target != GL_TEXTURE_2D)
{ {
return error(GL_INVALID_OPERATION, (Renderbuffer *)NULL); return error(GL_INVALID_OPERATION, (Renderbuffer*)nullptr);
} }
if(mColorbufferProxy == NULL) if(!mColorbufferProxy)
{ {
mColorbufferProxy = new Renderbuffer(name, new RenderbufferTexture2D(this)); mColorbufferProxy = new Renderbuffer(name, new RenderbufferTexture2D(this));
} }
...@@ -786,10 +786,10 @@ egl::Image *createBackBuffer(int width, int height, const egl::Config *config) ...@@ -786,10 +786,10 @@ egl::Image *createBackBuffer(int width, int height, const egl::Config *config)
{ {
if(config) if(config)
{ {
return new egl::Image(width, height, config->mRenderTargetFormat, config->mSamples, false, true); return new egl::Image(width, height, config->mRenderTargetFormat, config->mSamples, false);
} }
return 0; return nullptr;
} }
egl::Image *createDepthStencil(unsigned int width, unsigned int height, sw::Format format, int multiSampleDepth, bool discard) egl::Image *createDepthStencil(unsigned int width, unsigned int height, sw::Format format, int multiSampleDepth, bool discard)
...@@ -825,12 +825,12 @@ egl::Image *createDepthStencil(unsigned int width, unsigned int height, sw::Form ...@@ -825,12 +825,12 @@ egl::Image *createDepthStencil(unsigned int width, unsigned int height, sw::Form
UNREACHABLE(format); UNREACHABLE(format);
} }
egl::Image *surface = new egl::Image(width, height, format, multiSampleDepth, lockable, true); egl::Image *surface = new egl::Image(width, height, format, multiSampleDepth, lockable);
if(!surface) if(!surface)
{ {
ERR("Out of memory"); ERR("Out of memory");
return 0; return nullptr;
} }
return surface; return surface;
......
...@@ -143,13 +143,13 @@ namespace es2 ...@@ -143,13 +143,13 @@ namespace es2
} }
Device::~Device() Device::~Device()
{ {
if(depthStencil) if(depthStencil)
{ {
depthStencil->release(); depthStencil->release();
depthStencil = nullptr; depthStencil = nullptr;
} }
for(int i = 0; i < RENDERTARGETS; ++i) for(int i = 0; i < RENDERTARGETS; ++i)
{ {
if(renderTarget[i]) if(renderTarget[i])
...@@ -219,7 +219,7 @@ namespace es2 ...@@ -219,7 +219,7 @@ namespace es2
int x0(0), y0(0), width(0), height(0); int x0(0), y0(0), width(0), height(0);
getScissoredRegion(depthStencil, x0, y0, width, height); getScissoredRegion(depthStencil, x0, y0, width, height);
depthStencil->clearDepthBuffer(z, x0, y0, width, height); depthStencil->clearDepthBuffer(z, x0, y0, width, height);
} }
...@@ -241,9 +241,9 @@ namespace es2 ...@@ -241,9 +241,9 @@ namespace es2
if(height > OUTLINE_RESOLUTION) if(height > OUTLINE_RESOLUTION)
{ {
ERR("Invalid parameters: %dx%d", width, height); ERR("Invalid parameters: %dx%d", width, height);
return 0; return nullptr;
} }
bool lockable = true; bool lockable = true;
switch(format) switch(format)
...@@ -269,12 +269,12 @@ namespace es2 ...@@ -269,12 +269,12 @@ namespace es2
UNREACHABLE(format); UNREACHABLE(format);
} }
egl::Image *surface = new egl::Image(width, height, format, multiSampleDepth, lockable, true); egl::Image *surface = new egl::Image(width, height, format, multiSampleDepth, lockable);
if(!surface) if(!surface)
{ {
ERR("Out of memory"); ERR("Out of memory");
return 0; return nullptr;
} }
return surface; return surface;
...@@ -285,17 +285,17 @@ namespace es2 ...@@ -285,17 +285,17 @@ namespace es2
if(height > OUTLINE_RESOLUTION) if(height > OUTLINE_RESOLUTION)
{ {
ERR("Invalid parameters: %dx%d", width, height); ERR("Invalid parameters: %dx%d", width, height);
return 0; return nullptr;
} }
egl::Image *surface = new egl::Image(width, height, format, multiSampleDepth, lockable, true); egl::Image *surface = new egl::Image(width, height, format, multiSampleDepth, lockable);
if(!surface) if(!surface)
{ {
ERR("Out of memory"); ERR("Out of memory");
return 0; return nullptr;
} }
return surface; return surface;
} }
...@@ -405,7 +405,7 @@ namespace es2 ...@@ -405,7 +405,7 @@ namespace es2
vertexShaderConstantF[startRegister + i][2] = constantData[i * 4 + 2]; vertexShaderConstantF[startRegister + i][2] = constantData[i * 4 + 2];
vertexShaderConstantF[startRegister + i][3] = constantData[i * 4 + 3]; vertexShaderConstantF[startRegister + i][3] = constantData[i * 4 + 3];
} }
vertexShaderConstantsFDirty = max(startRegister + count, vertexShaderConstantsFDirty); vertexShaderConstantsFDirty = max(startRegister + count, vertexShaderConstantsFDirty);
vertexShaderDirty = true; // Reload DEF constants vertexShaderDirty = true; // Reload DEF constants
} }
...@@ -471,7 +471,7 @@ namespace es2 ...@@ -471,7 +471,7 @@ namespace es2
ERR("Invalid parameters"); ERR("Invalid parameters");
return false; return false;
} }
int sWidth = source->getWidth(); int sWidth = source->getWidth();
int sHeight = source->getHeight(); int sHeight = source->getHeight();
int dWidth = dest->getWidth(); int dWidth = dest->getWidth();
...@@ -732,7 +732,7 @@ namespace es2 ...@@ -732,7 +732,7 @@ namespace es2
{ {
Renderer::setVertexShaderConstantF(0, vertexShaderConstantF[0], vertexShaderConstantsFDirty); Renderer::setVertexShaderConstantF(0, vertexShaderConstantF[0], vertexShaderConstantsFDirty);
} }
Renderer::setVertexShader(vertexShader); // Loads shader constants set with DEF Renderer::setVertexShader(vertexShader); // Loads shader constants set with DEF
vertexShaderConstantsFDirty = vertexShader->dirtyConstantsF; // Shader DEF'ed constants are dirty vertexShaderConstantsFDirty = vertexShader->dirtyConstantsF; // Shader DEF'ed constants are dirty
} }
...@@ -744,7 +744,7 @@ namespace es2 ...@@ -744,7 +744,7 @@ namespace es2
vertexShaderDirty = false; vertexShaderDirty = false;
} }
} }
bool Device::bindViewport() bool Device::bindViewport()
{ {
if(viewport.width <= 0 || viewport.height <= 0) if(viewport.width <= 0 || viewport.height <= 0)
...@@ -764,7 +764,7 @@ namespace es2 ...@@ -764,7 +764,7 @@ namespace es2
scissor.x1 = scissorRect.x1; scissor.x1 = scissorRect.x1;
scissor.y0 = scissorRect.y0; scissor.y0 = scissorRect.y0;
scissor.y1 = scissorRect.y1; scissor.y1 = scissorRect.y1;
setScissor(scissor); setScissor(scissor);
} }
else else
...@@ -774,7 +774,7 @@ namespace es2 ...@@ -774,7 +774,7 @@ namespace es2
scissor.x1 = viewport.x0 + viewport.width; scissor.x1 = viewport.x0 + viewport.width;
scissor.y0 = viewport.y0; scissor.y0 = viewport.y0;
scissor.y1 = viewport.y0 + viewport.height; scissor.y1 = viewport.y0 + viewport.height;
for(int i = 0; i < RENDERTARGETS; ++i) for(int i = 0; i < RENDERTARGETS; ++i)
{ {
if(renderTarget[i]) if(renderTarget[i])
...@@ -804,7 +804,7 @@ namespace es2 ...@@ -804,7 +804,7 @@ namespace es2
view.height = (float)viewport.height; view.height = (float)viewport.height;
view.minZ = viewport.minZ; view.minZ = viewport.minZ;
view.maxZ = viewport.maxZ; view.maxZ = viewport.maxZ;
Renderer::setViewport(view); Renderer::setViewport(view);
return true; return true;
......
...@@ -167,7 +167,7 @@ bool Texture::setMaxAnisotropy(float textureMaxAnisotropy) ...@@ -167,7 +167,7 @@ bool Texture::setMaxAnisotropy(float textureMaxAnisotropy)
{ {
return false; return false;
} }
if(mMaxAnisotropy != textureMaxAnisotropy) if(mMaxAnisotropy != textureMaxAnisotropy)
{ {
mMaxAnisotropy = textureMaxAnisotropy; mMaxAnisotropy = textureMaxAnisotropy;
...@@ -470,7 +470,7 @@ void Texture::subImageCompressed(GLint xoffset, GLint yoffset, GLint zoffset, GL ...@@ -470,7 +470,7 @@ void Texture::subImageCompressed(GLint xoffset, GLint yoffset, GLint zoffset, GL
bool Texture::copy(egl::Image *source, const sw::SliceRect &sourceRect, GLenum destFormat, GLint xoffset, GLint yoffset, GLint zoffset, egl::Image *dest) bool Texture::copy(egl::Image *source, const sw::SliceRect &sourceRect, GLenum destFormat, GLint xoffset, GLint yoffset, GLint zoffset, egl::Image *dest)
{ {
Device *device = getDevice(); Device *device = getDevice();
sw::SliceRect destRect(xoffset, yoffset, xoffset + (sourceRect.x1 - sourceRect.x0), yoffset + (sourceRect.y1 - sourceRect.y0), zoffset); sw::SliceRect destRect(xoffset, yoffset, xoffset + (sourceRect.x1 - sourceRect.x0), yoffset + (sourceRect.y1 - sourceRect.y0), zoffset);
bool success = device->stretchRect(source, &sourceRect, dest, &destRect, false); bool success = device->stretchRect(source, &sourceRect, dest, &destRect, false);
...@@ -504,12 +504,12 @@ Texture2D::Texture2D(GLuint name) : Texture(name) ...@@ -504,12 +504,12 @@ Texture2D::Texture2D(GLuint name) : Texture(name)
{ {
for(int i = 0; i < MIPMAP_LEVELS; i++) for(int i = 0; i < MIPMAP_LEVELS; i++)
{ {
image[i] = 0; image[i] = nullptr;
} }
mSurface = NULL; mSurface = nullptr;
mColorbufferProxy = NULL; mColorbufferProxy = nullptr;
mProxyRefs = 0; mProxyRefs = 0;
} }
...@@ -522,7 +522,7 @@ Texture2D::~Texture2D() ...@@ -522,7 +522,7 @@ Texture2D::~Texture2D()
if(image[i]) if(image[i])
{ {
image[i]->unbind(this); image[i]->unbind(this);
image[i] = 0; image[i] = nullptr;
} }
} }
...@@ -530,15 +530,15 @@ Texture2D::~Texture2D() ...@@ -530,15 +530,15 @@ Texture2D::~Texture2D()
if(mSurface) if(mSurface)
{ {
mSurface->setBoundTexture(NULL); mSurface->setBoundTexture(nullptr);
mSurface = NULL; mSurface = nullptr;
} }
mColorbufferProxy = NULL; mColorbufferProxy = nullptr;
} }
// We need to maintain a count of references to renderbuffers acting as // We need to maintain a count of references to renderbuffers acting as
// proxies for this texture, so that we do not attempt to use a pointer // proxies for this texture, so that we do not attempt to use a pointer
// to a renderbuffer proxy which has been deleted. // to a renderbuffer proxy which has been deleted.
void Texture2D::addProxyRef(const Renderbuffer *proxy) void Texture2D::addProxyRef(const Renderbuffer *proxy)
{ {
...@@ -554,7 +554,7 @@ void Texture2D::releaseProxy(const Renderbuffer *proxy) ...@@ -554,7 +554,7 @@ void Texture2D::releaseProxy(const Renderbuffer *proxy)
if(mProxyRefs == 0) if(mProxyRefs == 0)
{ {
mColorbufferProxy = NULL; mColorbufferProxy = nullptr;
} }
} }
...@@ -649,7 +649,7 @@ void Texture2D::bindTexImage(egl::Surface *surface) ...@@ -649,7 +649,7 @@ void Texture2D::bindTexImage(egl::Surface *surface)
if(image[level]) if(image[level])
{ {
image[level]->unbind(this); image[level]->unbind(this);
image[level] = 0; image[level] = nullptr;
} }
} }
...@@ -666,7 +666,7 @@ void Texture2D::releaseTexImage() ...@@ -666,7 +666,7 @@ void Texture2D::releaseTexImage()
if(image[level]) if(image[level])
{ {
image[level]->unbind(this); image[level]->unbind(this);
image[level] = 0; image[level] = nullptr;
} }
} }
} }
...@@ -878,7 +878,7 @@ void Texture2D::generateMipmaps() ...@@ -878,7 +878,7 @@ void Texture2D::generateMipmaps()
} }
unsigned int q = log2(std::max(image[0]->getWidth(), image[0]->getHeight())); unsigned int q = log2(std::max(image[0]->getWidth(), image[0]->getHeight()));
for(unsigned int i = 1; i <= q; i++) for(unsigned int i = 1; i <= q; i++)
{ {
if(image[i]) if(image[i])
...@@ -906,10 +906,10 @@ Renderbuffer *Texture2D::getRenderbuffer(GLenum target, GLint level, GLint layer ...@@ -906,10 +906,10 @@ Renderbuffer *Texture2D::getRenderbuffer(GLenum target, GLint level, GLint layer
{ {
if(target != GL_TEXTURE_2D) if(target != GL_TEXTURE_2D)
{ {
return error(GL_INVALID_OPERATION, (Renderbuffer *)NULL); return error(GL_INVALID_OPERATION, (Renderbuffer*)nullptr);
} }
if(mColorbufferProxy == NULL) if(!mColorbufferProxy)
{ {
mColorbufferProxy = new Renderbuffer(name, new RenderbufferTexture2D(this, level)); mColorbufferProxy = new Renderbuffer(name, new RenderbufferTexture2D(this, level));
} }
...@@ -954,13 +954,13 @@ TextureCubeMap::TextureCubeMap(GLuint name) : Texture(name) ...@@ -954,13 +954,13 @@ TextureCubeMap::TextureCubeMap(GLuint name) : Texture(name)
{ {
for(int i = 0; i < MIPMAP_LEVELS; i++) for(int i = 0; i < MIPMAP_LEVELS; i++)
{ {
image[f][i] = 0; image[f][i] = nullptr;
} }
} }
for(int f = 0; f < 6; f++) for(int f = 0; f < 6; f++)
{ {
mFaceProxies[f] = NULL; mFaceProxies[f] = nullptr;
mFaceProxyRefs[f] = 0; mFaceProxyRefs[f] = 0;
} }
} }
...@@ -976,7 +976,7 @@ TextureCubeMap::~TextureCubeMap() ...@@ -976,7 +976,7 @@ TextureCubeMap::~TextureCubeMap()
if(image[f][i]) if(image[f][i])
{ {
image[f][i]->unbind(this); image[f][i]->unbind(this);
image[f][i] = 0; image[f][i] = nullptr;
} }
} }
} }
...@@ -985,14 +985,14 @@ TextureCubeMap::~TextureCubeMap() ...@@ -985,14 +985,14 @@ TextureCubeMap::~TextureCubeMap()
for(int i = 0; i < 6; i++) for(int i = 0; i < 6; i++)
{ {
mFaceProxies[i] = NULL; mFaceProxies[i] = nullptr;
} }
} }
// We need to maintain a count of references to renderbuffers acting as // We need to maintain a count of references to renderbuffers acting as
// proxies for this texture, so that the texture is not deleted while // proxies for this texture, so that the texture is not deleted while
// proxy references still exist. If the reference count drops to zero, // proxy references still exist. If the reference count drops to zero,
// we set our proxy pointer NULL, so that a new attempt at referencing // we set our proxy pointer null, so that a new attempt at referencing
// will cause recreation. // will cause recreation.
void TextureCubeMap::addProxyRef(const Renderbuffer *proxy) void TextureCubeMap::addProxyRef(const Renderbuffer *proxy)
{ {
...@@ -1018,7 +1018,7 @@ void TextureCubeMap::releaseProxy(const Renderbuffer *proxy) ...@@ -1018,7 +1018,7 @@ void TextureCubeMap::releaseProxy(const Renderbuffer *proxy)
if(mFaceProxyRefs[f] == 0) if(mFaceProxyRefs[f] == 0)
{ {
mFaceProxies[f] = NULL; mFaceProxies[f] = nullptr;
} }
} }
} }
...@@ -1270,7 +1270,7 @@ void TextureCubeMap::copyImage(GLenum target, GLint level, GLenum format, GLint ...@@ -1270,7 +1270,7 @@ void TextureCubeMap::copyImage(GLenum target, GLint level, GLenum format, GLint
sw::SliceRect sourceRect(x, y, x + width, y + height, 0); sw::SliceRect sourceRect(x, y, x + width, y + height, 0);
sourceRect.clip(0, 0, renderbuffer->getWidth(), renderbuffer->getHeight()); sourceRect.clip(0, 0, renderbuffer->getWidth(), renderbuffer->getHeight());
copy(renderTarget, sourceRect, sizedInternalFormat, 0, 0, 0, image[face][level]); copy(renderTarget, sourceRect, sizedInternalFormat, 0, 0, 0, image[face][level]);
} }
...@@ -1361,12 +1361,12 @@ Renderbuffer *TextureCubeMap::getRenderbuffer(GLenum target, GLint level, GLint ...@@ -1361,12 +1361,12 @@ Renderbuffer *TextureCubeMap::getRenderbuffer(GLenum target, GLint level, GLint
{ {
if(!IsCubemapTextureTarget(target)) if(!IsCubemapTextureTarget(target))
{ {
return error(GL_INVALID_OPERATION, (Renderbuffer *)NULL); return error(GL_INVALID_OPERATION, (Renderbuffer*)nullptr);
} }
int face = CubeFaceIndex(target); int face = CubeFaceIndex(target);
if(mFaceProxies[face] == NULL) if(!mFaceProxies[face])
{ {
mFaceProxies[face] = new Renderbuffer(name, new RenderbufferTextureCubeMap(this, target, level)); mFaceProxies[face] = new Renderbuffer(name, new RenderbufferTextureCubeMap(this, target, level));
} }
...@@ -1378,7 +1378,7 @@ egl::Image *TextureCubeMap::getRenderTarget(GLenum target, unsigned int level) ...@@ -1378,7 +1378,7 @@ egl::Image *TextureCubeMap::getRenderTarget(GLenum target, unsigned int level)
{ {
ASSERT(IsCubemapTextureTarget(target)); ASSERT(IsCubemapTextureTarget(target));
ASSERT(level < IMPLEMENTATION_MAX_TEXTURE_LEVELS); ASSERT(level < IMPLEMENTATION_MAX_TEXTURE_LEVELS);
int face = CubeFaceIndex(target); int face = CubeFaceIndex(target);
if(image[face][level]) if(image[face][level])
...@@ -1408,12 +1408,12 @@ Texture3D::Texture3D(GLuint name) : Texture(name) ...@@ -1408,12 +1408,12 @@ Texture3D::Texture3D(GLuint name) : Texture(name)
{ {
for(int i = 0; i < MIPMAP_LEVELS; i++) for(int i = 0; i < MIPMAP_LEVELS; i++)
{ {
image[i] = 0; image[i] = nullptr;
} }
mSurface = NULL; mSurface = nullptr;
mColorbufferProxy = NULL; mColorbufferProxy = nullptr;
mProxyRefs = 0; mProxyRefs = 0;
} }
...@@ -1426,7 +1426,7 @@ Texture3D::~Texture3D() ...@@ -1426,7 +1426,7 @@ Texture3D::~Texture3D()
if(image[i]) if(image[i])
{ {
image[i]->unbind(this); image[i]->unbind(this);
image[i] = 0; image[i] = nullptr;
} }
} }
...@@ -1434,15 +1434,15 @@ Texture3D::~Texture3D() ...@@ -1434,15 +1434,15 @@ Texture3D::~Texture3D()
if(mSurface) if(mSurface)
{ {
mSurface->setBoundTexture(NULL); mSurface->setBoundTexture(nullptr);
mSurface = NULL; mSurface = nullptr;
} }
mColorbufferProxy = NULL; mColorbufferProxy = nullptr;
} }
// We need to maintain a count of references to renderbuffers acting as // We need to maintain a count of references to renderbuffers acting as
// proxies for this texture, so that we do not attempt to use a pointer // proxies for this texture, so that we do not attempt to use a pointer
// to a renderbuffer proxy which has been deleted. // to a renderbuffer proxy which has been deleted.
void Texture3D::addProxyRef(const Renderbuffer *proxy) void Texture3D::addProxyRef(const Renderbuffer *proxy)
{ {
...@@ -1458,7 +1458,7 @@ void Texture3D::releaseProxy(const Renderbuffer *proxy) ...@@ -1458,7 +1458,7 @@ void Texture3D::releaseProxy(const Renderbuffer *proxy)
if(mProxyRefs == 0) if(mProxyRefs == 0)
{ {
mColorbufferProxy = NULL; mColorbufferProxy = nullptr;
} }
} }
...@@ -1555,7 +1555,7 @@ void Texture3D::bindTexImage(egl::Surface *surface) ...@@ -1555,7 +1555,7 @@ void Texture3D::bindTexImage(egl::Surface *surface)
if(image[level]) if(image[level])
{ {
image[level]->unbind(this); image[level]->unbind(this);
image[level] = 0; image[level] = nullptr;
} }
} }
...@@ -1572,7 +1572,7 @@ void Texture3D::releaseTexImage() ...@@ -1572,7 +1572,7 @@ void Texture3D::releaseTexImage()
if(image[level]) if(image[level])
{ {
image[level]->unbind(this); image[level]->unbind(this);
image[level] = 0; image[level] = nullptr;
} }
} }
} }
...@@ -1819,10 +1819,10 @@ Renderbuffer *Texture3D::getRenderbuffer(GLenum target, GLint level, GLint layer ...@@ -1819,10 +1819,10 @@ Renderbuffer *Texture3D::getRenderbuffer(GLenum target, GLint level, GLint layer
{ {
if(target != getTarget()) if(target != getTarget())
{ {
return error(GL_INVALID_OPERATION, (Renderbuffer *)NULL); return error(GL_INVALID_OPERATION, (Renderbuffer*)nullptr);
} }
if(mColorbufferProxy == NULL) if(!mColorbufferProxy)
{ {
mColorbufferProxy = new Renderbuffer(name, new RenderbufferTexture3D(this, level, layer)); mColorbufferProxy = new Renderbuffer(name, new RenderbufferTexture3D(this, level, layer));
} }
...@@ -1935,10 +1935,10 @@ egl::Image *createBackBuffer(int width, int height, const egl::Config *config) ...@@ -1935,10 +1935,10 @@ egl::Image *createBackBuffer(int width, int height, const egl::Config *config)
{ {
if(config) if(config)
{ {
return new egl::Image(width, height, config->mRenderTargetFormat, config->mSamples, false, true); return new egl::Image(width, height, config->mRenderTargetFormat, config->mSamples, false);
} }
return 0; return nullptr;
} }
egl::Image *createDepthStencil(unsigned int width, unsigned int height, sw::Format format, int multiSampleDepth, bool discard) egl::Image *createDepthStencil(unsigned int width, unsigned int height, sw::Format format, int multiSampleDepth, bool discard)
...@@ -1948,7 +1948,7 @@ egl::Image *createDepthStencil(unsigned int width, unsigned int height, sw::Form ...@@ -1948,7 +1948,7 @@ egl::Image *createDepthStencil(unsigned int width, unsigned int height, sw::Form
ERR("Invalid parameters: %dx%d", width, height); ERR("Invalid parameters: %dx%d", width, height);
return 0; return 0;
} }
bool lockable = true; bool lockable = true;
switch(format) switch(format)
...@@ -1974,12 +1974,12 @@ egl::Image *createDepthStencil(unsigned int width, unsigned int height, sw::Form ...@@ -1974,12 +1974,12 @@ egl::Image *createDepthStencil(unsigned int width, unsigned int height, sw::Form
UNREACHABLE(format); UNREACHABLE(format);
} }
egl::Image *surface = new egl::Image(width, height, format, multiSampleDepth, lockable, true); egl::Image *surface = new egl::Image(width, height, format, multiSampleDepth, lockable);
if(!surface) if(!surface)
{ {
ERR("Out of memory"); ERR("Out of memory");
return 0; return nullptr;
} }
return surface; return surface;
......
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