Adding Texture3D support. Bug 19126833 Added Texture3D argument verifications. Added the basic API and functions. A few are still unimplemented: - Image::loadCompressedData() (for depth other than 1) - Texture3D::copyImage() - Texture3D::generateMipmaps() Added colour grading test for 3D texture Change-Id: I9e52afa7213999f94c5916c2f301fc6fa4b42c0d Reviewed-on: https://swiftshader-review.googlesource.com/1730 Tested-by: Alexis Hétu <sugoi@google.com> Reviewed-by: Alexis Hétu <sugoi@google.com> Reviewed-by: Nicolas Capens <capn@google.com>
diff --git a/src/OpenGL/libGL/Image.cpp b/src/OpenGL/libGL/Image.cpp index 9e98db2..4168d82 100644 --- a/src/OpenGL/libGL/Image.cpp +++ b/src/OpenGL/libGL/Image.cpp
@@ -32,7 +32,7 @@ Image::Image(Texture *parentTexture, GLsizei width, GLsizei height, GLenum format, GLenum type) : parentTexture(parentTexture) - , egl::Image(getParentResource(parentTexture), width, height, format, type, selectInternalFormat(format, type)) + , egl::Image(getParentResource(parentTexture), width, height, 1, format, type, selectInternalFormat(format, type)) { referenceCount = 1; } @@ -176,7 +176,7 @@ return sw::FORMAT_A8R8G8B8; } - void Image::loadImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *input) + void Image::loadImageData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLint unpackAlignment, const void *input) { GLsizei inputPitch = ComputePitch(width, format, type, unpackAlignment); void *buffer = lock(0, 0, sw::LOCK_WRITEONLY); @@ -644,7 +644,7 @@ } } - void Image::loadCompressedData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLsizei imageSize, const void *pixels) + void Image::loadCompressedData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const void *pixels) { int inputPitch = ComputeCompressedPitch(width, format); int rows = imageSize / inputPitch;
diff --git a/src/OpenGL/libGL/Image.hpp b/src/OpenGL/libGL/Image.hpp index 28d04d8..039d2d0 100644 --- a/src/OpenGL/libGL/Image.hpp +++ b/src/OpenGL/libGL/Image.hpp
@@ -28,8 +28,8 @@ Image(Texture *parentTexture, GLsizei width, GLsizei height, GLenum format, GLenum type); Image(Texture *parentTexture, GLsizei width, GLsizei height, sw::Format internalFormat, int multiSampleDepth, bool lockable, bool renderTarget); - void loadImageData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *input); - void loadCompressedData(GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLsizei imageSize, const void *pixels); + void loadImageData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLint unpackAlignment, const void *input); + void loadCompressedData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei imageSize, const void *pixels); virtual void addRef(); virtual void release();
diff --git a/src/OpenGL/libGL/Program.cpp b/src/OpenGL/libGL/Program.cpp index a66a19d..97eb6f4 100644 --- a/src/OpenGL/libGL/Program.cpp +++ b/src/OpenGL/libGL/Program.cpp
@@ -591,7 +591,8 @@ if(targetUniform->type == GL_INT || targetUniform->type == GL_SAMPLER_2D || targetUniform->type == GL_SAMPLER_CUBE || - targetUniform->type == GL_SAMPLER_EXTERNAL_OES) + targetUniform->type == GL_SAMPLER_EXTERNAL_OES || + targetUniform->type == GL_SAMPLER_3D_OES) { memcpy(targetUniform->data + uniformIndex[location].element * sizeof(GLint), v, sizeof(GLint) * count); @@ -925,6 +926,7 @@ case GL_SAMPLER_2D: case GL_SAMPLER_CUBE: case GL_SAMPLER_EXTERNAL_OES: + case GL_SAMPLER_3D_OES: case GL_INT: applyUniform1iv(location, size, i); break; case GL_INT_VEC2: applyUniform2iv(location, size, i); break; case GL_INT_VEC3: applyUniform3iv(location, size, i); break; @@ -1315,7 +1317,7 @@ bool Program::defineUniform(GLenum shader, GLenum type, GLenum precision, const std::string &name, unsigned int arraySize, int registerIndex) { - if(type == GL_SAMPLER_2D || type == GL_SAMPLER_CUBE || type == GL_SAMPLER_EXTERNAL_OES) + if(type == GL_SAMPLER_2D || type == GL_SAMPLER_CUBE || type == GL_SAMPLER_EXTERNAL_OES || type == GL_SAMPLER_3D_OES) { int index = registerIndex; @@ -1737,7 +1739,8 @@ { if(targetUniform->type == GL_SAMPLER_2D || targetUniform->type == GL_SAMPLER_CUBE || - targetUniform->type == GL_SAMPLER_EXTERNAL_OES) + targetUniform->type == GL_SAMPLER_EXTERNAL_OES || + targetUniform->type == GL_SAMPLER_3D_OES) { for(int i = 0; i < count; i++) { @@ -1760,7 +1763,8 @@ { if(targetUniform->type == GL_SAMPLER_2D || targetUniform->type == GL_SAMPLER_CUBE || - targetUniform->type == GL_SAMPLER_EXTERNAL_OES) + targetUniform->type == GL_SAMPLER_EXTERNAL_OES || + targetUniform->type == GL_SAMPLER_3D_OES) { for(int i = 0; i < count; i++) {
diff --git a/src/OpenGL/libGL/Renderbuffer.cpp b/src/OpenGL/libGL/Renderbuffer.cpp index 81fcd45..6e1e04b 100644 --- a/src/OpenGL/libGL/Renderbuffer.cpp +++ b/src/OpenGL/libGL/Renderbuffer.cpp
@@ -361,7 +361,7 @@ mHeight = renderTarget->getHeight(); internalFormat = renderTarget->getInternalFormat(); format = sw2es::ConvertBackBufferFormat(internalFormat); - mSamples = renderTarget->getMultiSampleDepth() & ~1; + mSamples = renderTarget->getDepth() & ~1; } } @@ -438,7 +438,7 @@ mHeight = depthStencil->getHeight(); internalFormat = depthStencil->getInternalFormat(); format = sw2es::ConvertDepthStencilFormat(internalFormat); - mSamples = depthStencil->getMultiSampleDepth() & ~1; + mSamples = depthStencil->getDepth() & ~1; } }
diff --git a/src/OpenGL/libGL/Texture.cpp b/src/OpenGL/libGL/Texture.cpp index 732b018..f7dcbfa 100644 --- a/src/OpenGL/libGL/Texture.cpp +++ b/src/OpenGL/libGL/Texture.cpp
@@ -185,7 +185,7 @@ { if(pixels && image) { - image->loadImageData(0, 0, image->getWidth(), image->getHeight(), format, type, unpackAlignment, pixels); + image->loadImageData(0, 0, 0, image->getWidth(), image->getHeight(), 1, format, type, unpackAlignment, pixels); } } @@ -193,7 +193,7 @@ { if(pixels && image) { - image->loadCompressedData(0, 0, image->getWidth(), image->getHeight(), imageSize, pixels); + image->loadCompressedData(0, 0, 0, image->getWidth(), image->getHeight(), 1, imageSize, pixels); } } @@ -221,7 +221,7 @@ if(pixels) { - image->loadImageData(xoffset, yoffset, width, height, format, type, unpackAlignment, pixels); + image->loadImageData(xoffset, yoffset, 0, width, height, 1, format, type, unpackAlignment, pixels); } } @@ -244,7 +244,7 @@ if(pixels) { - image->loadCompressedData(xoffset, yoffset, width, height, imageSize, pixels); + image->loadCompressedData(xoffset, yoffset, 0, width, height, 1, imageSize, pixels); } }
diff --git a/src/OpenGL/libGL/utilities.cpp b/src/OpenGL/libGL/utilities.cpp index ef6eeed..0305085 100644 --- a/src/OpenGL/libGL/utilities.cpp +++ b/src/OpenGL/libGL/utilities.cpp
@@ -32,6 +32,7 @@ case GL_SAMPLER_2D: case GL_SAMPLER_CUBE: case GL_SAMPLER_EXTERNAL_OES: + case GL_SAMPLER_3D_OES: return 1; case GL_BOOL_VEC2: case GL_FLOAT_VEC2: @@ -78,6 +79,7 @@ case GL_SAMPLER_2D: case GL_SAMPLER_CUBE: case GL_SAMPLER_EXTERNAL_OES: + case GL_SAMPLER_3D_OES: case GL_INT_VEC2: case GL_INT_VEC3: case GL_INT_VEC4: @@ -122,6 +124,7 @@ case GL_SAMPLER_2D: case GL_SAMPLER_CUBE: case GL_SAMPLER_EXTERNAL_OES: + case GL_SAMPLER_3D_OES: return 1; case GL_FLOAT_MAT2: return 2;