Add ES1 stubs and remove ES2-only functions.
BUG=18110152
Change-Id: Iecebf951fe708d3f47ca6c821f448d6bbbfe0abc
Reviewed-on: https://swiftshader-review.googlesource.com/1235
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
diff --git a/src/GLES2/libGLES_CM/Buffer.h b/src/GLES2/libGLES_CM/Buffer.h
index 91580e6..538d366 100644
--- a/src/GLES2/libGLES_CM/Buffer.h
+++ b/src/GLES2/libGLES_CM/Buffer.h
@@ -13,14 +13,14 @@
// index data. Implements GL buffer objects and related functionality.
// [OpenGL ES 2.0.24] section 2.9 page 21.
-#ifndef LIBGLESV2_BUFFER_H_
-#define LIBGLESV2_BUFFER_H_
+#ifndef LIBGLES_CM_BUFFER_H_
+#define LIBGLES_CM_BUFFER_H_
#include "RefCountObject.h"
#include "Common/Resource.hpp"
-#define GL_APICALL
-#include <GLES2/gl2.h>
+#define GL_API
+#include <GLES/gl.h>
#include <cstddef>
#include <vector>
@@ -51,4 +51,4 @@
}
-#endif // LIBGLESV2_BUFFER_H_
+#endif // LIBGLES_CM_BUFFER_H_
diff --git a/src/GLES2/libGLES_CM/Context.cpp b/src/GLES2/libGLES_CM/Context.cpp
index 2eba52e..0378768 100644
--- a/src/GLES2/libGLES_CM/Context.cpp
+++ b/src/GLES2/libGLES_CM/Context.cpp
@@ -19,12 +19,9 @@
#include "utilities.h"
#include "ResourceManager.h"
#include "Buffer.h"
-#include "Fence.h"
#include "Framebuffer.h"
-#include "Program.h"
#include "Query.h"
#include "Renderbuffer.h"
-#include "Shader.h"
#include "Texture.h"
#include "VertexDataManager.h"
#include "IndexDataManager.h"
@@ -38,8 +35,6 @@
{
Context::Context(const egl::Config *config, const Context *shareContext) : mConfig(config)
{
- mFenceHandleAllocator.setBaseHandle(0);
-
setClearColor(0.0f, 0.0f, 0.0f, 0.0f);
mState.depthClearValue = 1.0f;
@@ -55,27 +50,16 @@
mState.sourceBlendAlpha = GL_ONE;
mState.destBlendRGB = GL_ZERO;
mState.destBlendAlpha = GL_ZERO;
- mState.blendEquationRGB = GL_FUNC_ADD;
- mState.blendEquationAlpha = GL_FUNC_ADD;
- mState.blendColor.red = 0;
- mState.blendColor.green = 0;
- mState.blendColor.blue = 0;
- mState.blendColor.alpha = 0;
+ mState.blendEquationRGB = GL_FUNC_ADD_OES;
+ mState.blendEquationAlpha = GL_FUNC_ADD_OES;
mState.stencilTest = false;
mState.stencilFunc = GL_ALWAYS;
mState.stencilRef = 0;
mState.stencilMask = -1;
mState.stencilWritemask = -1;
- mState.stencilBackFunc = GL_ALWAYS;
- mState.stencilBackRef = 0;
- mState.stencilBackMask = - 1;
- mState.stencilBackWritemask = -1;
mState.stencilFail = GL_KEEP;
mState.stencilPassDepthFail = GL_KEEP;
mState.stencilPassDepthPass = GL_KEEP;
- mState.stencilBackFail = GL_KEEP;
- mState.stencilBackPassDepthFail = GL_KEEP;
- mState.stencilBackPassDepthPass = GL_KEEP;
mState.polygonOffsetFill = false;
mState.polygonOffsetFactor = 0.0f;
mState.polygonOffsetUnits = 0.0f;
@@ -86,7 +70,6 @@
mState.scissorTest = false;
mState.dither = true;
mState.generateMipmapHint = GL_DONT_CARE;
- mState.fragmentShaderDerivativeHint = GL_DONT_CARE;
mState.lineWidth = 1.0f;
@@ -125,20 +108,15 @@
// objects all of whose names are 0.
mTexture2DZero.set(new Texture2D(0));
- mTextureCubeMapZero.set(new TextureCubeMap(0));
mTextureExternalZero.set(new TextureExternal(0));
mState.activeSampler = 0;
bindArrayBuffer(0);
bindElementArrayBuffer(0);
- bindTextureCubeMap(0);
bindTexture2D(0);
- bindReadFramebuffer(0);
- bindDrawFramebuffer(0);
+ bindFramebuffer(0);
bindRenderbuffer(0);
- mState.currentProgram = 0;
-
mState.packAlignment = 4;
mState.unpackAlignment = 4;
@@ -158,31 +136,11 @@
Context::~Context()
{
- if(mState.currentProgram != 0)
- {
- Program *programObject = mResourceManager->getProgram(mState.currentProgram);
- if(programObject)
- {
- programObject->release();
- }
- mState.currentProgram = 0;
- }
-
while(!mFramebufferMap.empty())
{
deleteFramebuffer(mFramebufferMap.begin()->first);
}
-
- while(!mFenceMap.empty())
- {
- deleteFence(mFenceMap.begin()->first);
- }
-
- while(!mQueryMap.empty())
- {
- deleteQuery(mQueryMap.begin()->first);
- }
-
+
for(int type = 0; type < TEXTURE_TYPE_COUNT; type++)
{
for(int sampler = 0; sampler < MAX_COMBINED_TEXTURE_IMAGE_UNITS; sampler++)
@@ -195,18 +153,12 @@
{
mState.vertexAttribute[i].mBoundBuffer.set(NULL);
}
-
- for(int i = 0; i < QUERY_TYPE_COUNT; i++)
- {
- mState.activeQuery[i].set(NULL);
- }
-
+
mState.arrayBuffer.set(NULL);
mState.elementArrayBuffer.set(NULL);
mState.renderbuffer.set(NULL);
mTexture2DZero.set(NULL);
- mTextureCubeMapZero.set(NULL);
mTextureExternalZero.set(NULL);
delete mVertexDataManager;
@@ -263,8 +215,6 @@
// This function will set all of the state-related dirty flags, so that all state is set during next pre-draw.
void Context::markAllStateDirty()
{
- mAppliedProgramSerial = 0;
-
mDepthStateDirty = true;
mMaskStateDirty = true;
mBlendStateDirty = true;
@@ -375,21 +325,6 @@
}
}
-void Context::setBlendColor(float red, float green, float blue, float alpha)
-{
- if(mState.blendColor.red != red ||
- mState.blendColor.green != green ||
- mState.blendColor.blue != blue ||
- mState.blendColor.alpha != alpha)
- {
- mState.blendColor.red = red;
- mState.blendColor.green = green;
- mState.blendColor.blue = blue;
- mState.blendColor.alpha = alpha;
- mBlendStateDirty = true;
- }
-}
-
void Context::setBlendEquation(GLenum rgbEquation, GLenum alphaEquation)
{
if(mState.blendEquationRGB != rgbEquation ||
@@ -428,19 +363,6 @@
}
}
-void Context::setStencilBackParams(GLenum stencilBackFunc, GLint stencilBackRef, GLuint stencilBackMask)
-{
- if(mState.stencilBackFunc != stencilBackFunc ||
- mState.stencilBackRef != stencilBackRef ||
- mState.stencilBackMask != stencilBackMask)
- {
- mState.stencilBackFunc = stencilBackFunc;
- mState.stencilBackRef = (stencilBackRef > 0) ? stencilBackRef : 0;
- mState.stencilBackMask = stencilBackMask;
- mStencilStateDirty = true;
- }
-}
-
void Context::setStencilWritemask(GLuint stencilWritemask)
{
if(mState.stencilWritemask != stencilWritemask)
@@ -450,15 +372,6 @@
}
}
-void Context::setStencilBackWritemask(GLuint stencilBackWritemask)
-{
- if(mState.stencilBackWritemask != stencilBackWritemask)
- {
- mState.stencilBackWritemask = stencilBackWritemask;
- mStencilStateDirty = true;
- }
-}
-
void Context::setStencilOperations(GLenum stencilFail, GLenum stencilPassDepthFail, GLenum stencilPassDepthPass)
{
if(mState.stencilFail != stencilFail ||
@@ -472,19 +385,6 @@
}
}
-void Context::setStencilBackOperations(GLenum stencilBackFail, GLenum stencilBackPassDepthFail, GLenum stencilBackPassDepthPass)
-{
- if(mState.stencilBackFail != stencilBackFail ||
- mState.stencilBackPassDepthFail != stencilBackPassDepthFail ||
- mState.stencilBackPassDepthPass != stencilBackPassDepthPass)
- {
- mState.stencilBackFail = stencilBackFail;
- mState.stencilBackPassDepthFail = stencilBackPassDepthFail;
- mState.stencilBackPassDepthPass = stencilBackPassDepthPass;
- mStencilStateDirty = true;
- }
-}
-
void Context::setPolygonOffsetFill(bool enabled)
{
if(mState.polygonOffsetFill != enabled)
@@ -583,14 +483,6 @@
mState.generateMipmapHint = hint;
}
-void Context::setFragmentShaderDerivativeHint(GLenum hint)
-{
- mState.fragmentShaderDerivativeHint = hint;
- // TODO: Propagate the hint to shader translator so we can write
- // ddx, ddx_coarse, or ddx_fine depending on the hint.
- // Ignore for now. It is valid for implementations to ignore hint.
-}
-
void Context::setViewportParams(GLint x, GLint y, GLsizei width, GLsizei height)
{
mState.viewportX = x;
@@ -634,14 +526,9 @@
mState.activeSampler = active;
}
-GLuint Context::getReadFramebufferHandle() const
+GLuint Context::getFramebufferHandle() const
{
- return mState.readFramebuffer;
-}
-
-GLuint Context::getDrawFramebufferHandle() const
-{
- return mState.drawFramebuffer;
+ return mState.framebuffer;
}
GLuint Context::getRenderbufferHandle() const
@@ -654,30 +541,6 @@
return mState.arrayBuffer.id();
}
-GLuint Context::getActiveQuery(GLenum target) const
-{
- Query *queryObject = NULL;
-
- switch(target)
- {
- case GL_ANY_SAMPLES_PASSED_EXT:
- queryObject = mState.activeQuery[QUERY_ANY_SAMPLES_PASSED].get();
- break;
- case GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT:
- queryObject = mState.activeQuery[QUERY_ANY_SAMPLES_PASSED_CONSERVATIVE].get();
- break;
- default:
- ASSERT(false);
- }
-
- if(queryObject)
- {
- return queryObject->id();
- }
-
- return 0;
-}
-
void Context::setEnableVertexAttribArray(unsigned int attribNum, bool enabled)
{
mState.vertexAttribute[attribNum].mArrayEnabled = enabled;
@@ -734,16 +597,6 @@
return mResourceManager->createBuffer();
}
-GLuint Context::createProgram()
-{
- return mResourceManager->createProgram();
-}
-
-GLuint Context::createShader(GLenum type)
-{
- return mResourceManager->createShader(type);
-}
-
GLuint Context::createTexture()
{
return mResourceManager->createTexture();
@@ -764,25 +617,6 @@
return handle;
}
-GLuint Context::createFence()
-{
- GLuint handle = mFenceHandleAllocator.allocate();
-
- mFenceMap[handle] = new Fence;
-
- return handle;
-}
-
-// Returns an unused query name
-GLuint Context::createQuery()
-{
- GLuint handle = mQueryHandleAllocator.allocate();
-
- mQueryMap[handle] = NULL;
-
- return handle;
-}
-
void Context::deleteBuffer(GLuint buffer)
{
if(mResourceManager->getBuffer(buffer))
@@ -793,16 +627,6 @@
mResourceManager->deleteBuffer(buffer);
}
-void Context::deleteShader(GLuint shader)
-{
- mResourceManager->deleteShader(shader);
-}
-
-void Context::deleteProgram(GLuint program)
-{
- mResourceManager->deleteProgram(program);
-}
-
void Context::deleteTexture(GLuint texture)
{
if(mResourceManager->getTexture(texture))
@@ -837,50 +661,11 @@
}
}
-void Context::deleteFence(GLuint fence)
-{
- FenceMap::iterator fenceObject = mFenceMap.find(fence);
-
- if(fenceObject != mFenceMap.end())
- {
- mFenceHandleAllocator.release(fenceObject->first);
- delete fenceObject->second;
- mFenceMap.erase(fenceObject);
- }
-}
-
-void Context::deleteQuery(GLuint query)
-{
- QueryMap::iterator queryObject = mQueryMap.find(query);
-
- if(queryObject != mQueryMap.end())
- {
- mQueryHandleAllocator.release(queryObject->first);
-
- if(queryObject->second)
- {
- queryObject->second->release();
- }
-
- mQueryMap.erase(queryObject);
- }
-}
-
Buffer *Context::getBuffer(GLuint handle)
{
return mResourceManager->getBuffer(handle);
}
-Shader *Context::getShader(GLuint handle)
-{
- return mResourceManager->getShader(handle);
-}
-
-Program *Context::getProgram(GLuint handle)
-{
- return mResourceManager->getProgram(handle);
-}
-
Texture *Context::getTexture(GLuint handle)
{
return mResourceManager->getTexture(handle);
@@ -891,14 +676,9 @@
return mResourceManager->getRenderbuffer(handle);
}
-Framebuffer *Context::getReadFramebuffer()
+Framebuffer *Context::getFramebuffer()
{
- return getFramebuffer(mState.readFramebuffer);
-}
-
-Framebuffer *Context::getDrawFramebuffer()
-{
- return getFramebuffer(mState.drawFramebuffer);
+ return getFramebuffer(mState.framebuffer);
}
void Context::bindArrayBuffer(unsigned int buffer)
@@ -922,13 +702,6 @@
mState.samplerTexture[TEXTURE_2D][mState.activeSampler].set(getTexture(texture));
}
-void Context::bindTextureCubeMap(GLuint texture)
-{
- mResourceManager->checkTextureAllocation(texture, TEXTURE_CUBE);
-
- mState.samplerTexture[TEXTURE_CUBE][mState.activeSampler].set(getTexture(texture));
-}
-
void Context::bindTextureExternal(GLuint texture)
{
mResourceManager->checkTextureAllocation(texture, TEXTURE_EXTERNAL);
@@ -936,24 +709,14 @@
mState.samplerTexture[TEXTURE_EXTERNAL][mState.activeSampler].set(getTexture(texture));
}
-void Context::bindReadFramebuffer(GLuint framebuffer)
+void Context::bindFramebuffer(GLuint framebuffer)
{
if(!getFramebuffer(framebuffer))
{
mFramebufferMap[framebuffer] = new Framebuffer();
}
- mState.readFramebuffer = framebuffer;
-}
-
-void Context::bindDrawFramebuffer(GLuint framebuffer)
-{
- if(!getFramebuffer(framebuffer))
- {
- mFramebufferMap[framebuffer] = new Framebuffer();
- }
-
- mState.drawFramebuffer = framebuffer;
+ mState.framebuffer = framebuffer;
}
void Context::bindRenderbuffer(GLuint renderbuffer)
@@ -963,115 +726,6 @@
mState.renderbuffer.set(getRenderbuffer(renderbuffer));
}
-void Context::useProgram(GLuint program)
-{
- GLuint priorProgram = mState.currentProgram;
- mState.currentProgram = program; // Must switch before trying to delete, otherwise it only gets flagged.
-
- if(priorProgram != program)
- {
- Program *newProgram = mResourceManager->getProgram(program);
- Program *oldProgram = mResourceManager->getProgram(priorProgram);
-
- if(newProgram)
- {
- newProgram->addRef();
- }
-
- if(oldProgram)
- {
- oldProgram->release();
- }
- }
-}
-
-void Context::beginQuery(GLenum target, GLuint query)
-{
- // From EXT_occlusion_query_boolean: If BeginQueryEXT is called with an <id>
- // of zero, if the active query object name for <target> is non-zero (for the
- // targets ANY_SAMPLES_PASSED_EXT and ANY_SAMPLES_PASSED_CONSERVATIVE_EXT, if
- // the active query for either target is non-zero), if <id> is the name of an
- // existing query object whose type does not match <target>, or if <id> is the
- // active query object name for any query type, the error INVALID_OPERATION is
- // generated.
-
- // Ensure no other queries are active
- // NOTE: If other queries than occlusion are supported, we will need to check
- // separately that:
- // a) The query ID passed is not the current active query for any target/type
- // b) There are no active queries for the requested target (and in the case
- // of GL_ANY_SAMPLES_PASSED_EXT and GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT,
- // no query may be active for either if glBeginQuery targets either.
- for(int i = 0; i < QUERY_TYPE_COUNT; i++)
- {
- if(mState.activeQuery[i].get() != NULL)
- {
- return error(GL_INVALID_OPERATION);
- }
- }
-
- QueryType qType;
- switch(target)
- {
- case GL_ANY_SAMPLES_PASSED_EXT:
- qType = QUERY_ANY_SAMPLES_PASSED;
- break;
- case GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT:
- qType = QUERY_ANY_SAMPLES_PASSED_CONSERVATIVE;
- break;
- default:
- ASSERT(false);
- }
-
- Query *queryObject = getQuery(query, true, target);
-
- // Check that name was obtained with glGenQueries
- if(!queryObject)
- {
- return error(GL_INVALID_OPERATION);
- }
-
- // Check for type mismatch
- if(queryObject->getType() != target)
- {
- return error(GL_INVALID_OPERATION);
- }
-
- // Set query as active for specified target
- mState.activeQuery[qType].set(queryObject);
-
- // Begin query
- queryObject->begin();
-}
-
-void Context::endQuery(GLenum target)
-{
- QueryType qType;
-
- switch(target)
- {
- case GL_ANY_SAMPLES_PASSED_EXT:
- qType = QUERY_ANY_SAMPLES_PASSED;
- break;
- case GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT:
- qType = QUERY_ANY_SAMPLES_PASSED_CONSERVATIVE;
- break;
- default:
- ASSERT(false);
- }
-
- Query *queryObject = mState.activeQuery[qType].get();
-
- if(queryObject == NULL)
- {
- return error(GL_INVALID_OPERATION);
- }
-
- queryObject->end();
-
- mState.activeQuery[qType].set(NULL);
-}
-
void Context::setFramebufferZero(Framebuffer *buffer)
{
delete mFramebufferMap[0];
@@ -1098,40 +752,6 @@
}
}
-Fence *Context::getFence(unsigned int handle)
-{
- FenceMap::iterator fence = mFenceMap.find(handle);
-
- if(fence == mFenceMap.end())
- {
- return NULL;
- }
- else
- {
- return fence->second;
- }
-}
-
-Query *Context::getQuery(unsigned int handle, bool create, GLenum type)
-{
- QueryMap::iterator query = mQueryMap.find(handle);
-
- if(query == mQueryMap.end())
- {
- return NULL;
- }
- else
- {
- if(!query->second && create)
- {
- query->second = new Query(handle, type);
- query->second->addRef();
- }
-
- return query->second;
- }
-}
-
Buffer *Context::getArrayBuffer()
{
return mState.arrayBuffer.get();
@@ -1142,21 +762,11 @@
return mState.elementArrayBuffer.get();
}
-Program *Context::getCurrentProgram()
-{
- return mResourceManager->getProgram(mState.currentProgram);
-}
-
Texture2D *Context::getTexture2D()
{
return static_cast<Texture2D*>(getSamplerTexture(mState.activeSampler, TEXTURE_2D));
}
-TextureCubeMap *Context::getTextureCubeMap()
-{
- return static_cast<TextureCubeMap*>(getSamplerTexture(mState.activeSampler, TEXTURE_CUBE));
-}
-
TextureExternal *Context::getTextureExternal()
{
return static_cast<TextureExternal*>(getSamplerTexture(mState.activeSampler, TEXTURE_EXTERNAL));
@@ -1171,7 +781,6 @@
switch (type)
{
case TEXTURE_2D: return mTexture2DZero.get();
- case TEXTURE_CUBE: return mTextureCubeMapZero.get();
case TEXTURE_EXTERNAL: return mTextureExternalZero.get();
default: UNREACHABLE();
}
@@ -1184,7 +793,6 @@
{
switch (pname)
{
- case GL_SHADER_COMPILER: *params = GL_TRUE; break;
case GL_SAMPLE_COVERAGE_INVERT: *params = mState.sampleCoverageInvert; break;
case GL_DEPTH_WRITEMASK: *params = mState.depthMask; break;
case GL_COLOR_WRITEMASK:
@@ -1240,12 +848,6 @@
params[2] = mState.colorClearValue.blue;
params[3] = mState.colorClearValue.alpha;
break;
- case GL_BLEND_COLOR:
- params[0] = mState.blendColor.red;
- params[1] = mState.blendColor.green;
- params[2] = mState.blendColor.blue;
- params[3] = mState.blendColor.alpha;
- break;
case GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT:
*params = MAX_TEXTURE_MAX_ANISOTROPY;
break;
@@ -1265,62 +867,38 @@
// Context::getFloatv.
switch (pname)
{
- case GL_MAX_VERTEX_ATTRIBS: *params = MAX_VERTEX_ATTRIBS; break;
- case GL_MAX_VERTEX_UNIFORM_VECTORS: *params = MAX_VERTEX_UNIFORM_VECTORS; break;
- case GL_MAX_VARYING_VECTORS: *params = MAX_VARYING_VECTORS; break;
- case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS: *params = MAX_COMBINED_TEXTURE_IMAGE_UNITS; break;
- case GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS: *params = MAX_VERTEX_TEXTURE_IMAGE_UNITS; break;
- case GL_MAX_TEXTURE_IMAGE_UNITS: *params = MAX_TEXTURE_IMAGE_UNITS; break;
- case GL_MAX_FRAGMENT_UNIFORM_VECTORS: *params = MAX_FRAGMENT_UNIFORM_VECTORS; break;
- case GL_MAX_RENDERBUFFER_SIZE: *params = IMPLEMENTATION_MAX_RENDERBUFFER_SIZE; break;
- case GL_NUM_SHADER_BINARY_FORMATS: *params = 0; break;
- case GL_SHADER_BINARY_FORMATS: /* no shader binary formats are supported */ break;
case GL_ARRAY_BUFFER_BINDING: *params = mState.arrayBuffer.id(); break;
case GL_ELEMENT_ARRAY_BUFFER_BINDING: *params = mState.elementArrayBuffer.id(); break;
-// case GL_FRAMEBUFFER_BINDING: // now equivalent to GL_DRAW_FRAMEBUFFER_BINDING_ANGLE
- case GL_DRAW_FRAMEBUFFER_BINDING_ANGLE: *params = mState.drawFramebuffer; break;
- case GL_READ_FRAMEBUFFER_BINDING_ANGLE: *params = mState.readFramebuffer; break;
- case GL_RENDERBUFFER_BINDING: *params = mState.renderbuffer.id(); break;
- case GL_CURRENT_PROGRAM: *params = mState.currentProgram; break;
+ case GL_FRAMEBUFFER_BINDING_OES: *params = mState.framebuffer; break;
+ case GL_RENDERBUFFER_BINDING_OES: *params = mState.renderbuffer.id(); break;
case GL_PACK_ALIGNMENT: *params = mState.packAlignment; break;
case GL_UNPACK_ALIGNMENT: *params = mState.unpackAlignment; break;
case GL_GENERATE_MIPMAP_HINT: *params = mState.generateMipmapHint; break;
- case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES: *params = mState.fragmentShaderDerivativeHint; break;
case GL_ACTIVE_TEXTURE: *params = (mState.activeSampler + GL_TEXTURE0); break;
case GL_STENCIL_FUNC: *params = mState.stencilFunc; break;
case GL_STENCIL_REF: *params = mState.stencilRef; break;
case GL_STENCIL_VALUE_MASK: *params = mState.stencilMask; break;
- case GL_STENCIL_BACK_FUNC: *params = mState.stencilBackFunc; break;
- case GL_STENCIL_BACK_REF: *params = mState.stencilBackRef; break;
- case GL_STENCIL_BACK_VALUE_MASK: *params = mState.stencilBackMask; break;
case GL_STENCIL_FAIL: *params = mState.stencilFail; break;
case GL_STENCIL_PASS_DEPTH_FAIL: *params = mState.stencilPassDepthFail; break;
case GL_STENCIL_PASS_DEPTH_PASS: *params = mState.stencilPassDepthPass; break;
- case GL_STENCIL_BACK_FAIL: *params = mState.stencilBackFail; break;
- case GL_STENCIL_BACK_PASS_DEPTH_FAIL: *params = mState.stencilBackPassDepthFail; break;
- case GL_STENCIL_BACK_PASS_DEPTH_PASS: *params = mState.stencilBackPassDepthPass; break;
case GL_DEPTH_FUNC: *params = mState.depthFunc; break;
- case GL_BLEND_SRC_RGB: *params = mState.sourceBlendRGB; break;
- case GL_BLEND_SRC_ALPHA: *params = mState.sourceBlendAlpha; break;
- case GL_BLEND_DST_RGB: *params = mState.destBlendRGB; break;
- case GL_BLEND_DST_ALPHA: *params = mState.destBlendAlpha; break;
- case GL_BLEND_EQUATION_RGB: *params = mState.blendEquationRGB; break;
- case GL_BLEND_EQUATION_ALPHA: *params = mState.blendEquationAlpha; break;
+ case GL_BLEND_SRC_RGB_OES: *params = mState.sourceBlendRGB; break;
+ case GL_BLEND_SRC_ALPHA_OES: *params = mState.sourceBlendAlpha; break;
+ case GL_BLEND_DST_RGB_OES: *params = mState.destBlendRGB; break;
+ case GL_BLEND_DST_ALPHA_OES: *params = mState.destBlendAlpha; break;
+ case GL_BLEND_EQUATION_RGB_OES: *params = mState.blendEquationRGB; break;
+ case GL_BLEND_EQUATION_ALPHA_OES: *params = mState.blendEquationAlpha; break;
case GL_STENCIL_WRITEMASK: *params = mState.stencilWritemask; break;
- case GL_STENCIL_BACK_WRITEMASK: *params = mState.stencilBackWritemask; break;
case GL_STENCIL_CLEAR_VALUE: *params = mState.stencilClearValue; break;
case GL_SUBPIXEL_BITS: *params = 4; break;
- case GL_MAX_TEXTURE_SIZE: *params = IMPLEMENTATION_MAX_TEXTURE_SIZE; break;
- case GL_MAX_CUBE_MAP_TEXTURE_SIZE: *params = IMPLEMENTATION_MAX_CUBE_MAP_TEXTURE_SIZE; break;
+ case GL_MAX_TEXTURE_SIZE: *params = IMPLEMENTATION_MAX_TEXTURE_SIZE; break;
case GL_NUM_COMPRESSED_TEXTURE_FORMATS:
{
if(S3TC_SUPPORT)
{
// GL_COMPRESSED_RGB_S3TC_DXT1_EXT
// GL_COMPRESSED_RGBA_S3TC_DXT1_EXT
- // GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE
- // GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE
- *params = 4;
+ *params = 2;
}
else
{
@@ -1328,14 +906,13 @@
}
}
break;
- case GL_MAX_SAMPLES_ANGLE: *params = IMPLEMENTATION_MAX_SAMPLES; break;
- case GL_SAMPLE_BUFFERS:
+ case GL_SAMPLE_BUFFERS:
case GL_SAMPLES:
{
- Framebuffer *framebuffer = getDrawFramebuffer();
+ Framebuffer *framebuffer = getFramebuffer();
int width, height, samples;
- if(framebuffer->completeness(width, height, samples) == GL_FRAMEBUFFER_COMPLETE)
+ if(framebuffer->completeness(width, height, samples) == GL_FRAMEBUFFER_COMPLETE_OES)
{
switch(pname)
{
@@ -1360,8 +937,8 @@
}
}
break;
- case GL_IMPLEMENTATION_COLOR_READ_TYPE: *params = IMPLEMENTATION_COLOR_READ_TYPE; break;
- case GL_IMPLEMENTATION_COLOR_READ_FORMAT: *params = IMPLEMENTATION_COLOR_READ_FORMAT; break;
+ case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES: *params = IMPLEMENTATION_COLOR_READ_TYPE; break;
+ case GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES: *params = IMPLEMENTATION_COLOR_READ_FORMAT; break;
case GL_MAX_VIEWPORT_DIMS:
{
int maxDimension = IMPLEMENTATION_MAX_RENDERBUFFER_SIZE;
@@ -1375,8 +952,6 @@
{
params[0] = GL_COMPRESSED_RGB_S3TC_DXT1_EXT;
params[1] = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
- params[2] = GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE;
- params[3] = GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE;
}
}
break;
@@ -1399,7 +974,7 @@
case GL_BLUE_BITS:
case GL_ALPHA_BITS:
{
- Framebuffer *framebuffer = getDrawFramebuffer();
+ Framebuffer *framebuffer = getFramebuffer();
Renderbuffer *colorbuffer = framebuffer->getColorbuffer();
if(colorbuffer)
@@ -1420,7 +995,7 @@
break;
case GL_DEPTH_BITS:
{
- Framebuffer *framebuffer = getDrawFramebuffer();
+ Framebuffer *framebuffer = getFramebuffer();
Renderbuffer *depthbuffer = framebuffer->getDepthbuffer();
if(depthbuffer)
@@ -1435,7 +1010,7 @@
break;
case GL_STENCIL_BITS:
{
- Framebuffer *framebuffer = getDrawFramebuffer();
+ Framebuffer *framebuffer = getFramebuffer();
Renderbuffer *stencilbuffer = framebuffer->getStencilbuffer();
if(stencilbuffer)
@@ -1459,7 +1034,7 @@
*params = mState.samplerTexture[TEXTURE_2D][mState.activeSampler].id();
}
break;
- case GL_TEXTURE_BINDING_CUBE_MAP:
+ case GL_TEXTURE_BINDING_CUBE_MAP_OES:
{
if(mState.activeSampler < 0 || mState.activeSampler > MAX_COMBINED_TEXTURE_IMAGE_UNITS - 1)
{
@@ -1488,7 +1063,7 @@
return true;
}
-bool Context::getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *numParams)
+int Context::getQueryParameterNum(GLenum pname)
{
// Please note: the query type returned for DEPTH_CLEAR_VALUE in this implementation
// is FLOAT rather than INT, as would be suggested by the GL ES 2.0 spec. This is due
@@ -1499,171 +1074,219 @@
// application.
switch (pname)
{
- case GL_COMPRESSED_TEXTURE_FORMATS:
- {
- *type = GL_INT;
- *numParams = S3TC_SUPPORT ? 4 : 0;
- }
- break;
- case GL_SHADER_BINARY_FORMATS:
- {
- *type = GL_INT;
- *numParams = 0;
- }
- break;
- case GL_MAX_VERTEX_ATTRIBS:
- case GL_MAX_VERTEX_UNIFORM_VECTORS:
- case GL_MAX_VARYING_VECTORS:
- case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS:
- case GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS:
- case GL_MAX_TEXTURE_IMAGE_UNITS:
- case GL_MAX_FRAGMENT_UNIFORM_VECTORS:
- case GL_MAX_RENDERBUFFER_SIZE:
- case GL_NUM_SHADER_BINARY_FORMATS:
- case GL_NUM_COMPRESSED_TEXTURE_FORMATS:
- case GL_ARRAY_BUFFER_BINDING:
- case GL_FRAMEBUFFER_BINDING:
- case GL_RENDERBUFFER_BINDING:
- case GL_CURRENT_PROGRAM:
- case GL_PACK_ALIGNMENT:
- case GL_UNPACK_ALIGNMENT:
- case GL_GENERATE_MIPMAP_HINT:
- case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES:
- case GL_RED_BITS:
- case GL_GREEN_BITS:
- case GL_BLUE_BITS:
- case GL_ALPHA_BITS:
- case GL_DEPTH_BITS:
- case GL_STENCIL_BITS:
- case GL_ELEMENT_ARRAY_BUFFER_BINDING:
- case GL_CULL_FACE_MODE:
- case GL_FRONT_FACE:
- case GL_ACTIVE_TEXTURE:
- case GL_STENCIL_FUNC:
- case GL_STENCIL_VALUE_MASK:
- case GL_STENCIL_REF:
- case GL_STENCIL_FAIL:
- case GL_STENCIL_PASS_DEPTH_FAIL:
- case GL_STENCIL_PASS_DEPTH_PASS:
- case GL_STENCIL_BACK_FUNC:
- case GL_STENCIL_BACK_VALUE_MASK:
- case GL_STENCIL_BACK_REF:
- case GL_STENCIL_BACK_FAIL:
- case GL_STENCIL_BACK_PASS_DEPTH_FAIL:
- case GL_STENCIL_BACK_PASS_DEPTH_PASS:
- case GL_DEPTH_FUNC:
- case GL_BLEND_SRC_RGB:
- case GL_BLEND_SRC_ALPHA:
- case GL_BLEND_DST_RGB:
- case GL_BLEND_DST_ALPHA:
- case GL_BLEND_EQUATION_RGB:
- case GL_BLEND_EQUATION_ALPHA:
- case GL_STENCIL_WRITEMASK:
- case GL_STENCIL_BACK_WRITEMASK:
- case GL_STENCIL_CLEAR_VALUE:
- case GL_SUBPIXEL_BITS:
- case GL_MAX_TEXTURE_SIZE:
- case GL_MAX_CUBE_MAP_TEXTURE_SIZE:
- case GL_SAMPLE_BUFFERS:
- case GL_SAMPLES:
- case GL_IMPLEMENTATION_COLOR_READ_TYPE:
- case GL_IMPLEMENTATION_COLOR_READ_FORMAT:
- case GL_TEXTURE_BINDING_2D:
- case GL_TEXTURE_BINDING_CUBE_MAP:
- case GL_TEXTURE_BINDING_EXTERNAL_OES:
- {
- *type = GL_INT;
- *numParams = 1;
- }
- break;
- case GL_MAX_SAMPLES_ANGLE:
- {
- *type = GL_INT;
- *numParams = 1;
- }
- break;
- case GL_MAX_VIEWPORT_DIMS:
- {
- *type = GL_INT;
- *numParams = 2;
- }
- break;
- case GL_VIEWPORT:
- case GL_SCISSOR_BOX:
- {
- *type = GL_INT;
- *numParams = 4;
- }
- break;
- case GL_SHADER_COMPILER:
- case GL_SAMPLE_COVERAGE_INVERT:
- case GL_DEPTH_WRITEMASK:
- case GL_CULL_FACE: // CULL_FACE through DITHER are natural to IsEnabled,
- case GL_POLYGON_OFFSET_FILL: // but can be retrieved through the Get{Type}v queries.
- case GL_SAMPLE_ALPHA_TO_COVERAGE: // For this purpose, they are treated here as bool-natural
- case GL_SAMPLE_COVERAGE:
- case GL_SCISSOR_TEST:
- case GL_STENCIL_TEST:
- case GL_DEPTH_TEST:
- case GL_BLEND:
- case GL_DITHER:
- {
- *type = GL_BOOL;
- *numParams = 1;
- }
- break;
- case GL_COLOR_WRITEMASK:
- {
- *type = GL_BOOL;
- *numParams = 4;
- }
- break;
- case GL_POLYGON_OFFSET_FACTOR:
- case GL_POLYGON_OFFSET_UNITS:
- case GL_SAMPLE_COVERAGE_VALUE:
- case GL_DEPTH_CLEAR_VALUE:
- case GL_LINE_WIDTH:
- {
- *type = GL_FLOAT;
- *numParams = 1;
- }
- break;
- case GL_ALIASED_LINE_WIDTH_RANGE:
- case GL_ALIASED_POINT_SIZE_RANGE:
- case GL_DEPTH_RANGE:
- {
- *type = GL_FLOAT;
- *numParams = 2;
- }
- break;
- case GL_COLOR_CLEAR_VALUE:
- case GL_BLEND_COLOR:
- {
- *type = GL_FLOAT;
- *numParams = 4;
- }
- break;
- case GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT:
- *type = GL_FLOAT;
- *numParams = 1;
- break;
- default:
- return false;
+ case GL_COMPRESSED_TEXTURE_FORMATS:
+ return S3TC_SUPPORT ? 2 : 0;
+ case GL_NUM_COMPRESSED_TEXTURE_FORMATS:
+ case GL_ARRAY_BUFFER_BINDING:
+ case GL_FRAMEBUFFER_BINDING_OES:
+ case GL_RENDERBUFFER_BINDING_OES:
+ case GL_PACK_ALIGNMENT:
+ case GL_UNPACK_ALIGNMENT:
+ case GL_GENERATE_MIPMAP_HINT:
+ case GL_RED_BITS:
+ case GL_GREEN_BITS:
+ case GL_BLUE_BITS:
+ case GL_ALPHA_BITS:
+ case GL_DEPTH_BITS:
+ case GL_STENCIL_BITS:
+ case GL_ELEMENT_ARRAY_BUFFER_BINDING:
+ case GL_CULL_FACE_MODE:
+ case GL_FRONT_FACE:
+ case GL_ACTIVE_TEXTURE:
+ case GL_STENCIL_FUNC:
+ case GL_STENCIL_VALUE_MASK:
+ case GL_STENCIL_REF:
+ case GL_STENCIL_FAIL:
+ case GL_STENCIL_PASS_DEPTH_FAIL:
+ case GL_STENCIL_PASS_DEPTH_PASS:
+ case GL_DEPTH_FUNC:
+ case GL_BLEND_SRC_RGB_OES:
+ case GL_BLEND_SRC_ALPHA_OES:
+ case GL_BLEND_DST_RGB_OES:
+ case GL_BLEND_DST_ALPHA_OES:
+ case GL_BLEND_EQUATION_RGB_OES:
+ case GL_BLEND_EQUATION_ALPHA_OES:
+ case GL_STENCIL_WRITEMASK:
+ case GL_STENCIL_CLEAR_VALUE:
+ case GL_SUBPIXEL_BITS:
+ case GL_MAX_TEXTURE_SIZE:
+ case GL_MAX_CUBE_MAP_TEXTURE_SIZE_OES:
+ case GL_SAMPLE_BUFFERS:
+ case GL_SAMPLES:
+ case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES:
+ case GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES:
+ case GL_TEXTURE_BINDING_2D:
+ case GL_TEXTURE_BINDING_CUBE_MAP_OES:
+ case GL_TEXTURE_BINDING_EXTERNAL_OES:
+ return 1;
+ case GL_MAX_VIEWPORT_DIMS:
+ return 2;
+ case GL_VIEWPORT:
+ case GL_SCISSOR_BOX:
+ return 4;
+ case GL_SAMPLE_COVERAGE_INVERT:
+ case GL_DEPTH_WRITEMASK:
+ case GL_CULL_FACE: // CULL_FACE through DITHER are natural to IsEnabled,
+ case GL_POLYGON_OFFSET_FILL: // but can be retrieved through the Get{Type}v queries.
+ case GL_SAMPLE_ALPHA_TO_COVERAGE: // For this purpose, they are treated here as bool-natural
+ case GL_SAMPLE_COVERAGE:
+ case GL_SCISSOR_TEST:
+ case GL_STENCIL_TEST:
+ case GL_DEPTH_TEST:
+ case GL_BLEND:
+ case GL_DITHER:
+ return 1;
+ case GL_COLOR_WRITEMASK:
+ return 4;
+ case GL_POLYGON_OFFSET_FACTOR:
+ case GL_POLYGON_OFFSET_UNITS:
+ case GL_SAMPLE_COVERAGE_VALUE:
+ case GL_DEPTH_CLEAR_VALUE:
+ case GL_LINE_WIDTH:
+ return 1;
+ case GL_ALIASED_LINE_WIDTH_RANGE:
+ case GL_ALIASED_POINT_SIZE_RANGE:
+ case GL_DEPTH_RANGE:
+ return 2;
+ case GL_COLOR_CLEAR_VALUE:
+ return 4;
+ case GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT:
+ return 1;
+ default:
+ UNREACHABLE();
}
- return true;
+ return -1;
+}
+
+bool Context::isQueryParameterInt(GLenum pname)
+{
+ // Please note: the query type returned for DEPTH_CLEAR_VALUE in this implementation
+ // is FLOAT rather than INT, as would be suggested by the GL ES 2.0 spec. This is due
+ // to the fact that it is stored internally as a float, and so would require conversion
+ // if returned from Context::getIntegerv. Since this conversion is already implemented
+ // in the case that one calls glGetIntegerv to retrieve a float-typed state variable, we
+ // place DEPTH_CLEAR_VALUE with the floats. This should make no difference to the calling
+ // application.
+ switch(pname)
+ {
+ case GL_COMPRESSED_TEXTURE_FORMATS:
+ case GL_NUM_COMPRESSED_TEXTURE_FORMATS:
+ case GL_ARRAY_BUFFER_BINDING:
+ case GL_FRAMEBUFFER_BINDING_OES:
+ case GL_RENDERBUFFER_BINDING_OES:
+ case GL_PACK_ALIGNMENT:
+ case GL_UNPACK_ALIGNMENT:
+ case GL_GENERATE_MIPMAP_HINT:
+ case GL_RED_BITS:
+ case GL_GREEN_BITS:
+ case GL_BLUE_BITS:
+ case GL_ALPHA_BITS:
+ case GL_DEPTH_BITS:
+ case GL_STENCIL_BITS:
+ case GL_ELEMENT_ARRAY_BUFFER_BINDING:
+ case GL_CULL_FACE_MODE:
+ case GL_FRONT_FACE:
+ case GL_ACTIVE_TEXTURE:
+ case GL_STENCIL_FUNC:
+ case GL_STENCIL_VALUE_MASK:
+ case GL_STENCIL_REF:
+ case GL_STENCIL_FAIL:
+ case GL_STENCIL_PASS_DEPTH_FAIL:
+ case GL_STENCIL_PASS_DEPTH_PASS:
+ case GL_DEPTH_FUNC:
+ case GL_BLEND_SRC_RGB_OES:
+ case GL_BLEND_SRC_ALPHA_OES:
+ case GL_BLEND_DST_RGB_OES:
+ case GL_BLEND_DST_ALPHA_OES:
+ case GL_BLEND_EQUATION_RGB_OES:
+ case GL_BLEND_EQUATION_ALPHA_OES:
+ case GL_STENCIL_WRITEMASK:
+ case GL_STENCIL_CLEAR_VALUE:
+ case GL_SUBPIXEL_BITS:
+ case GL_MAX_TEXTURE_SIZE:
+ case GL_MAX_CUBE_MAP_TEXTURE_SIZE_OES:
+ case GL_SAMPLE_BUFFERS:
+ case GL_SAMPLES:
+ case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES:
+ case GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES:
+ case GL_TEXTURE_BINDING_2D:
+ case GL_TEXTURE_BINDING_CUBE_MAP_OES:
+ case GL_TEXTURE_BINDING_EXTERNAL_OES:
+ case GL_MAX_VIEWPORT_DIMS:
+ case GL_VIEWPORT:
+ case GL_SCISSOR_BOX:
+ return true;
+ default:
+ ASSERT(isQueryParameterFloat(pname) || isQueryParameterBool(pname));
+ }
+
+ return false;
+}
+
+bool Context::isQueryParameterFloat(GLenum pname)
+{
+ // Please note: the query type returned for DEPTH_CLEAR_VALUE in this implementation
+ // is FLOAT rather than INT, as would be suggested by the GL ES 2.0 spec. This is due
+ // to the fact that it is stored internally as a float, and so would require conversion
+ // if returned from Context::getIntegerv. Since this conversion is already implemented
+ // in the case that one calls glGetIntegerv to retrieve a float-typed state variable, we
+ // place DEPTH_CLEAR_VALUE with the floats. This should make no difference to the calling
+ // application.
+ switch(pname)
+ {
+ case GL_POLYGON_OFFSET_FACTOR:
+ case GL_POLYGON_OFFSET_UNITS:
+ case GL_SAMPLE_COVERAGE_VALUE:
+ case GL_DEPTH_CLEAR_VALUE:
+ case GL_LINE_WIDTH:
+ case GL_ALIASED_LINE_WIDTH_RANGE:
+ case GL_ALIASED_POINT_SIZE_RANGE:
+ case GL_DEPTH_RANGE:
+ case GL_COLOR_CLEAR_VALUE:
+ case GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT:
+ return true;
+ default:
+ ASSERT(isQueryParameterInt(pname) || isQueryParameterBool(pname));
+ }
+
+ return false;
+}
+
+bool Context::isQueryParameterBool(GLenum pname)
+{
+ switch(pname)
+ {
+ case GL_SAMPLE_COVERAGE_INVERT:
+ case GL_DEPTH_WRITEMASK:
+ case GL_CULL_FACE: // CULL_FACE through DITHER are natural to IsEnabled,
+ case GL_POLYGON_OFFSET_FILL: // but can be retrieved through the Get{Type}v queries.
+ case GL_SAMPLE_ALPHA_TO_COVERAGE: // For this purpose, they are treated here as bool-natural
+ case GL_SAMPLE_COVERAGE:
+ case GL_SCISSOR_TEST:
+ case GL_STENCIL_TEST:
+ case GL_DEPTH_TEST:
+ case GL_BLEND:
+ case GL_DITHER:
+ case GL_COLOR_WRITEMASK:
+ return true;
+ default:
+ ASSERT(isQueryParameterInt(pname) || isQueryParameterFloat(pname));
+ }
+
+ return false;
}
// Applies the render target surface, depth stencil surface, viewport rectangle and scissor rectangle
bool Context::applyRenderTarget()
{
Device *device = getDevice();
- Framebuffer *framebuffer = getDrawFramebuffer();
+ Framebuffer *framebuffer = getFramebuffer();
int width, height, samples;
- if(!framebuffer || framebuffer->completeness(width, height, samples) != GL_FRAMEBUFFER_COMPLETE)
+ if(!framebuffer || framebuffer->completeness(width, height, samples) != GL_FRAMEBUFFER_COMPLETE_OES)
{
- return error(GL_INVALID_FRAMEBUFFER_OPERATION, false);
+ return error(GL_INVALID_FRAMEBUFFER_OPERATION_OES, false);
}
Image *renderTarget = framebuffer->getRenderTarget();
@@ -1700,16 +1323,6 @@
device->setScissorEnable(false);
}
- Program *program = getCurrentProgram();
-
- if(program)
- {
- GLfloat nearFarDiff[3] = {zNear, zFar, zFar - zNear};
- program->setUniform1fv(program->getUniformLocation("gl_DepthRange.near"), 1, &nearFarDiff[0]);
- program->setUniform1fv(program->getUniformLocation("gl_DepthRange.far"), 1, &nearFarDiff[1]);
- program->setUniform1fv(program->getUniformLocation("gl_DepthRange.diff"), 1, &nearFarDiff[2]);
- }
-
return true;
}
@@ -1717,7 +1330,7 @@
void Context::applyState(GLenum drawMode)
{
Device *device = getDevice();
- Framebuffer *framebuffer = getDrawFramebuffer();
+ Framebuffer *framebuffer = getFramebuffer();
if(mState.cullFace)
{
@@ -1750,8 +1363,6 @@
device->setAlphaBlendEnable(true);
device->setSeparateAlphaBlendEnable(true);
- device->setBlendConstant(es2sw::ConvertColor(mState.blendColor));
-
device->setSourceBlendFactor(es2sw::ConvertBlendFunc(mState.sourceBlendRGB));
device->setDestBlendFactor(es2sw::ConvertBlendFunc(mState.destBlendRGB));
device->setBlendOperation(es2sw::ConvertBlendOp(mState.blendEquationRGB));
@@ -1774,63 +1385,30 @@
{
device->setStencilEnable(true);
device->setTwoSidedStencil(true);
-
- if(mState.stencilWritemask != mState.stencilBackWritemask ||
- mState.stencilRef != mState.stencilBackRef ||
- mState.stencilMask != mState.stencilBackMask)
- {
- ERR("Separate front/back stencil writemasks, reference values, or stencil mask values are invalid under WebGL.");
- return error(GL_INVALID_OPERATION);
- }
-
+
// get the maximum size of the stencil ref
Renderbuffer *stencilbuffer = framebuffer->getStencilbuffer();
GLuint maxStencil = (1 << stencilbuffer->getStencilSize()) - 1;
- if(mState.frontFace == GL_CCW)
- {
- device->setStencilWriteMask(mState.stencilWritemask);
- device->setStencilCompare(es2sw::ConvertStencilComparison(mState.stencilFunc));
+ device->setStencilWriteMask(mState.stencilWritemask);
+ device->setStencilCompare(es2sw::ConvertStencilComparison(mState.stencilFunc));
- device->setStencilReference((mState.stencilRef < (GLint)maxStencil) ? mState.stencilRef : maxStencil);
- device->setStencilMask(mState.stencilMask);
+ device->setStencilReference((mState.stencilRef < (GLint)maxStencil) ? mState.stencilRef : maxStencil);
+ device->setStencilMask(mState.stencilMask);
- device->setStencilFailOperation(es2sw::ConvertStencilOp(mState.stencilFail));
- device->setStencilZFailOperation(es2sw::ConvertStencilOp(mState.stencilPassDepthFail));
- device->setStencilPassOperation(es2sw::ConvertStencilOp(mState.stencilPassDepthPass));
+ device->setStencilFailOperation(es2sw::ConvertStencilOp(mState.stencilFail));
+ device->setStencilZFailOperation(es2sw::ConvertStencilOp(mState.stencilPassDepthFail));
+ device->setStencilPassOperation(es2sw::ConvertStencilOp(mState.stencilPassDepthPass));
- device->setStencilWriteMaskCCW(mState.stencilBackWritemask);
- device->setStencilCompareCCW(es2sw::ConvertStencilComparison(mState.stencilBackFunc));
+ device->setStencilWriteMaskCCW(mState.stencilWritemask);
+ device->setStencilCompareCCW(es2sw::ConvertStencilComparison(mState.stencilFunc));
- device->setStencilReferenceCCW((mState.stencilBackRef < (GLint)maxStencil) ? mState.stencilBackRef : maxStencil);
- device->setStencilMaskCCW(mState.stencilBackMask);
+ device->setStencilReferenceCCW((mState.stencilRef < (GLint)maxStencil) ? mState.stencilRef : maxStencil);
+ device->setStencilMaskCCW(mState.stencilMask);
- device->setStencilFailOperationCCW(es2sw::ConvertStencilOp(mState.stencilBackFail));
- device->setStencilZFailOperationCCW(es2sw::ConvertStencilOp(mState.stencilBackPassDepthFail));
- device->setStencilPassOperationCCW(es2sw::ConvertStencilOp(mState.stencilBackPassDepthPass));
- }
- else
- {
- device->setStencilWriteMaskCCW(mState.stencilWritemask);
- device->setStencilCompareCCW(es2sw::ConvertStencilComparison(mState.stencilFunc));
-
- device->setStencilReferenceCCW((mState.stencilRef < (GLint)maxStencil) ? mState.stencilRef : maxStencil);
- device->setStencilMaskCCW(mState.stencilMask);
-
- device->setStencilFailOperationCCW(es2sw::ConvertStencilOp(mState.stencilFail));
- device->setStencilZFailOperationCCW(es2sw::ConvertStencilOp(mState.stencilPassDepthFail));
- device->setStencilPassOperationCCW(es2sw::ConvertStencilOp(mState.stencilPassDepthPass));
-
- device->setStencilWriteMask(mState.stencilBackWritemask);
- device->setStencilCompare(es2sw::ConvertStencilComparison(mState.stencilBackFunc));
-
- device->setStencilReference((mState.stencilBackRef < (GLint)maxStencil) ? mState.stencilBackRef : maxStencil);
- device->setStencilMask(mState.stencilBackMask);
-
- device->setStencilFailOperation(es2sw::ConvertStencilOp(mState.stencilBackFail));
- device->setStencilZFailOperation(es2sw::ConvertStencilOp(mState.stencilBackPassDepthFail));
- device->setStencilPassOperation(es2sw::ConvertStencilOp(mState.stencilBackPassDepthPass));
- }
+ device->setStencilFailOperationCCW(es2sw::ConvertStencilOp(mState.stencilFail));
+ device->setStencilZFailOperationCCW(es2sw::ConvertStencilOp(mState.stencilPassDepthFail));
+ device->setStencilPassOperationCCW(es2sw::ConvertStencilOp(mState.stencilPassDepthPass));
}
else
{
@@ -1937,17 +1515,11 @@
}
Device *device = getDevice();
- Program *program = getCurrentProgram();
device->resetInputStreams(false);
for(int i = 0; i < MAX_VERTEX_ATTRIBS; i++)
{
- if(program->getAttributeStream(i) == -1)
- {
- continue;
- }
-
sw::Resource *resource = attributes[i].vertexBuffer;
const void *buffer = (char*)resource->getBuffer() + attributes[i].offset;
@@ -1961,8 +1533,7 @@
attribute.count = attributes[i].count;
attribute.normalized = attributes[i].normalized;
- int stream = program->getAttributeStream(i);
- device->setInputStream(stream, attribute);
+ device->setInputStream(i, attribute);
}
return GL_NO_ERROR;
@@ -1982,111 +1553,61 @@
return err;
}
-// Applies the shaders and shader constants
-void Context::applyShaders()
-{
- Device *device = getDevice();
- Program *programObject = getCurrentProgram();
- sw::VertexShader *vertexShader = programObject->getVertexShader();
- sw::PixelShader *pixelShader = programObject->getPixelShader();
-
- device->setVertexShader(vertexShader);
- device->setPixelShader(pixelShader);
-
- if(programObject->getSerial() != mAppliedProgramSerial)
- {
- programObject->dirtyAllUniforms();
- mAppliedProgramSerial = programObject->getSerial();
- }
-
- programObject->applyUniforms();
-}
-
void Context::applyTextures()
{
- applyTextures(sw::SAMPLER_PIXEL);
- applyTextures(sw::SAMPLER_VERTEX);
-}
-
-void Context::applyTextures(sw::SamplerType samplerType)
-{
Device *device = getDevice();
- Program *programObject = getCurrentProgram();
- int samplerCount = (samplerType == sw::SAMPLER_PIXEL) ? MAX_TEXTURE_IMAGE_UNITS : MAX_VERTEX_TEXTURE_IMAGE_UNITS; // Range of samplers of given sampler type
-
- for(int samplerIndex = 0; samplerIndex < samplerCount; samplerIndex++)
+ for(int samplerIndex = 0; samplerIndex < MAX_TEXTURE_IMAGE_UNITS; samplerIndex++)
{
- int textureUnit = programObject->getSamplerMapping(samplerType, samplerIndex); // OpenGL texture image unit index
+ UNIMPLEMENTED();
+ TextureType textureType = TEXTURE_2D;
- if(textureUnit != -1)
+ Texture *texture = getSamplerTexture(samplerIndex, textureType);
+
+ if(texture->isSamplerComplete())
{
- TextureType textureType = programObject->getSamplerTextureType(samplerType, samplerIndex);
+ GLenum wrapS = texture->getWrapS();
+ GLenum wrapT = texture->getWrapT();
+ GLenum texFilter = texture->getMinFilter();
+ GLenum magFilter = texture->getMagFilter();
+ GLenum maxAnisotropy = texture->getMaxAnisotropy();
- Texture *texture = getSamplerTexture(textureUnit, textureType);
+ device->setAddressingModeU(sw::SAMPLER_PIXEL, samplerIndex, es2sw::ConvertTextureWrap(wrapS));
+ device->setAddressingModeV(sw::SAMPLER_PIXEL, samplerIndex, es2sw::ConvertTextureWrap(wrapT));
- if(texture->isSamplerComplete())
- {
- GLenum wrapS = texture->getWrapS();
- GLenum wrapT = texture->getWrapT();
- GLenum texFilter = texture->getMinFilter();
- GLenum magFilter = texture->getMagFilter();
- GLenum maxAnisotropy = texture->getMaxAnisotropy();
+ sw::FilterType minFilter;
+ sw::MipmapType mipFilter;
+ es2sw::ConvertMinFilter(texFilter, &minFilter, &mipFilter, maxAnisotropy);
+ // ASSERT(minFilter == es2sw::ConvertMagFilter(magFilter));
- device->setAddressingModeU(samplerType, samplerIndex, es2sw::ConvertTextureWrap(wrapS));
- device->setAddressingModeV(samplerType, samplerIndex, es2sw::ConvertTextureWrap(wrapT));
+ device->setTextureFilter(sw::SAMPLER_PIXEL, samplerIndex, minFilter);
+ // device->setTextureFilter(sw::SAMPLER_PIXEL, samplerIndex, es2sw::ConvertMagFilter(magFilter));
+ device->setMipmapFilter(sw::SAMPLER_PIXEL, samplerIndex, mipFilter);
+ device->setMaxAnisotropy(sw::SAMPLER_PIXEL, samplerIndex, maxAnisotropy);
- sw::FilterType minFilter;
- sw::MipmapType mipFilter;
- es2sw::ConvertMinFilter(texFilter, &minFilter, &mipFilter, maxAnisotropy);
- // ASSERT(minFilter == es2sw::ConvertMagFilter(magFilter));
-
- device->setTextureFilter(samplerType, samplerIndex, minFilter);
- // device->setTextureFilter(samplerType, samplerIndex, es2sw::ConvertMagFilter(magFilter));
- device->setMipmapFilter(samplerType, samplerIndex, mipFilter);
- device->setMaxAnisotropy(samplerType, samplerIndex, maxAnisotropy);
-
- applyTexture(samplerType, samplerIndex, texture);
- }
- else
- {
- applyTexture(samplerType, samplerIndex, 0);
- }
+ applyTexture(samplerIndex, texture);
}
else
{
- applyTexture(samplerType, samplerIndex, NULL);
+ applyTexture(samplerIndex, 0);
}
}
}
-void Context::applyTexture(sw::SamplerType type, int index, Texture *baseTexture)
+void Context::applyTexture(int index, Texture *baseTexture)
{
Device *device = getDevice();
- Program *program = getCurrentProgram();
- int sampler = (type == sw::SAMPLER_PIXEL) ? index : 16 + index;
- bool textureUsed = false;
-
- if(type == sw::SAMPLER_PIXEL)
- {
- textureUsed = program->getPixelShader()->usesSampler(index);
- }
- else if(type == sw::SAMPLER_VERTEX)
- {
- textureUsed = program->getVertexShader()->usesSampler(index);
- }
- else UNREACHABLE();
sw::Resource *resource = 0;
- if(baseTexture && textureUsed)
+ if(baseTexture)
{
resource = baseTexture->getResource();
}
- device->setTextureResource(sampler, resource);
+ device->setTextureResource(index, resource);
- if(baseTexture && textureUsed)
+ if(baseTexture)
{
int levelCount = baseTexture->getLevelCount();
@@ -2108,53 +1629,29 @@
}
Image *surface = texture->getImage(surfaceLevel);
- device->setTextureLevel(sampler, 0, mipmapLevel, surface, sw::TEXTURE_2D);
- }
- }
- else if(baseTexture->getTarget() == GL_TEXTURE_CUBE_MAP)
- {
- for(int face = 0; face < 6; face++)
- {
- TextureCubeMap *cubeTexture = static_cast<TextureCubeMap*>(baseTexture);
-
- for(int mipmapLevel = 0; mipmapLevel < MIPMAP_LEVELS; mipmapLevel++)
- {
- int surfaceLevel = mipmapLevel;
-
- if(surfaceLevel < 0)
- {
- surfaceLevel = 0;
- }
- else if(surfaceLevel >= levelCount)
- {
- surfaceLevel = levelCount - 1;
- }
-
- Image *surface = cubeTexture->getImage(face, surfaceLevel);
- device->setTextureLevel(sampler, face, mipmapLevel, surface, sw::TEXTURE_CUBE);
- }
+ device->setTextureLevel(index, 0, mipmapLevel, surface, sw::TEXTURE_2D);
}
}
else UNIMPLEMENTED();
}
else
{
- device->setTextureLevel(sampler, 0, 0, 0, sw::TEXTURE_NULL);
+ device->setTextureLevel(index, 0, 0, 0, sw::TEXTURE_NULL);
}
}
void Context::readPixels(GLint x, GLint y, GLsizei width, GLsizei height,
GLenum format, GLenum type, GLsizei *bufSize, void* pixels)
{
- Framebuffer *framebuffer = getReadFramebuffer();
+ Framebuffer *framebuffer = getFramebuffer();
int framebufferWidth, framebufferHeight, framebufferSamples;
- if(framebuffer->completeness(framebufferWidth, framebufferHeight, framebufferSamples) != GL_FRAMEBUFFER_COMPLETE)
+ if(framebuffer->completeness(framebufferWidth, framebufferHeight, framebufferSamples) != GL_FRAMEBUFFER_COMPLETE_OES)
{
- return error(GL_INVALID_FRAMEBUFFER_OPERATION);
+ return error(GL_INVALID_FRAMEBUFFER_OPERATION_OES);
}
- if(getReadFramebufferHandle() != 0 && framebufferSamples != 0)
+ if(getFramebufferHandle() != 0 && framebufferSamples != 0)
{
return error(GL_INVALID_OPERATION);
}
@@ -2355,11 +1852,11 @@
void Context::clear(GLbitfield mask)
{
- Framebuffer *framebuffer = getDrawFramebuffer();
+ Framebuffer *framebuffer = getFramebuffer();
- if(!framebuffer || framebuffer->completeness() != GL_FRAMEBUFFER_COMPLETE)
+ if(!framebuffer || framebuffer->completeness() != GL_FRAMEBUFFER_COMPLETE_OES)
{
- return error(GL_INVALID_FRAMEBUFFER_OPERATION);
+ return error(GL_INVALID_FRAMEBUFFER_OPERATION_OES);
}
if(!applyRenderTarget())
@@ -2408,11 +1905,6 @@
void Context::drawArrays(GLenum mode, GLint first, GLsizei count)
{
- if(!mState.currentProgram)
- {
- return error(GL_INVALID_OPERATION);
- }
-
Device *device = getDevice();
PrimitiveType primitiveType;
int primitiveCount;
@@ -2438,14 +1930,8 @@
return error(err);
}
- applyShaders();
applyTextures();
- if(!getCurrentProgram()->validateSamplers(false))
- {
- return error(GL_INVALID_OPERATION);
- }
-
if(!cullSkipsDraw(mode))
{
device->drawPrimitive(primitiveType, primitiveCount);
@@ -2454,11 +1940,6 @@
void Context::drawElements(GLenum mode, GLsizei count, GLenum type, const void *indices)
{
- if(!mState.currentProgram)
- {
- return error(GL_INVALID_OPERATION);
- }
-
if(!indices && !mState.elementArrayBuffer)
{
return error(GL_INVALID_OPERATION);
@@ -2497,14 +1978,8 @@
return error(err);
}
- applyShaders();
applyTextures();
- if(!getCurrentProgram()->validateSamplers(false))
- {
- return error(GL_INVALID_OPERATION);
- }
-
if(!cullSkipsDraw(mode))
{
device->drawIndexedPrimitive(primitiveType, indexInfo.indexOffset, primitiveCount, IndexDataManager::typeSize(type));
@@ -2584,7 +2059,7 @@
{
mInvalidFramebufferOperation = false;
- return GL_INVALID_FRAMEBUFFER_OPERATION;
+ return GL_INVALID_FRAMEBUFFER_OPERATION_OES;
}
return GL_NO_ERROR;
@@ -2652,17 +2127,11 @@
// as if FramebufferTexture2D had been called, with a texture of 0, for each attachment point to which this
// image was attached in the currently bound framebuffer.
- Framebuffer *readFramebuffer = getReadFramebuffer();
- Framebuffer *drawFramebuffer = getDrawFramebuffer();
+ Framebuffer *framebuffer = getFramebuffer();
- if(readFramebuffer)
+ if(framebuffer)
{
- readFramebuffer->detachTexture(texture);
- }
-
- if(drawFramebuffer && drawFramebuffer != readFramebuffer)
- {
- drawFramebuffer->detachTexture(texture);
+ framebuffer->detachTexture(texture);
}
}
@@ -2672,14 +2141,9 @@
// If a framebuffer that is currently bound to the target FRAMEBUFFER is deleted, it is as though
// BindFramebuffer had been executed with the target of FRAMEBUFFER and framebuffer of zero.
- if(mState.readFramebuffer == framebuffer)
+ if(mState.framebuffer == framebuffer)
{
- bindReadFramebuffer(0);
- }
-
- if(mState.drawFramebuffer == framebuffer)
- {
- bindDrawFramebuffer(0);
+ bindFramebuffer(0);
}
}
@@ -2699,17 +2163,11 @@
// then it is as if FramebufferRenderbuffer had been called, with a renderbuffer of 0, for each attachment
// point to which this image was attached in the currently bound framebuffer.
- Framebuffer *readFramebuffer = getReadFramebuffer();
- Framebuffer *drawFramebuffer = getDrawFramebuffer();
+ Framebuffer *framebuffer = getFramebuffer();
- if(readFramebuffer)
+ if(framebuffer)
{
- readFramebuffer->detachRenderbuffer(renderbuffer);
- }
-
- if(drawFramebuffer && drawFramebuffer != readFramebuffer)
- {
- drawFramebuffer->detachRenderbuffer(renderbuffer);
+ framebuffer->detachRenderbuffer(renderbuffer);
}
}
@@ -2749,277 +2207,6 @@
mVertexDataManager->dirtyCurrentValue(index);
}
-void Context::blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
- GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
- GLbitfield mask)
-{
- Device *device = getDevice();
-
- Framebuffer *readFramebuffer = getReadFramebuffer();
- Framebuffer *drawFramebuffer = getDrawFramebuffer();
-
- int readBufferWidth, readBufferHeight, readBufferSamples;
- int drawBufferWidth, drawBufferHeight, drawBufferSamples;
-
- if(!readFramebuffer || readFramebuffer->completeness(readBufferWidth, readBufferHeight, readBufferSamples) != GL_FRAMEBUFFER_COMPLETE ||
- !drawFramebuffer || drawFramebuffer->completeness(drawBufferWidth, drawBufferHeight, drawBufferSamples) != GL_FRAMEBUFFER_COMPLETE)
- {
- return error(GL_INVALID_FRAMEBUFFER_OPERATION);
- }
-
- if(drawBufferSamples > 1)
- {
- return error(GL_INVALID_OPERATION);
- }
-
- sw::Rect sourceRect;
- sw::Rect destRect;
-
- if(srcX0 < srcX1)
- {
- sourceRect.x0 = srcX0;
- sourceRect.x1 = srcX1;
- destRect.x0 = dstX0;
- destRect.x1 = dstX1;
- }
- else
- {
- sourceRect.x0 = srcX1;
- destRect.x0 = dstX1;
- sourceRect.x1 = srcX0;
- destRect.x1 = dstX0;
- }
-
- if(srcY0 < srcY1)
- {
- sourceRect.y0 = srcY0;
- destRect.y0 = dstY0;
- sourceRect.y1 = srcY1;
- destRect.y1 = dstY1;
- }
- else
- {
- sourceRect.y0 = srcY1;
- destRect.y0 = dstY1;
- sourceRect.y1 = srcY0;
- destRect.y1 = dstY0;
- }
-
- sw::Rect sourceScissoredRect = sourceRect;
- sw::Rect destScissoredRect = destRect;
-
- if(mState.scissorTest) // Only write to parts of the destination framebuffer which pass the scissor test
- {
- if(destRect.x0 < mState.scissorX)
- {
- int xDiff = mState.scissorX - destRect.x0;
- destScissoredRect.x0 = mState.scissorX;
- sourceScissoredRect.x0 += xDiff;
- }
-
- if(destRect.x1 > mState.scissorX + mState.scissorWidth)
- {
- int xDiff = destRect.x1 - (mState.scissorX + mState.scissorWidth);
- destScissoredRect.x1 = mState.scissorX + mState.scissorWidth;
- sourceScissoredRect.x1 -= xDiff;
- }
-
- if(destRect.y0 < mState.scissorY)
- {
- int yDiff = mState.scissorY - destRect.y0;
- destScissoredRect.y0 = mState.scissorY;
- sourceScissoredRect.y0 += yDiff;
- }
-
- if(destRect.y1 > mState.scissorY + mState.scissorHeight)
- {
- int yDiff = destRect.y1 - (mState.scissorY + mState.scissorHeight);
- destScissoredRect.y1 = mState.scissorY + mState.scissorHeight;
- sourceScissoredRect.y1 -= yDiff;
- }
- }
-
- sw::Rect sourceTrimmedRect = sourceScissoredRect;
- sw::Rect destTrimmedRect = destScissoredRect;
-
- // The source & destination rectangles also may need to be trimmed if they fall out of the bounds of
- // the actual draw and read surfaces.
- if(sourceTrimmedRect.x0 < 0)
- {
- int xDiff = 0 - sourceTrimmedRect.x0;
- sourceTrimmedRect.x0 = 0;
- destTrimmedRect.x0 += xDiff;
- }
-
- if(sourceTrimmedRect.x1 > readBufferWidth)
- {
- int xDiff = sourceTrimmedRect.x1 - readBufferWidth;
- sourceTrimmedRect.x1 = readBufferWidth;
- destTrimmedRect.x1 -= xDiff;
- }
-
- if(sourceTrimmedRect.y0 < 0)
- {
- int yDiff = 0 - sourceTrimmedRect.y0;
- sourceTrimmedRect.y0 = 0;
- destTrimmedRect.y0 += yDiff;
- }
-
- if(sourceTrimmedRect.y1 > readBufferHeight)
- {
- int yDiff = sourceTrimmedRect.y1 - readBufferHeight;
- sourceTrimmedRect.y1 = readBufferHeight;
- destTrimmedRect.y1 -= yDiff;
- }
-
- if(destTrimmedRect.x0 < 0)
- {
- int xDiff = 0 - destTrimmedRect.x0;
- destTrimmedRect.x0 = 0;
- sourceTrimmedRect.x0 += xDiff;
- }
-
- if(destTrimmedRect.x1 > drawBufferWidth)
- {
- int xDiff = destTrimmedRect.x1 - drawBufferWidth;
- destTrimmedRect.x1 = drawBufferWidth;
- sourceTrimmedRect.x1 -= xDiff;
- }
-
- if(destTrimmedRect.y0 < 0)
- {
- int yDiff = 0 - destTrimmedRect.y0;
- destTrimmedRect.y0 = 0;
- sourceTrimmedRect.y0 += yDiff;
- }
-
- if(destTrimmedRect.y1 > drawBufferHeight)
- {
- int yDiff = destTrimmedRect.y1 - drawBufferHeight;
- destTrimmedRect.y1 = drawBufferHeight;
- sourceTrimmedRect.y1 -= yDiff;
- }
-
- bool partialBufferCopy = false;
-
- if(sourceTrimmedRect.y1 - sourceTrimmedRect.y0 < readBufferHeight ||
- sourceTrimmedRect.x1 - sourceTrimmedRect.x0 < readBufferWidth ||
- destTrimmedRect.y1 - destTrimmedRect.y0 < drawBufferHeight ||
- destTrimmedRect.x1 - destTrimmedRect.x0 < drawBufferWidth ||
- sourceTrimmedRect.y0 != 0 || destTrimmedRect.y0 != 0 || sourceTrimmedRect.x0 != 0 || destTrimmedRect.x0 != 0)
- {
- partialBufferCopy = true;
- }
-
- bool blitRenderTarget = false;
- bool blitDepthStencil = false;
-
- if(mask & GL_COLOR_BUFFER_BIT)
- {
- const bool validReadType = readFramebuffer->getColorbufferType() == GL_TEXTURE_2D ||
- readFramebuffer->getColorbufferType() == GL_RENDERBUFFER;
- const bool validDrawType = drawFramebuffer->getColorbufferType() == GL_TEXTURE_2D ||
- drawFramebuffer->getColorbufferType() == GL_RENDERBUFFER;
- if(!validReadType || !validDrawType ||
- readFramebuffer->getColorbuffer()->getInternalFormat() != drawFramebuffer->getColorbuffer()->getInternalFormat())
- {
- ERR("Color buffer format conversion in BlitFramebufferANGLE not supported by this implementation");
- return error(GL_INVALID_OPERATION);
- }
-
- if(partialBufferCopy && readBufferSamples > 1)
- {
- return error(GL_INVALID_OPERATION);
- }
-
- blitRenderTarget = true;
- }
-
- if(mask & (GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT))
- {
- Renderbuffer *readDSBuffer = NULL;
- Renderbuffer *drawDSBuffer = NULL;
-
- // We support OES_packed_depth_stencil, and do not support a separately attached depth and stencil buffer, so if we have
- // both a depth and stencil buffer, it will be the same buffer.
-
- if(mask & GL_DEPTH_BUFFER_BIT)
- {
- if(readFramebuffer->getDepthbuffer() && drawFramebuffer->getDepthbuffer())
- {
- if(readFramebuffer->getDepthbufferType() != drawFramebuffer->getDepthbufferType() ||
- readFramebuffer->getDepthbuffer()->getInternalFormat() != drawFramebuffer->getDepthbuffer()->getInternalFormat())
- {
- return error(GL_INVALID_OPERATION);
- }
-
- blitDepthStencil = true;
- readDSBuffer = readFramebuffer->getDepthbuffer();
- drawDSBuffer = drawFramebuffer->getDepthbuffer();
- }
- }
-
- if(mask & GL_STENCIL_BUFFER_BIT)
- {
- if(readFramebuffer->getStencilbuffer() && drawFramebuffer->getStencilbuffer())
- {
- if(readFramebuffer->getStencilbufferType() != drawFramebuffer->getStencilbufferType() ||
- readFramebuffer->getStencilbuffer()->getInternalFormat() != drawFramebuffer->getStencilbuffer()->getInternalFormat())
- {
- return error(GL_INVALID_OPERATION);
- }
-
- blitDepthStencil = true;
- readDSBuffer = readFramebuffer->getStencilbuffer();
- drawDSBuffer = drawFramebuffer->getStencilbuffer();
- }
- }
-
- if(partialBufferCopy)
- {
- ERR("Only whole-buffer depth and stencil blits are supported by this implementation.");
- return error(GL_INVALID_OPERATION); // Only whole-buffer copies are permitted
- }
-
- if((drawDSBuffer && drawDSBuffer->getSamples() > 1) ||
- (readDSBuffer && readDSBuffer->getSamples() > 1))
- {
- return error(GL_INVALID_OPERATION);
- }
- }
-
- if(blitRenderTarget || blitDepthStencil)
- {
- if(blitRenderTarget)
- {
- Image *readRenderTarget = readFramebuffer->getRenderTarget();
- Image *drawRenderTarget = drawFramebuffer->getRenderTarget();
-
- bool success = device->stretchRect(readRenderTarget, &sourceRect, drawRenderTarget, &destRect, false);
-
- readRenderTarget->release();
- drawRenderTarget->release();
-
- if(!success)
- {
- ERR("BlitFramebufferANGLE failed.");
- return;
- }
- }
-
- if(blitDepthStencil)
- {
- bool success = device->stretchRect(readFramebuffer->getDepthStencil(), NULL, drawFramebuffer->getDepthStencil(), NULL, false);
-
- if(!success)
- {
- ERR("BlitFramebufferANGLE failed.");
- return;
- }
- }
- }
-}
-
}
// Exported functions for use by EGL
diff --git a/src/GLES2/libGLES_CM/Context.h b/src/GLES2/libGLES_CM/Context.h
index cbeb2bd..005d19d 100644
--- a/src/GLES2/libGLES_CM/Context.h
+++ b/src/GLES2/libGLES_CM/Context.h
@@ -12,8 +12,8 @@
// Context.h: Defines the Context class, managing all GL state and performing
// rendering operations. It is the GLES2 specific implementation of EGLContext.
-#ifndef LIBGLESV2_CONTEXT_H_
-#define LIBGLESV2_CONTEXT_H_
+#ifndef LIBGLES_CM_CONTEXT_H_
+#define LIBGLES_CM_CONTEXT_H_
#include "ResourceManager.h"
#include "HandleAllocator.h"
@@ -21,9 +21,8 @@
#include "Image.hpp"
#include "Renderer/Sampler.hpp"
-#define GL_APICALL
-#include <GLES2/gl2.h>
-#include <GLES2/gl2ext.h>
+#define GL_API
+#include <GLES/gl.h>
#define EGLAPI
#include <EGL/egl.h>
@@ -43,11 +42,8 @@
struct TranslatedIndexData;
class Buffer;
-class Shader;
-class Program;
class Texture;
class Texture2D;
-class TextureCubeMap;
class TextureExternal;
class Framebuffer;
class Renderbuffer;
@@ -59,8 +55,6 @@
class DepthStencilbuffer;
class VertexDataManager;
class IndexDataManager;
-class Fence;
-class Query;
enum
{
@@ -170,7 +164,6 @@
GLenum destBlendAlpha;
GLenum blendEquationRGB;
GLenum blendEquationAlpha;
- Color blendColor;
bool stencilTest;
GLenum stencilFunc;
GLint stencilRef;
@@ -179,13 +172,6 @@
GLenum stencilPassDepthFail;
GLenum stencilPassDepthPass;
GLuint stencilWritemask;
- GLenum stencilBackFunc;
- GLint stencilBackRef;
- GLuint stencilBackMask;
- GLenum stencilBackFail;
- GLenum stencilBackPassDepthFail;
- GLenum stencilBackPassDepthPass;
- GLuint stencilBackWritemask;
bool polygonOffsetFill;
GLfloat polygonOffsetFactor;
GLfloat polygonOffsetUnits;
@@ -199,7 +185,6 @@
GLfloat lineWidth;
GLenum generateMipmapHint;
- GLenum fragmentShaderDerivativeHint;
GLint viewportX;
GLint viewportY;
@@ -222,14 +207,11 @@
unsigned int activeSampler; // Active texture unit selector - GL_TEXTURE0
BindingPointer<Buffer> arrayBuffer;
BindingPointer<Buffer> elementArrayBuffer;
- GLuint readFramebuffer;
- GLuint drawFramebuffer;
+ GLuint framebuffer;
BindingPointer<Renderbuffer> renderbuffer;
- GLuint currentProgram;
VertexAttribute vertexAttribute[MAX_VERTEX_ATTRIBS];
BindingPointer<Texture> samplerTexture[TEXTURE_TYPE_COUNT][MAX_COMBINED_TEXTURE_IMAGE_UNITS];
- BindingPointer<Query> activeQuery[QUERY_TYPE_COUNT];
GLint unpackAlignment;
GLint packAlignment;
@@ -264,18 +246,14 @@
void setBlend(bool enabled);
bool isBlendEnabled() const;
void setBlendFactors(GLenum sourceRGB, GLenum destRGB, GLenum sourceAlpha, GLenum destAlpha);
- void setBlendColor(float red, float green, float blue, float alpha);
void setBlendEquation(GLenum rgbEquation, GLenum alphaEquation);
void setStencilTest(bool enabled);
bool isStencilTestEnabled() const;
void setStencilParams(GLenum stencilFunc, GLint stencilRef, GLuint stencilMask);
- void setStencilBackParams(GLenum stencilBackFunc, GLint stencilBackRef, GLuint stencilBackMask);
void setStencilWritemask(GLuint stencilWritemask);
- void setStencilBackWritemask(GLuint stencilBackWritemask);
void setStencilOperations(GLenum stencilFail, GLenum stencilPassDepthFail, GLenum stencilPassDepthPass);
- void setStencilBackOperations(GLenum stencilBackFail, GLenum stencilBackPassDepthFail, GLenum stencilBackPassDepthPass);
-
+
void setPolygonOffsetFill(bool enabled);
bool isPolygonOffsetFillEnabled() const;
void setPolygonOffsetParams(GLfloat factor, GLfloat units);
@@ -292,7 +270,6 @@
void setLineWidth(GLfloat width);
void setGenerateMipmapHint(GLenum hint);
- void setFragmentShaderDerivativeHint(GLenum hint);
void setViewportParams(GLint x, GLint y, GLsizei width, GLsizei height);
@@ -305,12 +282,9 @@
void setActiveSampler(unsigned int active);
- GLuint getReadFramebufferHandle() const;
- GLuint getDrawFramebufferHandle() const;
+ GLuint getFramebufferHandle() const;
GLuint getRenderbufferHandle() const;
- GLuint getActiveQuery(GLenum target) const;
-
GLuint getArrayBufferHandle() const;
void setEnableVertexAttribArray(unsigned int attribNum, bool enabled);
@@ -330,14 +304,10 @@
// These create and destroy methods are merely pass-throughs to
// ResourceManager, which owns these object types
GLuint createBuffer();
- GLuint createShader(GLenum type);
- GLuint createProgram();
GLuint createTexture();
GLuint createRenderbuffer();
void deleteBuffer(GLuint buffer);
- void deleteShader(GLuint shader);
- void deleteProgram(GLuint program);
void deleteTexture(GLuint texture);
void deleteRenderbuffer(GLuint renderbuffer);
@@ -345,26 +315,12 @@
GLuint createFramebuffer();
void deleteFramebuffer(GLuint framebuffer);
- // Fences are owned by the Context
- GLuint createFence();
- void deleteFence(GLuint fence);
-
- // Queries are owned by the Context
- GLuint createQuery();
- void deleteQuery(GLuint query);
-
void bindArrayBuffer(GLuint buffer);
void bindElementArrayBuffer(GLuint buffer);
void bindTexture2D(GLuint texture);
- void bindTextureCubeMap(GLuint texture);
void bindTextureExternal(GLuint texture);
- void bindReadFramebuffer(GLuint framebuffer);
- void bindDrawFramebuffer(GLuint framebuffer);
+ void bindFramebuffer(GLuint framebuffer);
void bindRenderbuffer(GLuint renderbuffer);
- void useProgram(GLuint program);
-
- void beginQuery(GLenum target, GLuint query);
- void endQuery(GLenum target);
void setFramebufferZero(Framebuffer *framebuffer);
@@ -373,29 +329,25 @@
void setVertexAttrib(GLuint index, const GLfloat *values);
Buffer *getBuffer(GLuint handle);
- Fence *getFence(GLuint handle);
- Shader *getShader(GLuint handle);
- Program *getProgram(GLuint handle);
virtual Texture *getTexture(GLuint handle);
Framebuffer *getFramebuffer(GLuint handle);
virtual Renderbuffer *getRenderbuffer(GLuint handle);
- Query *getQuery(GLuint handle, bool create, GLenum type);
Buffer *getArrayBuffer();
Buffer *getElementArrayBuffer();
- Program *getCurrentProgram();
Texture2D *getTexture2D();
- TextureCubeMap *getTextureCubeMap();
TextureExternal *getTextureExternal();
Texture *getSamplerTexture(unsigned int sampler, TextureType type);
- Framebuffer *getReadFramebuffer();
- Framebuffer *getDrawFramebuffer();
+ Framebuffer *getFramebuffer();
bool getFloatv(GLenum pname, GLfloat *params);
bool getIntegerv(GLenum pname, GLint *params);
bool getBooleanv(GLenum pname, GLboolean *params);
- bool getQueryParameterInfo(GLenum pname, GLenum *type, unsigned int *numParams);
+ int getQueryParameterNum(GLenum pname);
+ bool isQueryParameterInt(GLenum pname);
+ bool isQueryParameterFloat(GLenum pname);
+ bool isQueryParameterBool(GLenum pname);
void readPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei *bufSize, void* pixels);
void clear(GLbitfield mask);
@@ -413,20 +365,14 @@
GLenum getError();
static int getSupportedMultiSampleDepth(sw::Format format, int requested);
-
- void blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
- GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
- GLbitfield mask);
private:
bool applyRenderTarget();
void applyState(GLenum drawMode);
GLenum applyVertexBuffer(GLint base, GLint first, GLsizei count);
GLenum applyIndexBuffer(const void *indices, GLsizei count, GLenum mode, GLenum type, TranslatedIndexData *indexInfo);
- void applyShaders();
void applyTextures();
- void applyTextures(sw::SamplerType type);
- void applyTexture(sw::SamplerType type, int sampler, Texture *texture);
+ void applyTexture(int sampler, Texture *texture);
void detachBuffer(GLuint buffer);
void detachTexture(GLuint texture);
@@ -441,21 +387,12 @@
State mState;
BindingPointer<Texture2D> mTexture2DZero;
- BindingPointer<TextureCubeMap> mTextureCubeMapZero;
BindingPointer<TextureExternal> mTextureExternalZero;
typedef std::map<GLint, Framebuffer*> FramebufferMap;
FramebufferMap mFramebufferMap;
HandleAllocator mFramebufferHandleAllocator;
- typedef std::map<GLint, Fence*> FenceMap;
- FenceMap mFenceMap;
- HandleAllocator mFenceHandleAllocator;
-
- typedef std::map<GLint, Query*> QueryMap;
- QueryMap mQueryMap;
- HandleAllocator mQueryHandleAllocator;
-
VertexDataManager *mVertexDataManager;
IndexDataManager *mIndexDataManager;
@@ -467,8 +404,6 @@
bool mInvalidFramebufferOperation;
bool mHasBeenCurrent;
-
- unsigned int mAppliedProgramSerial;
// state caching flags
bool mDepthStateDirty;
diff --git a/src/GLES2/libGLES_CM/Device.cpp b/src/GLES2/libGLES_CM/Device.cpp
index c2cc36a..9150a42 100644
--- a/src/GLES2/libGLES_CM/Device.cpp
+++ b/src/GLES2/libGLES_CM/Device.cpp
@@ -118,28 +118,6 @@
setClipPlane(i, plane);
}
-
- pixelShader = 0;
- vertexShader = 0;
-
- pixelShaderDirty = true;
- pixelShaderConstantsFDirty = 0;
- vertexShaderDirty = true;
- vertexShaderConstantsFDirty = 0;
-
- for(int i = 0; i < 224; i++)
- {
- float zero[4] = {0, 0, 0, 0};
-
- setPixelShaderConstantF(i, zero, 1);
- }
-
- for(int i = 0; i < 256; i++)
- {
- float zero[4] = {0, 0, 0, 0};
-
- setVertexShaderConstantF(i, zero, 1);
- }
}
Device::~Device()
@@ -272,7 +250,7 @@
UNREACHABLE();
}
- Image *surface = new Image(0, width, height, format, GL_NONE, GL_NONE, multiSampleDepth, lockable, true);
+ Image *surface = new Image(0, width, height, format, GL_NONE_OES, GL_NONE_OES, multiSampleDepth, lockable, true);
if(!surface)
{
@@ -293,7 +271,7 @@
return 0;
}
- Image *surface = new Image(0, width, height, format, GL_NONE, GL_NONE, multiSampleDepth, lockable, true);
+ Image *surface = new Image(0, width, height, format, GL_NONE_OES, GL_NONE_OES, multiSampleDepth, lockable, true);
if(!surface)
{
@@ -414,30 +392,6 @@
setDepthStencil(depthStencil);
}
- void Device::setPixelShader(PixelShader *pixelShader)
- {
- TRACE("PixelShader *shader = 0x%0.8p", pixelShader);
-
- this->pixelShader = pixelShader;
- pixelShaderDirty = true;
- }
-
- void Device::setPixelShaderConstantF(unsigned int startRegister, const float *constantData, unsigned int count)
- {
- TRACE("unsigned int startRegister = %d, const int *constantData = 0x%0.8p, unsigned int count = %d", startRegister, constantData, count);
-
- for(unsigned int i = 0; i < count && startRegister + i < 224; i++)
- {
- pixelShaderConstantF[startRegister + i][0] = constantData[i * 4 + 0];
- pixelShaderConstantF[startRegister + i][1] = constantData[i * 4 + 1];
- pixelShaderConstantF[startRegister + i][2] = constantData[i * 4 + 2];
- pixelShaderConstantF[startRegister + i][3] = constantData[i * 4 + 3];
- }
-
- pixelShaderConstantsFDirty = max(startRegister + count, pixelShaderConstantsFDirty);
- pixelShaderDirty = true; // Reload DEF constants
- }
-
void Device::setScissorEnable(bool enable)
{
scissorEnable = enable;
@@ -469,30 +423,6 @@
scissorRect = rect;
}
- void Device::setVertexShader(VertexShader *vertexShader)
- {
- TRACE("VertexShader *shader = 0x%0.8p", vertexShader);
-
- this->vertexShader = vertexShader;
- vertexShaderDirty = true;
- }
-
- void Device::setVertexShaderConstantF(unsigned int startRegister, const float *constantData, unsigned int count)
- {
- TRACE("unsigned int startRegister = %d, const int *constantData = 0x%0.8p, unsigned int count = %d", startRegister, constantData, count);
-
- for(unsigned int i = 0; i < count && startRegister + i < 256; i++)
- {
- vertexShaderConstantF[startRegister + i][0] = constantData[i * 4 + 0];
- vertexShaderConstantF[startRegister + i][1] = constantData[i * 4 + 1];
- vertexShaderConstantF[startRegister + i][2] = constantData[i * 4 + 2];
- vertexShaderConstantF[startRegister + i][3] = constantData[i * 4 + 3];
- }
-
- vertexShaderConstantsFDirty = max(startRegister + count, vertexShaderConstantsFDirty);
- vertexShaderDirty = true; // Reload DEF constants
- }
-
void Device::setViewport(const Viewport &viewport)
{
TRACE("const Viewport *viewport = 0x%0.8p", viewport);
@@ -643,53 +573,8 @@
return false; // Zero-area target region
}
- bindShaderConstants();
-
return true;
}
-
- void Device::bindShaderConstants()
- {
- if(pixelShaderDirty)
- {
- if(pixelShader)
- {
- if(pixelShaderConstantsFDirty)
- {
- Renderer::setPixelShaderConstantF(0, pixelShaderConstantF[0], pixelShaderConstantsFDirty);
- }
-
- Renderer::setPixelShader(pixelShader); // Loads shader constants set with DEF
- pixelShaderConstantsFDirty = pixelShader->dirtyConstantsF; // Shader DEF'ed constants are dirty
- }
- else
- {
- setPixelShader(0);
- }
-
- pixelShaderDirty = false;
- }
-
- if(vertexShaderDirty)
- {
- if(vertexShader)
- {
- if(vertexShaderConstantsFDirty)
- {
- Renderer::setVertexShaderConstantF(0, vertexShaderConstantF[0], vertexShaderConstantsFDirty);
- }
-
- Renderer::setVertexShader(vertexShader); // Loads shader constants set with DEF
- vertexShaderConstantsFDirty = vertexShader->dirtyConstantsF; // Shader DEF'ed constants are dirty
- }
- else
- {
- setVertexShader(0);
- }
-
- vertexShaderDirty = false;
- }
- }
bool Device::bindViewport()
{
diff --git a/src/GLES2/libGLES_CM/Device.hpp b/src/GLES2/libGLES_CM/Device.hpp
index 4e0337d..ca54e29 100644
--- a/src/GLES2/libGLES_CM/Device.hpp
+++ b/src/GLES2/libGLES_CM/Device.hpp
@@ -59,13 +59,9 @@
virtual void drawIndexedPrimitive(PrimitiveType type, unsigned int indexOffset, unsigned int primitiveCount, int indexSize);
virtual void drawPrimitive(PrimitiveType primitiveType, unsigned int primiveCount);
virtual void setDepthStencilSurface(Image *newDepthStencil);
- virtual void setPixelShader(sw::PixelShader *shader);
- virtual void setPixelShaderConstantF(unsigned int startRegister, const float *constantData, unsigned int count);
virtual void setScissorEnable(bool enable);
virtual void setRenderTarget(Image *renderTarget);
virtual void setScissorRect(const sw::Rect &rect);
- virtual void setVertexShader(sw::VertexShader *shader);
- virtual void setVertexShaderConstantF(unsigned int startRegister, const float *constantData, unsigned int count);
virtual void setViewport(const Viewport &viewport);
virtual bool stretchRect(Image *sourceSurface, const sw::Rect *sourceRect, Image *destSurface, const sw::Rect *destRect, bool filter);
@@ -75,7 +71,6 @@
sw::Context *const context;
bool bindResources();
- void bindShaderConstants();
bool bindViewport(); // Also adjusts for scissoring
bool validRectangle(const sw::Rect *rect, Image *surface);
@@ -84,17 +79,6 @@
sw::Rect scissorRect;
bool scissorEnable;
- sw::PixelShader *pixelShader;
- sw::VertexShader *vertexShader;
-
- bool pixelShaderDirty;
- unsigned int pixelShaderConstantsFDirty;
- bool vertexShaderDirty;
- unsigned int vertexShaderConstantsFDirty;
-
- float pixelShaderConstantF[224][4];
- float vertexShaderConstantF[256][4];
-
Image *renderTarget;
Image *depthStencil;
};
diff --git a/src/GLES2/libGLES_CM/Fence.cpp b/src/GLES2/libGLES_CM/Fence.cpp
deleted file mode 100644
index 8221075..0000000
--- a/src/GLES2/libGLES_CM/Fence.cpp
+++ /dev/null
@@ -1,108 +0,0 @@
-// SwiftShader Software Renderer
-//
-// Copyright(c) 2005-2012 TransGaming Inc.
-//
-// All rights reserved. No part of this software may be copied, distributed, transmitted,
-// transcribed, stored in a retrieval system, translated into any human or computer
-// language by any means, or disclosed to third parties without the explicit written
-// agreement of TransGaming Inc. Without such an agreement, no rights or licenses, express
-// or implied, including but not limited to any patent rights, are granted to you.
-//
-
-// Fence.cpp: Implements the Fence class, which supports the GL_NV_fence extension.
-
-#include "Fence.h"
-
-#include "main.h"
-#include "Common/Thread.hpp"
-
-namespace gl
-{
-
-Fence::Fence()
-{
- mQuery = false;
- mCondition = GL_NONE;
- mStatus = GL_FALSE;
-}
-
-Fence::~Fence()
-{
- mQuery = false;
-}
-
-GLboolean Fence::isFence()
-{
- // GL_NV_fence spec:
- // A name returned by GenFencesNV, but not yet set via SetFenceNV, is not the name of an existing fence.
- return mQuery;
-}
-
-void Fence::setFence(GLenum condition)
-{
- mQuery = true;
- mCondition = condition;
- mStatus = GL_FALSE;
-}
-
-GLboolean Fence::testFence()
-{
- if(!mQuery)
- {
- return error(GL_INVALID_OPERATION, GL_TRUE);
- }
-
- UNIMPLEMENTED();
- mStatus = GL_TRUE;
-
- return mStatus;
-}
-
-void Fence::finishFence()
-{
- if(!mQuery)
- {
- return error(GL_INVALID_OPERATION);
- }
-
- while(!testFence())
- {
- sw::Thread::yield();
- }
-}
-
-void Fence::getFenceiv(GLenum pname, GLint *params)
-{
- if(!mQuery)
- {
- return error(GL_INVALID_OPERATION);
- }
-
- switch (pname)
- {
- case GL_FENCE_STATUS_NV:
- {
- // GL_NV_fence spec:
- // Once the status of a fence has been finished (via FinishFenceNV) or tested and the returned status is TRUE (via either TestFenceNV
- // or GetFenceivNV querying the FENCE_STATUS_NV), the status remains TRUE until the next SetFenceNV of the fence.
- if(mStatus)
- {
- params[0] = GL_TRUE;
- return;
- }
-
- mStatus = testFence();
-
- params[0] = mStatus;
- break;
- }
- case GL_FENCE_CONDITION_NV:
- params[0] = mCondition;
- break;
- default:
- return error(GL_INVALID_ENUM);
- break;
- }
-}
-
-}
diff --git a/src/GLES2/libGLES_CM/Fence.h b/src/GLES2/libGLES_CM/Fence.h
deleted file mode 100644
index bd6d9ac..0000000
--- a/src/GLES2/libGLES_CM/Fence.h
+++ /dev/null
@@ -1,43 +0,0 @@
-// SwiftShader Software Renderer
-//
-// Copyright(c) 2005-2012 TransGaming Inc.
-//
-// All rights reserved. No part of this software may be copied, distributed, transmitted,
-// transcribed, stored in a retrieval system, translated into any human or computer
-// language by any means, or disclosed to third parties without the explicit written
-// agreement of TransGaming Inc. Without such an agreement, no rights or licenses, express
-// or implied, including but not limited to any patent rights, are granted to you.
-//
-
-// Fence.h: Defines the Fence class, which supports the GL_NV_fence extension.
-
-#ifndef LIBGLESV2_FENCE_H_
-#define LIBGLESV2_FENCE_H_
-
-#define GL_APICALL
-#include <GLES2/gl2.h>
-
-namespace gl
-{
-
-class Fence
-{
- public:
- Fence();
- virtual ~Fence();
-
- GLboolean isFence();
- void setFence(GLenum condition);
- GLboolean testFence();
- void finishFence();
- void getFenceiv(GLenum pname, GLint *params);
-
- private:
- bool mQuery;
- GLenum mCondition;
- GLboolean mStatus;
-};
-
-}
-
-#endif // LIBGLESV2_FENCE_H_
diff --git a/src/GLES2/libGLES_CM/Framebuffer.cpp b/src/GLES2/libGLES_CM/Framebuffer.cpp
index 8ba7d9e..1832913 100644
--- a/src/GLES2/libGLES_CM/Framebuffer.cpp
+++ b/src/GLES2/libGLES_CM/Framebuffer.cpp
@@ -24,9 +24,9 @@
Framebuffer::Framebuffer()
{
- mColorbufferType = GL_NONE;
- mDepthbufferType = GL_NONE;
- mStencilbufferType = GL_NONE;
+ mColorbufferType = GL_NONE_OES;
+ mDepthbufferType = GL_NONE_OES;
+ mStencilbufferType = GL_NONE_OES;
}
Framebuffer::~Framebuffer()
@@ -41,11 +41,11 @@
Context *context = getContext();
Renderbuffer *buffer = NULL;
- if(type == GL_NONE)
+ if(type == GL_NONE_OES)
{
buffer = NULL;
}
- else if(type == GL_RENDERBUFFER)
+ else if(type == GL_RENDERBUFFER_OES)
{
buffer = context->getRenderbuffer(handle);
}
@@ -63,19 +63,19 @@
void Framebuffer::setColorbuffer(GLenum type, GLuint colorbuffer)
{
- mColorbufferType = (colorbuffer != 0) ? type : GL_NONE;
+ mColorbufferType = (colorbuffer != 0) ? type : GL_NONE_OES;
mColorbufferPointer.set(lookupRenderbuffer(type, colorbuffer));
}
void Framebuffer::setDepthbuffer(GLenum type, GLuint depthbuffer)
{
- mDepthbufferType = (depthbuffer != 0) ? type : GL_NONE;
+ mDepthbufferType = (depthbuffer != 0) ? type : GL_NONE_OES;
mDepthbufferPointer.set(lookupRenderbuffer(type, depthbuffer));
}
void Framebuffer::setStencilbuffer(GLenum type, GLuint stencilbuffer)
{
- mStencilbufferType = (stencilbuffer != 0) ? type : GL_NONE;
+ mStencilbufferType = (stencilbuffer != 0) ? type : GL_NONE_OES;
mStencilbufferPointer.set(lookupRenderbuffer(type, stencilbuffer));
}
@@ -83,40 +83,40 @@
{
if(mColorbufferPointer.id() == texture && IsTextureTarget(mColorbufferType))
{
- mColorbufferType = GL_NONE;
+ mColorbufferType = GL_NONE_OES;
mColorbufferPointer.set(NULL);
}
if(mDepthbufferPointer.id() == texture && IsTextureTarget(mDepthbufferType))
{
- mDepthbufferType = GL_NONE;
+ mDepthbufferType = GL_NONE_OES;
mDepthbufferPointer.set(NULL);
}
if(mStencilbufferPointer.id() == texture && IsTextureTarget(mStencilbufferType))
{
- mStencilbufferType = GL_NONE;
+ mStencilbufferType = GL_NONE_OES;
mStencilbufferPointer.set(NULL);
}
}
void Framebuffer::detachRenderbuffer(GLuint renderbuffer)
{
- if(mColorbufferPointer.id() == renderbuffer && mColorbufferType == GL_RENDERBUFFER)
+ if(mColorbufferPointer.id() == renderbuffer && mColorbufferType == GL_RENDERBUFFER_OES)
{
- mColorbufferType = GL_NONE;
+ mColorbufferType = GL_NONE_OES;
mColorbufferPointer.set(NULL);
}
- if(mDepthbufferPointer.id() == renderbuffer && mDepthbufferType == GL_RENDERBUFFER)
+ if(mDepthbufferPointer.id() == renderbuffer && mDepthbufferType == GL_RENDERBUFFER_OES)
{
- mDepthbufferType = GL_NONE;
+ mDepthbufferType = GL_NONE_OES;
mDepthbufferPointer.set(NULL);
}
- if(mStencilbufferPointer.id() == renderbuffer && mStencilbufferType == GL_RENDERBUFFER)
+ if(mStencilbufferPointer.id() == renderbuffer && mStencilbufferType == GL_RENDERBUFFER_OES)
{
- mStencilbufferType = GL_NONE;
+ mStencilbufferType = GL_NONE_OES;
mStencilbufferPointer.set(NULL);
}
}
@@ -201,7 +201,7 @@
bool Framebuffer::hasStencil()
{
- if(mStencilbufferType != GL_NONE)
+ if(mStencilbufferType != GL_NONE_OES)
{
Renderbuffer *stencilbufferObject = getStencilbuffer();
@@ -229,25 +229,25 @@
height = -1;
samples = -1;
- if(mColorbufferType != GL_NONE)
+ if(mColorbufferType != GL_NONE_OES)
{
Renderbuffer *colorbuffer = getColorbuffer();
if(!colorbuffer)
{
- return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
+ return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_OES;
}
if(colorbuffer->getWidth() == 0 || colorbuffer->getHeight() == 0)
{
- return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
+ return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_OES;
}
- if(mColorbufferType == GL_RENDERBUFFER)
+ if(mColorbufferType == GL_RENDERBUFFER_OES)
{
if(!gl::IsColorRenderable(colorbuffer->getFormat()))
{
- return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
+ return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_OES;
}
}
else if(IsTextureTarget(mColorbufferType))
@@ -259,18 +259,18 @@
format == GL_LUMINANCE ||
format == GL_LUMINANCE_ALPHA)
{
- return GL_FRAMEBUFFER_UNSUPPORTED;
+ return GL_FRAMEBUFFER_UNSUPPORTED_OES;
}
if(gl::IsDepthTexture(format) || gl::IsStencilTexture(format))
{
- return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
+ return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_OES;
}
}
else
{
UNREACHABLE();
- return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
+ return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_OES;
}
width = colorbuffer->getWidth();
@@ -281,38 +281,38 @@
Renderbuffer *depthbuffer = NULL;
Renderbuffer *stencilbuffer = NULL;
- if(mDepthbufferType != GL_NONE)
+ if(mDepthbufferType != GL_NONE_OES)
{
depthbuffer = getDepthbuffer();
if(!depthbuffer)
{
- return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
+ return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_OES;
}
if(depthbuffer->getWidth() == 0 || depthbuffer->getHeight() == 0)
{
- return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
+ return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_OES;
}
- if(mDepthbufferType == GL_RENDERBUFFER)
+ if(mDepthbufferType == GL_RENDERBUFFER_OES)
{
if(!gl::IsDepthRenderable(depthbuffer->getFormat()))
{
- return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
+ return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_OES;
}
}
else if(IsTextureTarget(mDepthbufferType))
{
if(!gl::IsDepthTexture(depthbuffer->getFormat()))
{
- return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
+ return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_OES;
}
}
else
{
UNREACHABLE();
- return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
+ return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_OES;
}
if(width == -1 || height == -1)
@@ -323,33 +323,33 @@
}
else if(width != depthbuffer->getWidth() || height != depthbuffer->getHeight())
{
- return GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS;
+ return GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_OES;
}
else if(samples != depthbuffer->getSamples())
{
- return GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_ANGLE;
+ UNREACHABLE();
}
}
- if(mStencilbufferType != GL_NONE)
+ if(mStencilbufferType != GL_NONE_OES)
{
stencilbuffer = getStencilbuffer();
if(!stencilbuffer)
{
- return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
+ return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_OES;
}
if(stencilbuffer->getWidth() == 0 || stencilbuffer->getHeight() == 0)
{
- return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
+ return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_OES;
}
- if(mStencilbufferType == GL_RENDERBUFFER)
+ if(mStencilbufferType == GL_RENDERBUFFER_OES)
{
if(!gl::IsStencilRenderable(stencilbuffer->getFormat()))
{
- return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
+ return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_OES;
}
}
else if(IsTextureTarget(mStencilbufferType))
@@ -358,13 +358,13 @@
if(!gl::IsStencilTexture(internalformat))
{
- return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
+ return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_OES;
}
}
else
{
UNREACHABLE();
- return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
+ return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_OES;
}
if(width == -1 || height == -1)
@@ -375,11 +375,12 @@
}
else if(width != stencilbuffer->getWidth() || height != stencilbuffer->getHeight())
{
- return GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS;
+ return GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_OES;
}
else if(samples != stencilbuffer->getSamples())
{
- return GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_ANGLE;
+ UNREACHABLE();
+ return GL_FRAMEBUFFER_UNSUPPORTED_OES; // GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_OES;
}
}
@@ -387,16 +388,16 @@
// since we only support packed_depth_stencil and not separate depth and stencil
if(depthbuffer && stencilbuffer && (depthbuffer != stencilbuffer))
{
- return GL_FRAMEBUFFER_UNSUPPORTED;
+ return GL_FRAMEBUFFER_UNSUPPORTED_OES;
}
// We need to have at least one attachment to be complete
if(width == -1 || height == -1)
{
- return GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT;
+ return GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_OES;
}
- return GL_FRAMEBUFFER_COMPLETE;
+ return GL_FRAMEBUFFER_COMPLETE_OES;
}
DefaultFramebuffer::DefaultFramebuffer(Colorbuffer *colorbuffer, DepthStencilbuffer *depthStencil)
@@ -407,17 +408,17 @@
mDepthbufferPointer.set(depthStencilRenderbuffer);
mStencilbufferPointer.set(depthStencilRenderbuffer);
- mColorbufferType = GL_RENDERBUFFER;
- mDepthbufferType = (depthStencilRenderbuffer->getDepthSize() != 0) ? GL_RENDERBUFFER : GL_NONE;
- mStencilbufferType = (depthStencilRenderbuffer->getStencilSize() != 0) ? GL_RENDERBUFFER : GL_NONE;
+ mColorbufferType = GL_RENDERBUFFER_OES;
+ mDepthbufferType = (depthStencilRenderbuffer->getDepthSize() != 0) ? GL_RENDERBUFFER_OES : GL_NONE_OES;
+ mStencilbufferType = (depthStencilRenderbuffer->getStencilSize() != 0) ? GL_RENDERBUFFER_OES : GL_NONE_OES;
}
GLenum DefaultFramebuffer::completeness()
{
// The default framebuffer should always be complete
- ASSERT(Framebuffer::completeness() == GL_FRAMEBUFFER_COMPLETE);
+ ASSERT(Framebuffer::completeness() == GL_FRAMEBUFFER_COMPLETE_OES);
- return GL_FRAMEBUFFER_COMPLETE;
+ return GL_FRAMEBUFFER_COMPLETE_OES;
}
}
diff --git a/src/GLES2/libGLES_CM/Framebuffer.h b/src/GLES2/libGLES_CM/Framebuffer.h
index c3e0f0b..1b60462 100644
--- a/src/GLES2/libGLES_CM/Framebuffer.h
+++ b/src/GLES2/libGLES_CM/Framebuffer.h
@@ -12,14 +12,14 @@
// Framebuffer.h: Defines the Framebuffer class. Implements GL framebuffer
// objects and related functionality. [OpenGL ES 2.0.24] section 4.4 page 105.
-#ifndef LIBGLESV2_FRAMEBUFFER_H_
-#define LIBGLESV2_FRAMEBUFFER_H_
+#ifndef LIBGLES_CM_FRAMEBUFFER_H_
+#define LIBGLES_CM_FRAMEBUFFER_H_
#include "RefCountObject.h"
#include "Image.hpp"
-#define GL_APICALL
-#include <GLES2/gl2.h>
+#define GL_API
+#include <GLES/gl.h>
namespace gl
{
@@ -87,4 +87,4 @@
}
-#endif // LIBGLESV2_FRAMEBUFFER_H_
+#endif // LIBGLES_CM_FRAMEBUFFER_H_
diff --git a/src/GLES2/libGLES_CM/HandleAllocator.h b/src/GLES2/libGLES_CM/HandleAllocator.h
index 3dc5a34..82c94d6 100644
--- a/src/GLES2/libGLES_CM/HandleAllocator.h
+++ b/src/GLES2/libGLES_CM/HandleAllocator.h
@@ -12,11 +12,11 @@
// HandleAllocator.h: Defines the HandleAllocator class, which is used to
// allocate GL handles.
-#ifndef LIBGLESV2_HANDLEALLOCATOR_H_
-#define LIBGLESV2_HANDLEALLOCATOR_H_
+#ifndef LIBGLES_CM_HANDLEALLOCATOR_H_
+#define LIBGLES_CM_HANDLEALLOCATOR_H_
-#define GL_APICALL
-#include <GLES2/gl2.h>
+#define GL_API
+#include <GLES/gl.h>
#include <vector>
@@ -43,4 +43,4 @@
}
-#endif // LIBGLESV2_HANDLEALLOCATOR_H_
+#endif // LIBGLES_CM_HANDLEALLOCATOR_H_
diff --git a/src/GLES2/libGLES_CM/Image.cpp b/src/GLES2/libGLES_CM/Image.cpp
index a2950c6..8302343 100644
--- a/src/GLES2/libGLES_CM/Image.cpp
+++ b/src/GLES2/libGLES_CM/Image.cpp
@@ -16,7 +16,8 @@
#include "../common/debug.h"
#include "Common/Thread.hpp"
-#include <GLES2/gl2ext.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GLES/glext.h>
namespace gl
{
@@ -150,24 +151,12 @@
{
return sw::FORMAT_DXT1;
}
- else if(format == GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE)
- {
- return sw::FORMAT_DXT3;
- }
- else if(format == GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE)
- {
- return sw::FORMAT_DXT5;
- }
else
#endif
if(type == GL_FLOAT)
{
return sw::FORMAT_A32B32G32R32F;
}
- else if(type == GL_HALF_FLOAT_OES)
- {
- return sw::FORMAT_A16B16G16R16F;
- }
else if(type == GL_UNSIGNED_BYTE)
{
if(format == GL_LUMINANCE)
@@ -192,14 +181,6 @@
}
else UNREACHABLE();
}
- else if(type == GL_UNSIGNED_SHORT || type == GL_UNSIGNED_INT)
- {
- if(format == GL_DEPTH_COMPONENT)
- {
- return sw::FORMAT_D32FS8_TEXTURE;
- }
- else UNREACHABLE();
- }
else if(type == GL_UNSIGNED_INT_24_8_OES)
{
if(format == GL_DEPTH_STENCIL_OES)
@@ -312,28 +293,6 @@
default: UNREACHABLE();
}
break;
- case GL_HALF_FLOAT_OES:
- switch(format)
- {
- // float textures are converted to RGBA, not BGRA
- case GL_ALPHA:
- loadAlphaHalfFloatImageData(xoffset, yoffset, width, height, inputPitch, input, buffer);
- break;
- case GL_LUMINANCE:
- loadLuminanceHalfFloatImageData(xoffset, yoffset, width, height, inputPitch, input, buffer);
- break;
- case GL_LUMINANCE_ALPHA:
- loadLuminanceAlphaHalfFloatImageData(xoffset, yoffset, width, height, inputPitch, input, buffer);
- break;
- case GL_RGB:
- loadRGBHalfFloatImageData(xoffset, yoffset, width, height, inputPitch, input, buffer);
- break;
- case GL_RGBA:
- loadRGBAHalfFloatImageData(xoffset, yoffset, width, height, inputPitch, input, buffer);
- break;
- default: UNREACHABLE();
- }
- break;
case GL_UNSIGNED_SHORT:
loadD16ImageData(xoffset, yoffset, width, height, inputPitch, input, buffer);
break;
diff --git a/src/GLES2/libGLES_CM/Image.hpp b/src/GLES2/libGLES_CM/Image.hpp
index faae7d5..43216a5 100644
--- a/src/GLES2/libGLES_CM/Image.hpp
+++ b/src/GLES2/libGLES_CM/Image.hpp
@@ -14,8 +14,8 @@
#include "Renderer/Surface.hpp"
-#define GL_APICALL
-#include <GLES2/gl2.h>
+#define GL_API
+#include <GLES/gl.h>
namespace gl
{
diff --git a/src/GLES2/libGLES_CM/IndexDataManager.cpp b/src/GLES2/libGLES_CM/IndexDataManager.cpp
index 3dbfe44..d4f7fac 100644
--- a/src/GLES2/libGLES_CM/IndexDataManager.cpp
+++ b/src/GLES2/libGLES_CM/IndexDataManager.cpp
@@ -49,10 +49,6 @@
{
memcpy(output, input, count * sizeof(GLubyte));
}
- else if(type == GL_UNSIGNED_INT)
- {
- memcpy(output, input, count * sizeof(GLuint));
- }
else if(type == GL_UNSIGNED_SHORT)
{
memcpy(output, input, count * sizeof(GLushort));
@@ -79,10 +75,6 @@
{
computeRange(static_cast<const GLubyte*>(indices), count, minIndex, maxIndex);
}
- else if(type == GL_UNSIGNED_INT)
- {
- computeRange(static_cast<const GLuint*>(indices), count, minIndex, maxIndex);
- }
else if(type == GL_UNSIGNED_SHORT)
{
computeRange(static_cast<const GLushort*>(indices), count, minIndex, maxIndex);
@@ -106,7 +98,6 @@
{
case GL_UNSIGNED_BYTE: alignedOffset = (offset % sizeof(GLubyte) == 0); break;
case GL_UNSIGNED_SHORT: alignedOffset = (offset % sizeof(GLushort) == 0); break;
- case GL_UNSIGNED_INT: alignedOffset = (offset % sizeof(GLuint) == 0); break;
default: UNREACHABLE(); alignedOffset = false;
}
@@ -159,7 +150,6 @@
{
switch(type)
{
- case GL_UNSIGNED_INT: return sizeof(GLuint);
case GL_UNSIGNED_SHORT: return sizeof(GLushort);
case GL_UNSIGNED_BYTE: return sizeof(GLubyte);
default: UNREACHABLE(); return sizeof(GLushort);
diff --git a/src/GLES2/libGLES_CM/IndexDataManager.h b/src/GLES2/libGLES_CM/IndexDataManager.h
index 059e9fc..7d886a3 100644
--- a/src/GLES2/libGLES_CM/IndexDataManager.h
+++ b/src/GLES2/libGLES_CM/IndexDataManager.h
@@ -12,13 +12,13 @@
// IndexDataManager.h: Defines the IndexDataManager, a class that
// runs the Buffer translation process for index buffers.
-#ifndef LIBGLESV2_INDEXDATAMANAGER_H_
-#define LIBGLESV2_INDEXDATAMANAGER_H_
+#ifndef LIBGLES_CM_INDEXDATAMANAGER_H_
+#define LIBGLES_CM_INDEXDATAMANAGER_H_
#include "Context.h"
-#define GL_APICALL
-#include <GLES2/gl2.h>
+#define GL_API
+#include <GLES/gl.h>
namespace gl
{
@@ -66,4 +66,4 @@
}
-#endif // LIBGLESV2_INDEXDATAMANAGER_H_
+#endif // LIBGLES_CM_INDEXDATAMANAGER_H_
diff --git a/src/GLES2/libGLES_CM/Program.cpp b/src/GLES2/libGLES_CM/Program.cpp
deleted file mode 100644
index ca0ddd6..0000000
--- a/src/GLES2/libGLES_CM/Program.cpp
+++ /dev/null
@@ -1,2294 +0,0 @@
-// SwiftShader Software Renderer
-//
-// Copyright(c) 2005-2013 TransGaming Inc.
-//
-// All rights reserved. No part of this software may be copied, distributed, transmitted,
-// transcribed, stored in a retrieval system, translated into any human or computer
-// language by any means, or disclosed to third parties without the explicit written
-// agreement of TransGaming Inc. Without such an agreement, no rights or licenses, express
-// or implied, including but not limited to any patent rights, are granted to you.
-//
-
-// Program.cpp: Implements the Program class. Implements GL program objects
-// and related functionality. [OpenGL ES 2.0.24] section 2.10.3 page 28.
-
-#include "Program.h"
-
-#include "main.h"
-#include "Shader.h"
-#include "utilities.h"
-#include "common/debug.h"
-#include "Shader/PixelShader.hpp"
-#include "Shader/VertexShader.hpp"
-
-#include <string>
-#include <stdlib.h>
-
-namespace gl
-{
- unsigned int Program::currentSerial = 1;
-
- std::string str(int i)
- {
- char buffer[20];
- sprintf(buffer, "%d", i);
- return buffer;
- }
-
- Uniform::Uniform(GLenum type, GLenum precision, const std::string &name, unsigned int arraySize) : type(type), precision(precision), name(name), arraySize(arraySize)
- {
- int bytes = UniformTypeSize(type) * size();
- data = new unsigned char[bytes];
- memset(data, 0, bytes);
- dirty = true;
-
- psRegisterIndex = -1;
- vsRegisterIndex = -1;
- }
-
- Uniform::~Uniform()
- {
- delete[] data;
- }
-
- bool Uniform::isArray() const
- {
- return arraySize >= 1;
- }
-
- int Uniform::size() const
- {
- return arraySize > 0 ? arraySize : 1;
- }
-
- int Uniform::registerCount() const
- {
- return size() * VariableRowCount(type);
- }
-
- UniformLocation::UniformLocation(const std::string &name, unsigned int element, unsigned int index) : name(name), element(element), index(index)
- {
- }
-
- Program::Program(ResourceManager *manager, GLuint handle) : resourceManager(manager), handle(handle), serial(issueSerial())
- {
- device = getDevice();
-
- fragmentShader = 0;
- vertexShader = 0;
- pixelBinary = 0;
- vertexBinary = 0;
-
- infoLog = 0;
- validated = false;
-
- unlink();
-
- orphaned = false;
- referenceCount = 0;
- }
-
- Program::~Program()
- {
- unlink();
-
- if(vertexShader)
- {
- vertexShader->release();
- }
-
- if(fragmentShader)
- {
- fragmentShader->release();
- }
- }
-
- bool Program::attachShader(Shader *shader)
- {
- if(shader->getType() == GL_VERTEX_SHADER)
- {
- if(vertexShader)
- {
- return false;
- }
-
- vertexShader = (VertexShader*)shader;
- vertexShader->addRef();
- }
- else if(shader->getType() == GL_FRAGMENT_SHADER)
- {
- if(fragmentShader)
- {
- return false;
- }
-
- fragmentShader = (FragmentShader*)shader;
- fragmentShader->addRef();
- }
- else UNREACHABLE();
-
- return true;
- }
-
- bool Program::detachShader(Shader *shader)
- {
- if(shader->getType() == GL_VERTEX_SHADER)
- {
- if(vertexShader != shader)
- {
- return false;
- }
-
- vertexShader->release();
- vertexShader = 0;
- }
- else if(shader->getType() == GL_FRAGMENT_SHADER)
- {
- if(fragmentShader != shader)
- {
- return false;
- }
-
- fragmentShader->release();
- fragmentShader = 0;
- }
- else UNREACHABLE();
-
- return true;
- }
-
- int Program::getAttachedShadersCount() const
- {
- return (vertexShader ? 1 : 0) + (fragmentShader ? 1 : 0);
- }
-
- sw::PixelShader *Program::getPixelShader()
- {
- return pixelBinary;
- }
-
- sw::VertexShader *Program::getVertexShader()
- {
- return vertexBinary;
- }
-
- void Program::bindAttributeLocation(GLuint index, const char *name)
- {
- if(index < MAX_VERTEX_ATTRIBS)
- {
- for(int i = 0; i < MAX_VERTEX_ATTRIBS; i++)
- {
- attributeBinding[i].erase(name);
- }
-
- attributeBinding[index].insert(name);
- }
- }
-
- GLuint Program::getAttributeLocation(const char *name)
- {
- if(name)
- {
- for(int index = 0; index < MAX_VERTEX_ATTRIBS; index++)
- {
- if(linkedAttribute[index].name == std::string(name))
- {
- return index;
- }
- }
- }
-
- return -1;
- }
-
- int Program::getAttributeStream(int attributeIndex)
- {
- ASSERT(attributeIndex >= 0 && attributeIndex < MAX_VERTEX_ATTRIBS);
-
- return attributeStream[attributeIndex];
- }
-
- // Returns the index of the texture image unit (0-19) corresponding to a sampler index (0-15 for the pixel shader and 0-3 for the vertex shader)
- GLint Program::getSamplerMapping(sw::SamplerType type, unsigned int samplerIndex)
- {
- GLuint logicalTextureUnit = -1;
-
- switch(type)
- {
- case sw::SAMPLER_PIXEL:
- ASSERT(samplerIndex < sizeof(samplersPS) / sizeof(samplersPS[0]));
-
- if(samplersPS[samplerIndex].active)
- {
- logicalTextureUnit = samplersPS[samplerIndex].logicalTextureUnit;
- }
- break;
- case sw::SAMPLER_VERTEX:
- ASSERT(samplerIndex < sizeof(samplersVS) / sizeof(samplersVS[0]));
-
- if(samplersVS[samplerIndex].active)
- {
- logicalTextureUnit = samplersVS[samplerIndex].logicalTextureUnit;
- }
- break;
- default: UNREACHABLE();
- }
-
- if(logicalTextureUnit >= 0 && logicalTextureUnit < MAX_COMBINED_TEXTURE_IMAGE_UNITS)
- {
- return logicalTextureUnit;
- }
-
- return -1;
- }
-
- // Returns the texture type for a given sampler type and index (0-15 for the pixel shader and 0-3 for the vertex shader)
- TextureType Program::getSamplerTextureType(sw::SamplerType type, unsigned int samplerIndex)
- {
- switch(type)
- {
- case sw::SAMPLER_PIXEL:
- ASSERT(samplerIndex < sizeof(samplersPS)/sizeof(samplersPS[0]));
- ASSERT(samplersPS[samplerIndex].active);
- return samplersPS[samplerIndex].textureType;
- case sw::SAMPLER_VERTEX:
- ASSERT(samplerIndex < sizeof(samplersVS)/sizeof(samplersVS[0]));
- ASSERT(samplersVS[samplerIndex].active);
- return samplersVS[samplerIndex].textureType;
- default: UNREACHABLE();
- }
-
- return TEXTURE_2D;
- }
-
- GLint Program::getUniformLocation(std::string name)
- {
- int subscript = 0;
-
- // Strip any trailing array operator and retrieve the subscript
- size_t open = name.find_last_of('[');
- size_t close = name.find_last_of(']');
- if(open != std::string::npos && close == name.length() - 1)
- {
- subscript = atoi(name.substr(open + 1).c_str());
- name.erase(open);
- }
-
- unsigned int numUniforms = uniformIndex.size();
- for(unsigned int location = 0; location < numUniforms; location++)
- {
- if(uniformIndex[location].name == name &&
- uniformIndex[location].element == subscript)
- {
- return location;
- }
- }
-
- return -1;
- }
-
- bool Program::setUniform1fv(GLint location, GLsizei count, const GLfloat* v)
- {
- if(location < 0 || location >= (int)uniformIndex.size())
- {
- return false;
- }
-
- Uniform *targetUniform = uniforms[uniformIndex[location].index];
- targetUniform->dirty = true;
-
- int size = targetUniform->size();
-
- if(size == 1 && count > 1)
- {
- return false; // Attempting to write an array to a non-array uniform is an INVALID_OPERATION
- }
-
- count = std::min(size - (int)uniformIndex[location].element, count);
-
- if(targetUniform->type == GL_FLOAT)
- {
- memcpy(targetUniform->data + uniformIndex[location].element * sizeof(GLfloat),
- v, sizeof(GLfloat) * count);
- }
- else if(targetUniform->type == GL_BOOL)
- {
- GLboolean *boolParams = (GLboolean*)targetUniform->data + uniformIndex[location].element;
-
- for(int i = 0; i < count; i++)
- {
- if(v[i] == 0.0f)
- {
- boolParams[i] = GL_FALSE;
- }
- else
- {
- boolParams[i] = GL_TRUE;
- }
- }
- }
- else
- {
- return false;
- }
-
- return true;
- }
-
- bool Program::setUniform2fv(GLint location, GLsizei count, const GLfloat *v)
- {
- if(location < 0 || location >= (int)uniformIndex.size())
- {
- return false;
- }
-
- Uniform *targetUniform = uniforms[uniformIndex[location].index];
- targetUniform->dirty = true;
-
- int size = targetUniform->size();
-
- if(size == 1 && count > 1)
- {
- return false; // Attempting to write an array to a non-array uniform is an INVALID_OPERATION
- }
-
- count = std::min(size - (int)uniformIndex[location].element, count);
-
- if(targetUniform->type == GL_FLOAT_VEC2)
- {
- memcpy(targetUniform->data + uniformIndex[location].element * sizeof(GLfloat) * 2,
- v, 2 * sizeof(GLfloat) * count);
- }
- else if(targetUniform->type == GL_BOOL_VEC2)
- {
- GLboolean *boolParams = (GLboolean*)targetUniform->data + uniformIndex[location].element * 2;
-
- for(int i = 0; i < count * 2; i++)
- {
- if(v[i] == 0.0f)
- {
- boolParams[i] = GL_FALSE;
- }
- else
- {
- boolParams[i] = GL_TRUE;
- }
- }
- }
- else
- {
- return false;
- }
-
- return true;
- }
-
- bool Program::setUniform3fv(GLint location, GLsizei count, const GLfloat *v)
- {
- if(location < 0 || location >= (int)uniformIndex.size())
- {
- return false;
- }
-
- Uniform *targetUniform = uniforms[uniformIndex[location].index];
- targetUniform->dirty = true;
-
- int size = targetUniform->size();
-
- if(size == 1 && count > 1)
- {
- return false; // Attempting to write an array to a non-array uniform is an INVALID_OPERATION
- }
-
- count = std::min(size - (int)uniformIndex[location].element, count);
-
- if(targetUniform->type == GL_FLOAT_VEC3)
- {
- memcpy(targetUniform->data + uniformIndex[location].element * sizeof(GLfloat) * 3,
- v, 3 * sizeof(GLfloat) * count);
- }
- else if(targetUniform->type == GL_BOOL_VEC3)
- {
- GLboolean *boolParams = (GLboolean*)targetUniform->data + uniformIndex[location].element * 3;
-
- for(int i = 0; i < count * 3; i++)
- {
- if(v[i] == 0.0f)
- {
- boolParams[i] = GL_FALSE;
- }
- else
- {
- boolParams[i] = GL_TRUE;
- }
- }
- }
- else
- {
- return false;
- }
-
- return true;
- }
-
- bool Program::setUniform4fv(GLint location, GLsizei count, const GLfloat *v)
- {
- if(location < 0 || location >= (int)uniformIndex.size())
- {
- return false;
- }
-
- Uniform *targetUniform = uniforms[uniformIndex[location].index];
- targetUniform->dirty = true;
-
- int size = targetUniform->size();
-
- if(size == 1 && count > 1)
- {
- return false; // Attempting to write an array to a non-array uniform is an INVALID_OPERATION
- }
-
- count = std::min(size - (int)uniformIndex[location].element, count);
-
- if(targetUniform->type == GL_FLOAT_VEC4)
- {
- memcpy(targetUniform->data + uniformIndex[location].element * sizeof(GLfloat) * 4,
- v, 4 * sizeof(GLfloat) * count);
- }
- else if(targetUniform->type == GL_BOOL_VEC4)
- {
- GLboolean *boolParams = (GLboolean*)targetUniform->data + uniformIndex[location].element * 4;
-
- for(int i = 0; i < count * 4; i++)
- {
- if(v[i] == 0.0f)
- {
- boolParams[i] = GL_FALSE;
- }
- else
- {
- boolParams[i] = GL_TRUE;
- }
- }
- }
- else
- {
- return false;
- }
-
- return true;
- }
-
- bool Program::setUniformMatrix2fv(GLint location, GLsizei count, const GLfloat *value)
- {
- if(location < 0 || location >= (int)uniformIndex.size())
- {
- return false;
- }
-
- Uniform *targetUniform = uniforms[uniformIndex[location].index];
- targetUniform->dirty = true;
-
- if(targetUniform->type != GL_FLOAT_MAT2)
- {
- return false;
- }
-
- int size = targetUniform->size();
-
- if(size == 1 && count > 1)
- {
- return false; // Attempting to write an array to a non-array uniform is an INVALID_OPERATION
- }
-
- count = std::min(size - (int)uniformIndex[location].element, count);
-
- memcpy(targetUniform->data + uniformIndex[location].element * sizeof(GLfloat) * 4,
- value, 4 * sizeof(GLfloat) * count);
-
- return true;
- }
-
- bool Program::setUniformMatrix3fv(GLint location, GLsizei count, const GLfloat *value)
- {
- if(location < 0 || location >= (int)uniformIndex.size())
- {
- return false;
- }
-
- Uniform *targetUniform = uniforms[uniformIndex[location].index];
- targetUniform->dirty = true;
-
- if(targetUniform->type != GL_FLOAT_MAT3)
- {
- return false;
- }
-
- int size = targetUniform->size();
-
- if(size == 1 && count > 1)
- {
- return false; // Attempting to write an array to a non-array uniform is an INVALID_OPERATION
- }
-
- count = std::min(size - (int)uniformIndex[location].element, count);
-
- memcpy(targetUniform->data + uniformIndex[location].element * sizeof(GLfloat) * 9,
- value, 9 * sizeof(GLfloat) * count);
-
- return true;
- }
-
- bool Program::setUniformMatrix4fv(GLint location, GLsizei count, const GLfloat *value)
- {
- if(location < 0 || location >= (int)uniformIndex.size())
- {
- return false;
- }
-
- Uniform *targetUniform = uniforms[uniformIndex[location].index];
- targetUniform->dirty = true;
-
- if(targetUniform->type != GL_FLOAT_MAT4)
- {
- return false;
- }
-
- int size = targetUniform->size();
-
- if(size == 1 && count > 1)
- {
- return false; // Attempting to write an array to a non-array uniform is an INVALID_OPERATION
- }
-
- count = std::min(size - (int)uniformIndex[location].element, count);
-
- memcpy(targetUniform->data + uniformIndex[location].element * sizeof(GLfloat) * 16,
- value, 16 * sizeof(GLfloat) * count);
-
- return true;
- }
-
- bool Program::setUniform1iv(GLint location, GLsizei count, const GLint *v)
- {
- if(location < 0 || location >= (int)uniformIndex.size())
- {
- return false;
- }
-
- Uniform *targetUniform = uniforms[uniformIndex[location].index];
- targetUniform->dirty = true;
-
- int size = targetUniform->size();
-
- if(size == 1 && count > 1)
- {
- return false; // Attempting to write an array to a non-array uniform is an INVALID_OPERATION
- }
-
- count = std::min(size - (int)uniformIndex[location].element, count);
-
- if(targetUniform->type == GL_INT ||
- targetUniform->type == GL_SAMPLER_2D ||
- targetUniform->type == GL_SAMPLER_CUBE ||
- targetUniform->type == GL_SAMPLER_EXTERNAL_OES)
- {
- memcpy(targetUniform->data + uniformIndex[location].element * sizeof(GLint),
- v, sizeof(GLint) * count);
- }
- else if(targetUniform->type == GL_BOOL)
- {
- GLboolean *boolParams = new GLboolean[count];
-
- for(int i = 0; i < count; i++)
- {
- if(v[i] == 0)
- {
- boolParams[i] = GL_FALSE;
- }
- else
- {
- boolParams[i] = GL_TRUE;
- }
- }
-
- memcpy(targetUniform->data + uniformIndex[location].element * sizeof(GLboolean),
- boolParams, sizeof(GLboolean) * count);
-
- delete[] boolParams;
- }
- else
- {
- return false;
- }
-
- return true;
- }
-
- bool Program::setUniform2iv(GLint location, GLsizei count, const GLint *v)
- {
- if(location < 0 || location >= (int)uniformIndex.size())
- {
- return false;
- }
-
- Uniform *targetUniform = uniforms[uniformIndex[location].index];
- targetUniform->dirty = true;
-
- int size = targetUniform->size();
-
- if(size == 1 && count > 1)
- {
- return false; // Attempting to write an array to a non-array uniform is an INVALID_OPERATION
- }
-
- count = std::min(size - (int)uniformIndex[location].element, count);
-
- if(targetUniform->type == GL_INT_VEC2)
- {
- memcpy(targetUniform->data + uniformIndex[location].element * sizeof(GLint) * 2,
- v, 2 * sizeof(GLint) * count);
- }
- else if(targetUniform->type == GL_BOOL_VEC2)
- {
- GLboolean *boolParams = new GLboolean[count * 2];
-
- for(int i = 0; i < count * 2; i++)
- {
- if(v[i] == 0)
- {
- boolParams[i] = GL_FALSE;
- }
- else
- {
- boolParams[i] = GL_TRUE;
- }
- }
-
- memcpy(targetUniform->data + uniformIndex[location].element * sizeof(GLboolean) * 2,
- boolParams, 2 * sizeof(GLboolean) * count);
-
- delete[] boolParams;
- }
- else
- {
- return false;
- }
-
- return true;
- }
-
- bool Program::setUniform3iv(GLint location, GLsizei count, const GLint *v)
- {
- if(location < 0 || location >= (int)uniformIndex.size())
- {
- return false;
- }
-
- Uniform *targetUniform = uniforms[uniformIndex[location].index];
- targetUniform->dirty = true;
-
- int size = targetUniform->size();
-
- if(size == 1 && count > 1)
- {
- return false; // Attempting to write an array to a non-array uniform is an INVALID_OPERATION
- }
-
- count = std::min(size - (int)uniformIndex[location].element, count);
-
- if(targetUniform->type == GL_INT_VEC3)
- {
- memcpy(targetUniform->data + uniformIndex[location].element * sizeof(GLint) * 3,
- v, 3 * sizeof(GLint) * count);
- }
- else if(targetUniform->type == GL_BOOL_VEC3)
- {
- GLboolean *boolParams = new GLboolean[count * 3];
-
- for(int i = 0; i < count * 3; i++)
- {
- if(v[i] == 0)
- {
- boolParams[i] = GL_FALSE;
- }
- else
- {
- boolParams[i] = GL_TRUE;
- }
- }
-
- memcpy(targetUniform->data + uniformIndex[location].element * sizeof(GLboolean) * 3,
- boolParams, 3 * sizeof(GLboolean) * count);
-
- delete[] boolParams;
- }
- else
- {
- return false;
- }
-
- return true;
- }
-
- bool Program::setUniform4iv(GLint location, GLsizei count, const GLint *v)
- {
- if(location < 0 || location >= (int)uniformIndex.size())
- {
- return false;
- }
-
- Uniform *targetUniform = uniforms[uniformIndex[location].index];
- targetUniform->dirty = true;
-
- int size = targetUniform->size();
-
- if(size == 1 && count > 1)
- {
- return false; // Attempting to write an array to a non-array uniform is an INVALID_OPERATION
- }
-
- count = std::min(size - (int)uniformIndex[location].element, count);
-
- if(targetUniform->type == GL_INT_VEC4)
- {
- memcpy(targetUniform->data + uniformIndex[location].element * sizeof(GLint) * 4,
- v, 4 * sizeof(GLint) * count);
- }
- else if(targetUniform->type == GL_BOOL_VEC4)
- {
- GLboolean *boolParams = new GLboolean[count * 4];
-
- for(int i = 0; i < count * 4; i++)
- {
- if(v[i] == 0)
- {
- boolParams[i] = GL_FALSE;
- }
- else
- {
- boolParams[i] = GL_TRUE;
- }
- }
-
- memcpy(targetUniform->data + uniformIndex[location].element * sizeof(GLboolean) * 4,
- boolParams, 4 * sizeof(GLboolean) * count);
-
- delete[] boolParams;
- }
- else
- {
- return false;
- }
-
- return true;
- }
-
- bool Program::getUniformfv(GLint location, GLsizei *bufSize, GLfloat *params)
- {
- if(location < 0 || location >= (int)uniformIndex.size())
- {
- return false;
- }
-
- Uniform *targetUniform = uniforms[uniformIndex[location].index];
- unsigned int count = UniformComponentCount(targetUniform->type);
-
- // Sized query - ensure the provided buffer is large enough
- if(bufSize && *bufSize < count * sizeof(GLfloat))
- {
- return false;
- }
-
- switch (UniformComponentType(targetUniform->type))
- {
- case GL_BOOL:
- {
- GLboolean *boolParams = (GLboolean*)targetUniform->data + uniformIndex[location].element * count;
-
- for(unsigned int i = 0; i < count; i++)
- {
- params[i] = (boolParams[i] == GL_FALSE) ? 0.0f : 1.0f;
- }
- }
- break;
- case GL_FLOAT:
- memcpy(params, targetUniform->data + uniformIndex[location].element * count * sizeof(GLfloat),
- count * sizeof(GLfloat));
- break;
- case GL_INT:
- {
- GLint *intParams = (GLint*)targetUniform->data + uniformIndex[location].element * count;
-
- for(unsigned int i = 0; i < count; i++)
- {
- params[i] = (float)intParams[i];
- }
- }
- break;
- default: UNREACHABLE();
- }
-
- return true;
- }
-
- bool Program::getUniformiv(GLint location, GLsizei *bufSize, GLint *params)
- {
- if(location < 0 || location >= (int)uniformIndex.size())
- {
- return false;
- }
-
- Uniform *targetUniform = uniforms[uniformIndex[location].index];
- unsigned int count = UniformComponentCount(targetUniform->type);
-
- // Sized query - ensure the provided buffer is large enough
- if(bufSize && *bufSize < count * sizeof(GLint))
- {
- return false;
- }
-
- switch (UniformComponentType(targetUniform->type))
- {
- case GL_BOOL:
- {
- GLboolean *boolParams = targetUniform->data + uniformIndex[location].element * count;
-
- for(unsigned int i = 0; i < count; i++)
- {
- params[i] = (GLint)boolParams[i];
- }
- }
- break;
- case GL_FLOAT:
- {
- GLfloat *floatParams = (GLfloat*)targetUniform->data + uniformIndex[location].element * count;
-
- for(unsigned int i = 0; i < count; i++)
- {
- params[i] = (GLint)floatParams[i];
- }
- }
- break;
- case GL_INT:
- memcpy(params, targetUniform->data + uniformIndex[location].element * count * sizeof(GLint),
- count * sizeof(GLint));
- break;
- default: UNREACHABLE();
- }
-
- return true;
- }
-
- void Program::dirtyAllUniforms()
- {
- unsigned int numUniforms = uniforms.size();
- for(unsigned int index = 0; index < numUniforms; index++)
- {
- uniforms[index]->dirty = true;
- }
- }
-
- // Applies all the uniforms set for this program object to the device
- void Program::applyUniforms()
- {
- unsigned int numUniforms = uniformIndex.size();
- for(unsigned int location = 0; location < numUniforms; location++)
- {
- if(uniformIndex[location].element != 0)
- {
- continue;
- }
-
- Uniform *targetUniform = uniforms[uniformIndex[location].index];
-
- if(targetUniform->dirty)
- {
- int size = targetUniform->size();
- GLfloat *f = (GLfloat*)targetUniform->data;
- GLint *i = (GLint*)targetUniform->data;
- GLboolean *b = (GLboolean*)targetUniform->data;
-
- switch(targetUniform->type)
- {
- case GL_BOOL: applyUniform1bv(location, size, b); break;
- case GL_BOOL_VEC2: applyUniform2bv(location, size, b); break;
- case GL_BOOL_VEC3: applyUniform3bv(location, size, b); break;
- case GL_BOOL_VEC4: applyUniform4bv(location, size, b); break;
- case GL_FLOAT: applyUniform1fv(location, size, f); break;
- case GL_FLOAT_VEC2: applyUniform2fv(location, size, f); break;
- case GL_FLOAT_VEC3: applyUniform3fv(location, size, f); break;
- case GL_FLOAT_VEC4: applyUniform4fv(location, size, f); break;
- case GL_FLOAT_MAT2: applyUniformMatrix2fv(location, size, f); break;
- case GL_FLOAT_MAT3: applyUniformMatrix3fv(location, size, f); break;
- case GL_FLOAT_MAT4: applyUniformMatrix4fv(location, size, f); break;
- case GL_SAMPLER_2D:
- case GL_SAMPLER_CUBE:
- case GL_SAMPLER_EXTERNAL_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;
- case GL_INT_VEC4: applyUniform4iv(location, size, i); break;
- default:
- UNREACHABLE();
- }
-
- targetUniform->dirty = false;
- }
- }
- }
-
- // Packs varyings into generic varying registers, using the algorithm from [OpenGL ES Shading Language 1.00 rev. 17] appendix A section 7 page 111
- // Returns the number of used varying registers, or -1 if unsuccesful
- int Program::packVaryings(const Varying *packing[][4])
- {
- for(VaryingList::iterator varying = fragmentShader->varyings.begin(); varying != fragmentShader->varyings.end(); varying++)
- {
- int n = VariableRowCount(varying->type) * varying->size();
- int m = VariableColumnCount(varying->type);
- bool success = false;
-
- if(m == 2 || m == 3 || m == 4)
- {
- for(int r = 0; r <= MAX_VARYING_VECTORS - n && !success; r++)
- {
- bool available = true;
-
- for(int y = 0; y < n && available; y++)
- {
- for(int x = 0; x < m && available; x++)
- {
- if(packing[r + y][x])
- {
- available = false;
- }
- }
- }
-
- if(available)
- {
- varying->reg = r;
- varying->col = 0;
-
- for(int y = 0; y < n; y++)
- {
- for(int x = 0; x < m; x++)
- {
- packing[r + y][x] = &*varying;
- }
- }
-
- success = true;
- }
- }
-
- if(!success && m == 2)
- {
- for(int r = MAX_VARYING_VECTORS - n; r >= 0 && !success; r--)
- {
- bool available = true;
-
- for(int y = 0; y < n && available; y++)
- {
- for(int x = 2; x < 4 && available; x++)
- {
- if(packing[r + y][x])
- {
- available = false;
- }
- }
- }
-
- if(available)
- {
- varying->reg = r;
- varying->col = 2;
-
- for(int y = 0; y < n; y++)
- {
- for(int x = 2; x < 4; x++)
- {
- packing[r + y][x] = &*varying;
- }
- }
-
- success = true;
- }
- }
- }
- }
- else if(m == 1)
- {
- int space[4] = {0};
-
- for(int y = 0; y < MAX_VARYING_VECTORS; y++)
- {
- for(int x = 0; x < 4; x++)
- {
- space[x] += packing[y][x] ? 0 : 1;
- }
- }
-
- int column = 0;
-
- for(int x = 0; x < 4; x++)
- {
- if(space[x] >= n && space[x] < space[column])
- {
- column = x;
- }
- }
-
- if(space[column] >= n)
- {
- for(int r = 0; r < MAX_VARYING_VECTORS; r++)
- {
- if(!packing[r][column])
- {
- varying->reg = r;
-
- for(int y = r; y < r + n; y++)
- {
- packing[y][column] = &*varying;
- }
-
- break;
- }
- }
-
- varying->col = column;
-
- success = true;
- }
- }
- else UNREACHABLE();
-
- if(!success)
- {
- appendToInfoLog("Could not pack varying %s", varying->name.c_str());
-
- return -1;
- }
- }
-
- // Return the number of used registers
- int registers = 0;
-
- for(int r = 0; r < MAX_VARYING_VECTORS; r++)
- {
- if(packing[r][0] || packing[r][1] || packing[r][2] || packing[r][3])
- {
- registers++;
- }
- }
-
- return registers;
- }
-
- bool Program::linkVaryings()
- {
- for(VaryingList::iterator input = fragmentShader->varyings.begin(); input != fragmentShader->varyings.end(); input++)
- {
- bool matched = false;
-
- for(VaryingList::iterator output = vertexShader->varyings.begin(); output != vertexShader->varyings.end(); output++)
- {
- if(output->name == input->name)
- {
- if(output->type != input->type || output->size() != input->size())
- {
- appendToInfoLog("Type of vertex varying %s does not match that of the fragment varying", output->name.c_str());
-
- return false;
- }
-
- matched = true;
- break;
- }
- }
-
- if(!matched)
- {
- appendToInfoLog("Fragment varying %s does not match any vertex varying", input->name.c_str());
-
- return false;
- }
- }
-
- VaryingList &psVaryings = fragmentShader->varyings;
- VaryingList &vsVaryings = vertexShader->varyings;
-
- for(VaryingList::iterator output = vsVaryings.begin(); output != vsVaryings.end(); output++)
- {
- for(VaryingList::iterator input = psVaryings.begin(); input != psVaryings.end(); input++)
- {
- if(output->name == input->name)
- {
- int in = input->reg;
- int out = output->reg;
- int components = VariableColumnCount(output->type);
- int registers = VariableRowCount(output->type) * output->size();
-
- ASSERT(in >= 0);
-
- if(in + registers > MAX_VARYING_VECTORS)
- {
- appendToInfoLog("Too many varyings");
- return false;
- }
-
- if(out >= 0)
- {
- if(out + registers > MAX_VARYING_VECTORS)
- {
- appendToInfoLog("Too many varyings");
- return false;
- }
-
- for(int i = 0; i < registers; i++)
- {
- if(components >= 1) vertexBinary->output[out + i][0] = sw::Shader::Semantic(sw::Shader::USAGE_COLOR, in + i);
- if(components >= 2) vertexBinary->output[out + i][1] = sw::Shader::Semantic(sw::Shader::USAGE_COLOR, in + i);
- if(components >= 3) vertexBinary->output[out + i][2] = sw::Shader::Semantic(sw::Shader::USAGE_COLOR, in + i);
- if(components >= 4) vertexBinary->output[out + i][3] = sw::Shader::Semantic(sw::Shader::USAGE_COLOR, in + i);
- }
- }
- else // Vertex varying is declared but not written to
- {
- for(int i = 0; i < registers; i++)
- {
- if(components >= 1) pixelBinary->semantic[in + i][0] = sw::Shader::Semantic();
- if(components >= 2) pixelBinary->semantic[in + i][1] = sw::Shader::Semantic();
- if(components >= 3) pixelBinary->semantic[in + i][2] = sw::Shader::Semantic();
- if(components >= 4) pixelBinary->semantic[in + i][3] = sw::Shader::Semantic();
- }
- }
-
- break;
- }
- }
- }
-
- return true;
- }
-
- // Links the code of the vertex and pixel shader by matching up their varyings,
- // compiling them into binaries, determining the attribute mappings, and collecting
- // a list of uniforms
- void Program::link()
- {
- unlink();
-
- if(!fragmentShader || !fragmentShader->isCompiled())
- {
- return;
- }
-
- if(!vertexShader || !vertexShader->isCompiled())
- {
- return;
- }
-
- vertexBinary = new sw::VertexShader(vertexShader->getVertexShader());
- pixelBinary = new sw::PixelShader(fragmentShader->getPixelShader());
-
- if(!linkVaryings())
- {
- return;
- }
-
- if(!linkAttributes())
- {
- return;
- }
-
- if(!linkUniforms(fragmentShader))
- {
- return;
- }
-
- if(!linkUniforms(vertexShader))
- {
- return;
- }
-
- linked = true; // Success
- }
-
- // Determines the mapping between GL attributes and vertex stream usage indices
- bool Program::linkAttributes()
- {
- unsigned int usedLocations = 0;
-
- // Link attributes that have a binding location
- for(sh::ActiveAttributes::iterator attribute = vertexShader->activeAttributes.begin(); attribute != vertexShader->activeAttributes.end(); attribute++)
- {
- int location = getAttributeBinding(attribute->name);
-
- if(location != -1) // Set by glBindAttribLocation
- {
- if(!linkedAttribute[location].name.empty())
- {
- // Multiple active attributes bound to the same location; not an error
- }
-
- linkedAttribute[location] = *attribute;
-
- int rows = VariableRowCount(attribute->type);
-
- if(rows + location > MAX_VERTEX_ATTRIBS)
- {
- appendToInfoLog("Active attribute (%s) at location %d is too big to fit", attribute->name.c_str(), location);
- return false;
- }
-
- for(int i = 0; i < rows; i++)
- {
- usedLocations |= 1 << (location + i);
- }
- }
- }
-
- // Link attributes that don't have a binding location
- for(sh::ActiveAttributes::iterator attribute = vertexShader->activeAttributes.begin(); attribute != vertexShader->activeAttributes.end(); attribute++)
- {
- int location = getAttributeBinding(attribute->name);
-
- if(location == -1) // Not set by glBindAttribLocation
- {
- int rows = VariableRowCount(attribute->type);
- int availableIndex = AllocateFirstFreeBits(&usedLocations, rows, MAX_VERTEX_ATTRIBS);
-
- if(availableIndex == -1 || availableIndex + rows > MAX_VERTEX_ATTRIBS)
- {
- appendToInfoLog("Too many active attributes (%s)", attribute->name.c_str());
- return false; // Fail to link
- }
-
- linkedAttribute[availableIndex] = *attribute;
- }
- }
-
- for(int attributeIndex = 0; attributeIndex < MAX_VERTEX_ATTRIBS; )
- {
- int index = vertexShader->getSemanticIndex(linkedAttribute[attributeIndex].name);
- int rows = std::max(VariableRowCount(linkedAttribute[attributeIndex].type), 1);
-
- for(int r = 0; r < rows; r++)
- {
- attributeStream[attributeIndex++] = index++;
- }
- }
-
- return true;
- }
-
- int Program::getAttributeBinding(const std::string &name)
- {
- for(int location = 0; location < MAX_VERTEX_ATTRIBS; location++)
- {
- if(attributeBinding[location].find(name) != attributeBinding[location].end())
- {
- return location;
- }
- }
-
- return -1;
- }
-
- bool Program::linkUniforms(Shader *shader)
- {
- const sh::ActiveUniforms &activeUniforms = shader->activeUniforms;
-
- for(unsigned int uniformIndex = 0; uniformIndex < activeUniforms.size(); uniformIndex++)
- {
- const sh::Uniform &uniform = activeUniforms[uniformIndex];
-
- if(!defineUniform(shader->getType(), uniform.type, uniform.precision, uniform.name, uniform.arraySize, uniform.registerIndex))
- {
- return false;
- }
- }
-
- return true;
- }
-
- 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)
- {
- int index = registerIndex;
-
- do
- {
- if(shader == GL_VERTEX_SHADER)
- {
- if(index < MAX_VERTEX_TEXTURE_IMAGE_UNITS)
- {
- samplersVS[index].active = true;
- samplersVS[index].textureType = (type == GL_SAMPLER_CUBE) ? TEXTURE_CUBE : TEXTURE_2D;
- samplersVS[index].logicalTextureUnit = 0;
- }
- else
- {
- appendToInfoLog("Vertex shader sampler count exceeds MAX_VERTEX_TEXTURE_IMAGE_UNITS (%d).", MAX_VERTEX_TEXTURE_IMAGE_UNITS);
- return false;
- }
- }
- else if(shader == GL_FRAGMENT_SHADER)
- {
- if(index < MAX_TEXTURE_IMAGE_UNITS)
- {
- samplersPS[index].active = true;
- samplersPS[index].textureType = (type == GL_SAMPLER_CUBE) ? TEXTURE_CUBE : TEXTURE_2D;
- samplersPS[index].logicalTextureUnit = 0;
- }
- else
- {
- appendToInfoLog("Pixel shader sampler count exceeds MAX_TEXTURE_IMAGE_UNITS (%d).", MAX_TEXTURE_IMAGE_UNITS);
- return false;
- }
- }
- else UNREACHABLE();
-
- index++;
- }
- while(index < registerIndex + arraySize);
- }
-
- Uniform *uniform = 0;
- GLint location = getUniformLocation(name);
-
- if(location >= 0) // Previously defined, types must match
- {
- uniform = uniforms[uniformIndex[location].index];
-
- if(uniform->type != type)
- {
- appendToInfoLog("Types for uniform %s do not match between the vertex and fragment shader", uniform->name.c_str());
- return false;
- }
-
- if(uniform->precision != precision)
- {
- appendToInfoLog("Precisions for uniform %s do not match between the vertex and fragment shader", uniform->name.c_str());
- return false;
- }
- }
- else
- {
- uniform = new Uniform(type, precision, name, arraySize);
- }
-
- if(!uniform)
- {
- return false;
- }
-
- if(shader == GL_VERTEX_SHADER)
- {
- uniform->vsRegisterIndex = registerIndex;
- }
- else if(shader == GL_FRAGMENT_SHADER)
- {
- uniform->psRegisterIndex = registerIndex;
- }
- else UNREACHABLE();
-
- if(location == -1) // Not previously defined
- {
- uniforms.push_back(uniform);
- unsigned int index = uniforms.size() - 1;
-
- for(unsigned int i = 0; i < uniform->size(); i++)
- {
- uniformIndex.push_back(UniformLocation(name, i, index));
- }
- }
-
- if(shader == GL_VERTEX_SHADER)
- {
- if(registerIndex + uniform->registerCount() > MAX_VERTEX_UNIFORM_VECTORS)
- {
- appendToInfoLog("Vertex shader active uniforms exceed GL_MAX_VERTEX_UNIFORM_VECTORS (%d)", MAX_VERTEX_UNIFORM_VECTORS);
- return false;
- }
- }
- else if(shader == GL_FRAGMENT_SHADER)
- {
- if(registerIndex + uniform->registerCount() > MAX_FRAGMENT_UNIFORM_VECTORS)
- {
- appendToInfoLog("Fragment shader active uniforms exceed GL_MAX_FRAGMENT_UNIFORM_VECTORS (%d)", MAX_FRAGMENT_UNIFORM_VECTORS);
- return false;
- }
- }
- else UNREACHABLE();
-
- return true;
- }
-
- bool Program::applyUniform1bv(GLint location, GLsizei count, const GLboolean *v)
- {
- int vector[MAX_UNIFORM_VECTORS][4];
-
- for(int i = 0; i < count; i++)
- {
- vector[i][0] = (v[0] == GL_FALSE ? 0x00000000 : 0xFFFFFFFF);
- vector[i][1] = 0;
- vector[i][2] = 0;
- vector[i][3] = 0;
-
- v += 1;
- }
-
- Uniform *targetUniform = uniforms[uniformIndex[location].index];
-
- if(targetUniform->psRegisterIndex != -1)
- {
- device->setPixelShaderConstantF(targetUniform->psRegisterIndex, (float*)vector, targetUniform->registerCount());
- }
-
- if(targetUniform->vsRegisterIndex != -1)
- {
- device->setVertexShaderConstantF(targetUniform->vsRegisterIndex, (float*)vector, targetUniform->registerCount());
- }
-
- return true;
- }
-
- bool Program::applyUniform2bv(GLint location, GLsizei count, const GLboolean *v)
- {
- int vector[MAX_UNIFORM_VECTORS][4];
-
- for(int i = 0; i < count; i++)
- {
- vector[i][0] = (v[0] == GL_FALSE ? 0x00000000 : 0xFFFFFFFF);
- vector[i][1] = (v[1] == GL_FALSE ? 0x00000000 : 0xFFFFFFFF);
- vector[i][2] = 0;
- vector[i][3] = 0;
-
- v += 2;
- }
-
- Uniform *targetUniform = uniforms[uniformIndex[location].index];
-
- if(targetUniform->psRegisterIndex != -1)
- {
- device->setPixelShaderConstantF(targetUniform->psRegisterIndex, (float*)vector, targetUniform->registerCount());
- }
-
- if(targetUniform->vsRegisterIndex != -1)
- {
- device->setVertexShaderConstantF(targetUniform->vsRegisterIndex, (float*)vector, targetUniform->registerCount());
- }
-
- return true;
- }
-
- bool Program::applyUniform3bv(GLint location, GLsizei count, const GLboolean *v)
- {
- int vector[MAX_UNIFORM_VECTORS][4];
-
- for(int i = 0; i < count; i++)
- {
- vector[i][0] = (v[0] == GL_FALSE ? 0x00000000 : 0xFFFFFFFF);
- vector[i][1] = (v[1] == GL_FALSE ? 0x00000000 : 0xFFFFFFFF);
- vector[i][2] = (v[2] == GL_FALSE ? 0x00000000 : 0xFFFFFFFF);
- vector[i][3] = 0;
-
- v += 3;
- }
-
- Uniform *targetUniform = uniforms[uniformIndex[location].index];
-
- if(targetUniform->psRegisterIndex != -1)
- {
- device->setPixelShaderConstantF(targetUniform->psRegisterIndex, (float*)vector, targetUniform->registerCount());
- }
-
- if(targetUniform->vsRegisterIndex != -1)
- {
- device->setVertexShaderConstantF(targetUniform->vsRegisterIndex, (float*)vector, targetUniform->registerCount());
- }
-
- return true;
- }
-
- bool Program::applyUniform4bv(GLint location, GLsizei count, const GLboolean *v)
- {
- int vector[MAX_UNIFORM_VECTORS][4];
-
- for(int i = 0; i < count; i++)
- {
- vector[i][0] = (v[0] == GL_FALSE ? 0x00000000 : 0xFFFFFFFF);
- vector[i][1] = (v[1] == GL_FALSE ? 0x00000000 : 0xFFFFFFFF);
- vector[i][2] = (v[2] == GL_FALSE ? 0x00000000 : 0xFFFFFFFF);
- vector[i][3] = (v[3] == GL_FALSE ? 0x00000000 : 0xFFFFFFFF);
-
- v += 4;
- }
-
- Uniform *targetUniform = uniforms[uniformIndex[location].index];
-
- if(targetUniform->psRegisterIndex != -1)
- {
- device->setPixelShaderConstantF(targetUniform->psRegisterIndex, (float*)vector, targetUniform->registerCount());
- }
-
- if(targetUniform->vsRegisterIndex != -1)
- {
- device->setVertexShaderConstantF(targetUniform->vsRegisterIndex, (float*)vector, targetUniform->registerCount());
- }
-
- return true;
- }
-
- bool Program::applyUniform1fv(GLint location, GLsizei count, const GLfloat *v)
- {
- float vector[MAX_UNIFORM_VECTORS][4];
-
- for(int i = 0; i < count; i++)
- {
- vector[i][0] = v[0];
- vector[i][1] = 0;
- vector[i][2] = 0;
- vector[i][3] = 0;
-
- v += 1;
- }
-
- Uniform *targetUniform = uniforms[uniformIndex[location].index];
-
- if(targetUniform->psRegisterIndex != -1)
- {
- device->setPixelShaderConstantF(targetUniform->psRegisterIndex, (float*)vector, targetUniform->registerCount());
- }
-
- if(targetUniform->vsRegisterIndex != -1)
- {
- device->setVertexShaderConstantF(targetUniform->vsRegisterIndex, (float*)vector, targetUniform->registerCount());
- }
-
- return true;
- }
-
- bool Program::applyUniform2fv(GLint location, GLsizei count, const GLfloat *v)
- {
- float vector[MAX_UNIFORM_VECTORS][4];
-
- for(int i = 0; i < count; i++)
- {
- vector[i][0] = v[0];
- vector[i][1] = v[1];
- vector[i][2] = 0;
- vector[i][3] = 0;
-
- v += 2;
- }
-
- Uniform *targetUniform = uniforms[uniformIndex[location].index];
-
- if(targetUniform->psRegisterIndex != -1)
- {
- device->setPixelShaderConstantF(targetUniform->psRegisterIndex, (float*)vector, targetUniform->registerCount());
- }
-
- if(targetUniform->vsRegisterIndex != -1)
- {
- device->setVertexShaderConstantF(targetUniform->vsRegisterIndex, (float*)vector, targetUniform->registerCount());
- }
-
- return true;
- }
-
- bool Program::applyUniform3fv(GLint location, GLsizei count, const GLfloat *v)
- {
- float vector[MAX_UNIFORM_VECTORS][4];
-
- for(int i = 0; i < count; i++)
- {
- vector[i][0] = v[0];
- vector[i][1] = v[1];
- vector[i][2] = v[2];
- vector[i][3] = 0;
-
- v += 3;
- }
-
- Uniform *targetUniform = uniforms[uniformIndex[location].index];
-
- if(targetUniform->psRegisterIndex != -1)
- {
- device->setPixelShaderConstantF(targetUniform->psRegisterIndex, (float*)vector, targetUniform->registerCount());
- }
-
- if(targetUniform->vsRegisterIndex != -1)
- {
- device->setVertexShaderConstantF(targetUniform->vsRegisterIndex, (float*)vector, targetUniform->registerCount());
- }
-
- return true;
- }
-
- bool Program::applyUniform4fv(GLint location, GLsizei count, const GLfloat *v)
- {
- Uniform *targetUniform = uniforms[uniformIndex[location].index];
-
- if(targetUniform->psRegisterIndex != -1)
- {
- device->setPixelShaderConstantF(targetUniform->psRegisterIndex, (float*)v, targetUniform->registerCount());
- }
-
- if(targetUniform->vsRegisterIndex != -1)
- {
- device->setVertexShaderConstantF(targetUniform->vsRegisterIndex, (float*)v, targetUniform->registerCount());
- }
-
- return true;
- }
-
- bool Program::applyUniformMatrix2fv(GLint location, GLsizei count, const GLfloat *value)
- {
- float matrix[(MAX_UNIFORM_VECTORS + 1) / 2][2][4];
-
- for(int i = 0; i < count; i++)
- {
- matrix[i][0][0] = value[0]; matrix[i][0][1] = value[1]; matrix[i][0][2] = 0; matrix[i][0][3] = 0;
- matrix[i][1][0] = value[2]; matrix[i][1][1] = value[3]; matrix[i][1][2] = 0; matrix[i][1][3] = 0;
-
- value += 4;
- }
-
- Uniform *targetUniform = uniforms[uniformIndex[location].index];
-
- if(targetUniform->psRegisterIndex != -1)
- {
- device->setPixelShaderConstantF(targetUniform->psRegisterIndex, (float*)matrix, targetUniform->registerCount());
- }
-
- if(targetUniform->vsRegisterIndex != -1)
- {
- device->setVertexShaderConstantF(targetUniform->vsRegisterIndex, (float*)matrix, targetUniform->registerCount());
- }
-
- return true;
- }
-
- bool Program::applyUniformMatrix3fv(GLint location, GLsizei count, const GLfloat *value)
- {
- float matrix[(MAX_UNIFORM_VECTORS + 2) / 3][3][4];
-
- for(int i = 0; i < count; i++)
- {
- matrix[i][0][0] = value[0]; matrix[i][0][1] = value[1]; matrix[i][0][2] = value[2]; matrix[i][0][3] = 0;
- matrix[i][1][0] = value[3]; matrix[i][1][1] = value[4]; matrix[i][1][2] = value[5]; matrix[i][1][3] = 0;
- matrix[i][2][0] = value[6]; matrix[i][2][1] = value[7]; matrix[i][2][2] = value[8]; matrix[i][2][3] = 0;
-
- value += 9;
- }
-
- Uniform *targetUniform = uniforms[uniformIndex[location].index];
-
- if(targetUniform->psRegisterIndex != -1)
- {
- device->setPixelShaderConstantF(targetUniform->psRegisterIndex, (float*)matrix, targetUniform->registerCount());
- }
-
- if(targetUniform->vsRegisterIndex != -1)
- {
- device->setVertexShaderConstantF(targetUniform->vsRegisterIndex, (float*)matrix, targetUniform->registerCount());
- }
-
- return true;
- }
-
- bool Program::applyUniformMatrix4fv(GLint location, GLsizei count, const GLfloat *value)
- {
- Uniform *targetUniform = uniforms[uniformIndex[location].index];
-
- if(targetUniform->psRegisterIndex != -1)
- {
- device->setPixelShaderConstantF(targetUniform->psRegisterIndex, (float*)value, targetUniform->registerCount());
- }
-
- if(targetUniform->vsRegisterIndex != -1)
- {
- device->setVertexShaderConstantF(targetUniform->vsRegisterIndex, (float*)value, targetUniform->registerCount());
- }
-
- return true;
- }
-
- bool Program::applyUniform1iv(GLint location, GLsizei count, const GLint *v)
- {
- float vector[MAX_UNIFORM_VECTORS][4];
-
- for(int i = 0; i < count; i++)
- {
- vector[i][0] = (float)v[i];
- vector[i][1] = 0;
- vector[i][2] = 0;
- vector[i][3] = 0;
- }
-
- Uniform *targetUniform = uniforms[uniformIndex[location].index];
-
- if(targetUniform->psRegisterIndex != -1)
- {
- if(targetUniform->type == GL_SAMPLER_2D ||
- targetUniform->type == GL_SAMPLER_CUBE ||
- targetUniform->type == GL_SAMPLER_EXTERNAL_OES)
- {
- for(int i = 0; i < count; i++)
- {
- unsigned int samplerIndex = targetUniform->psRegisterIndex + i;
-
- if(samplerIndex < MAX_TEXTURE_IMAGE_UNITS)
- {
- ASSERT(samplersPS[samplerIndex].active);
- samplersPS[samplerIndex].logicalTextureUnit = v[i];
- }
- }
- }
- else
- {
- device->setPixelShaderConstantF(targetUniform->psRegisterIndex, (float*)vector, targetUniform->registerCount());
- }
- }
-
- if(targetUniform->vsRegisterIndex != -1)
- {
- if(targetUniform->type == GL_SAMPLER_2D ||
- targetUniform->type == GL_SAMPLER_CUBE ||
- targetUniform->type == GL_SAMPLER_EXTERNAL_OES)
- {
- for(int i = 0; i < count; i++)
- {
- unsigned int samplerIndex = targetUniform->vsRegisterIndex + i;
-
- if(samplerIndex < MAX_VERTEX_TEXTURE_IMAGE_UNITS)
- {
- ASSERT(samplersVS[samplerIndex].active);
- samplersVS[samplerIndex].logicalTextureUnit = v[i];
- }
- }
- }
- else
- {
- device->setVertexShaderConstantF(targetUniform->vsRegisterIndex, (float*)vector, targetUniform->registerCount());
- }
- }
-
- return true;
- }
-
- bool Program::applyUniform2iv(GLint location, GLsizei count, const GLint *v)
- {
- float vector[MAX_UNIFORM_VECTORS][4];
-
- for(int i = 0; i < count; i++)
- {
- vector[i][0] = (float)v[0];
- vector[i][1] = (float)v[1];
- vector[i][2] = 0;
- vector[i][3] = 0;
-
- v += 2;
- }
-
- Uniform *targetUniform = uniforms[uniformIndex[location].index];
-
- if(targetUniform->psRegisterIndex != -1)
- {
- device->setPixelShaderConstantF(targetUniform->psRegisterIndex, (float*)vector, targetUniform->registerCount());
- }
-
- if(targetUniform->vsRegisterIndex != -1)
- {
- device->setVertexShaderConstantF(targetUniform->vsRegisterIndex, (float*)vector, targetUniform->registerCount());
- }
-
- return true;
- }
-
- bool Program::applyUniform3iv(GLint location, GLsizei count, const GLint *v)
- {
- float vector[MAX_UNIFORM_VECTORS][4];
-
- for(int i = 0; i < count; i++)
- {
- vector[i][0] = (float)v[0];
- vector[i][1] = (float)v[1];
- vector[i][2] = (float)v[2];
- vector[i][3] = 0;
-
- v += 3;
- }
-
- Uniform *targetUniform = uniforms[uniformIndex[location].index];
-
- if(targetUniform->psRegisterIndex != -1)
- {
- device->setPixelShaderConstantF(targetUniform->psRegisterIndex, (float*)vector, targetUniform->registerCount());
- }
-
- if(targetUniform->vsRegisterIndex != -1)
- {
- device->setVertexShaderConstantF(targetUniform->vsRegisterIndex, (float*)vector, targetUniform->registerCount());
- }
-
- return true;
- }
-
- bool Program::applyUniform4iv(GLint location, GLsizei count, const GLint *v)
- {
- float vector[MAX_UNIFORM_VECTORS][4];
-
- for(int i = 0; i < count; i++)
- {
- vector[i][0] = (float)v[0];
- vector[i][1] = (float)v[1];
- vector[i][2] = (float)v[2];
- vector[i][3] = (float)v[3];
-
- v += 4;
- }
-
- Uniform *targetUniform = uniforms[uniformIndex[location].index];
-
- if(targetUniform->psRegisterIndex != -1)
- {
- device->setPixelShaderConstantF(targetUniform->psRegisterIndex, (float*)vector, targetUniform->registerCount());
- }
-
- if(targetUniform->vsRegisterIndex != -1)
- {
- device->setVertexShaderConstantF(targetUniform->vsRegisterIndex, (float*)vector, targetUniform->registerCount());
- }
-
- return true;
- }
-
- void Program::appendToInfoLog(const char *format, ...)
- {
- if(!format)
- {
- return;
- }
-
- char info[1024];
-
- va_list vararg;
- va_start(vararg, format);
- vsnprintf(info, sizeof(info), format, vararg);
- va_end(vararg);
-
- size_t infoLength = strlen(info);
-
- if(!infoLog)
- {
- infoLog = new char[infoLength + 2];
- strcpy(infoLog, info);
- strcpy(infoLog + infoLength, "\n");
- }
- else
- {
- size_t logLength = strlen(infoLog);
- char *newLog = new char[logLength + infoLength + 2];
- strcpy(newLog, infoLog);
- strcpy(newLog + logLength, info);
- strcpy(newLog + logLength + infoLength, "\n");
-
- delete[] infoLog;
- infoLog = newLog;
- }
- }
-
- void Program::resetInfoLog()
- {
- if(infoLog)
- {
- delete[] infoLog;
- infoLog = 0;
- }
- }
-
- // Returns the program object to an unlinked state, before re-linking, or at destruction
- void Program::unlink()
- {
- delete vertexBinary;
- vertexBinary = 0;
- delete pixelBinary;
- pixelBinary = 0;
-
- for(int index = 0; index < MAX_VERTEX_ATTRIBS; index++)
- {
- linkedAttribute[index].name.clear();
- attributeStream[index] = -1;
- }
-
- for(int index = 0; index < MAX_TEXTURE_IMAGE_UNITS; index++)
- {
- samplersPS[index].active = false;
- }
-
- for(int index = 0; index < MAX_VERTEX_TEXTURE_IMAGE_UNITS; index++)
- {
- samplersVS[index].active = false;
- }
-
- while(!uniforms.empty())
- {
- delete uniforms.back();
- uniforms.pop_back();
- }
-
- uniformIndex.clear();
-
- delete[] infoLog;
- infoLog = 0;
-
- linked = false;
- }
-
- bool Program::isLinked()
- {
- return linked;
- }
-
- bool Program::isValidated() const
- {
- return validated;
- }
-
- void Program::release()
- {
- referenceCount--;
-
- if(referenceCount == 0 && orphaned)
- {
- resourceManager->deleteProgram(handle);
- }
- }
-
- void Program::addRef()
- {
- referenceCount++;
- }
-
- unsigned int Program::getRefCount() const
- {
- return referenceCount;
- }
-
- unsigned int Program::getSerial() const
- {
- return serial;
- }
-
- unsigned int Program::issueSerial()
- {
- return currentSerial++;
- }
-
- int Program::getInfoLogLength() const
- {
- if(!infoLog)
- {
- return 0;
- }
- else
- {
- return strlen(infoLog) + 1;
- }
- }
-
- void Program::getInfoLog(GLsizei bufSize, GLsizei *length, char *buffer)
- {
- int index = 0;
-
- if(bufSize > 0)
- {
- if(infoLog)
- {
- index = std::min(bufSize - 1, (int)strlen(infoLog));
- memcpy(buffer, infoLog, index);
- }
-
- buffer[index] = '\0';
- }
-
- if(length)
- {
- *length = index;
- }
- }
-
- void Program::getAttachedShaders(GLsizei maxCount, GLsizei *count, GLuint *shaders)
- {
- int total = 0;
-
- if(vertexShader)
- {
- if(total < maxCount)
- {
- shaders[total] = vertexShader->getHandle();
- }
-
- total++;
- }
-
- if(fragmentShader)
- {
- if(total < maxCount)
- {
- shaders[total] = fragmentShader->getHandle();
- }
-
- total++;
- }
-
- if(count)
- {
- *count = total;
- }
- }
-
- void Program::getActiveAttribute(GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, GLchar *name) const
- {
- // Skip over inactive attributes
- unsigned int activeAttribute = 0;
- unsigned int attribute;
- for(attribute = 0; attribute < MAX_VERTEX_ATTRIBS; attribute++)
- {
- if(linkedAttribute[attribute].name.empty())
- {
- continue;
- }
-
- if(activeAttribute == index)
- {
- break;
- }
-
- activeAttribute++;
- }
-
- if(bufsize > 0)
- {
- const char *string = linkedAttribute[attribute].name.c_str();
-
- strncpy(name, string, bufsize);
- name[bufsize - 1] = '\0';
-
- if(length)
- {
- *length = strlen(name);
- }
- }
-
- *size = 1; // Always a single 'type' instance
-
- *type = linkedAttribute[attribute].type;
- }
-
- GLint Program::getActiveAttributeCount() const
- {
- int count = 0;
-
- for(int attributeIndex = 0; attributeIndex < MAX_VERTEX_ATTRIBS; attributeIndex++)
- {
- if(!linkedAttribute[attributeIndex].name.empty())
- {
- count++;
- }
- }
-
- return count;
- }
-
- GLint Program::getActiveAttributeMaxLength() const
- {
- int maxLength = 0;
-
- for(int attributeIndex = 0; attributeIndex < MAX_VERTEX_ATTRIBS; attributeIndex++)
- {
- if(!linkedAttribute[attributeIndex].name.empty())
- {
- maxLength = std::max((int)(linkedAttribute[attributeIndex].name.length() + 1), maxLength);
- }
- }
-
- return maxLength;
- }
-
- void Program::getActiveUniform(GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, GLchar *name) const
- {
- if(bufsize > 0)
- {
- std::string string = uniforms[index]->name;
-
- if(uniforms[index]->isArray())
- {
- string += "[0]";
- }
-
- strncpy(name, string.c_str(), bufsize);
- name[bufsize - 1] = '\0';
-
- if(length)
- {
- *length = strlen(name);
- }
- }
-
- *size = uniforms[index]->size();
-
- *type = uniforms[index]->type;
- }
-
- GLint Program::getActiveUniformCount() const
- {
- return uniforms.size();
- }
-
- GLint Program::getActiveUniformMaxLength() const
- {
- int maxLength = 0;
-
- unsigned int numUniforms = uniforms.size();
- for(unsigned int uniformIndex = 0; uniformIndex < numUniforms; uniformIndex++)
- {
- if(!uniforms[uniformIndex]->name.empty())
- {
- int length = (int)(uniforms[uniformIndex]->name.length() + 1);
- if(uniforms[uniformIndex]->isArray())
- {
- length += 3; // Counting in "[0]".
- }
- maxLength = std::max(length, maxLength);
- }
- }
-
- return maxLength;
- }
-
- void Program::flagForDeletion()
- {
- orphaned = true;
- }
-
- bool Program::isFlaggedForDeletion() const
- {
- return orphaned;
- }
-
- void Program::validate()
- {
- resetInfoLog();
-
- if(!isLinked())
- {
- appendToInfoLog("Program has not been successfully linked.");
- validated = false;
- }
- else
- {
- applyUniforms();
- if(!validateSamplers(true))
- {
- validated = false;
- }
- else
- {
- validated = true;
- }
- }
- }
-
- bool Program::validateSamplers(bool logErrors)
- {
- // if any two active samplers in a program are of different types, but refer to the same
- // texture image unit, and this is the current program, then ValidateProgram will fail, and
- // DrawArrays and DrawElements will issue the INVALID_OPERATION error.
-
- TextureType textureUnitType[MAX_COMBINED_TEXTURE_IMAGE_UNITS];
-
- for(unsigned int i = 0; i < MAX_COMBINED_TEXTURE_IMAGE_UNITS; i++)
- {
- textureUnitType[i] = TEXTURE_UNKNOWN;
- }
-
- for(unsigned int i = 0; i < MAX_TEXTURE_IMAGE_UNITS; i++)
- {
- if(samplersPS[i].active)
- {
- unsigned int unit = samplersPS[i].logicalTextureUnit;
-
- if(unit >= MAX_COMBINED_TEXTURE_IMAGE_UNITS)
- {
- if(logErrors)
- {
- appendToInfoLog("Sampler uniform (%d) exceeds MAX_COMBINED_TEXTURE_IMAGE_UNITS (%d)", unit, MAX_COMBINED_TEXTURE_IMAGE_UNITS);
- }
-
- return false;
- }
-
- if(textureUnitType[unit] != TEXTURE_UNKNOWN)
- {
- if(samplersPS[i].textureType != textureUnitType[unit])
- {
- if(logErrors)
- {
- appendToInfoLog("Samplers of conflicting types refer to the same texture image unit (%d).", unit);
- }
-
- return false;
- }
- }
- else
- {
- textureUnitType[unit] = samplersPS[i].textureType;
- }
- }
- }
-
- for(unsigned int i = 0; i < MAX_VERTEX_TEXTURE_IMAGE_UNITS; i++)
- {
- if(samplersVS[i].active)
- {
- unsigned int unit = samplersVS[i].logicalTextureUnit;
-
- if(unit >= MAX_COMBINED_TEXTURE_IMAGE_UNITS)
- {
- if(logErrors)
- {
- appendToInfoLog("Sampler uniform (%d) exceeds MAX_COMBINED_TEXTURE_IMAGE_UNITS (%d)", unit, MAX_COMBINED_TEXTURE_IMAGE_UNITS);
- }
-
- return false;
- }
-
- if(textureUnitType[unit] != TEXTURE_UNKNOWN)
- {
- if(samplersVS[i].textureType != textureUnitType[unit])
- {
- if(logErrors)
- {
- appendToInfoLog("Samplers of conflicting types refer to the same texture image unit (%d).", unit);
- }
-
- return false;
- }
- }
- else
- {
- textureUnitType[unit] = samplersVS[i].textureType;
- }
- }
- }
-
- return true;
- }
-}
diff --git a/src/GLES2/libGLES_CM/Program.h b/src/GLES2/libGLES_CM/Program.h
deleted file mode 100644
index 33e358c..0000000
--- a/src/GLES2/libGLES_CM/Program.h
+++ /dev/null
@@ -1,207 +0,0 @@
-// SwiftShader Software Renderer
-//
-// Copyright(c) 2005-2013 TransGaming Inc.
-//
-// All rights reserved. No part of this software may be copied, distributed, transmitted,
-// transcribed, stored in a retrieval system, translated into any human or computer
-// language by any means, or disclosed to third parties without the explicit written
-// agreement of TransGaming Inc. Without such an agreement, no rights or licenses, express
-// or implied, including but not limited to any patent rights, are granted to you.
-//
-
-// Program.h: Defines the Program class. Implements GL program objects
-// and related functionality. [OpenGL ES 2.0.24] section 2.10.3 page 28.
-
-#ifndef LIBGLESV2_PROGRAM_H_
-#define LIBGLESV2_PROGRAM_H_
-
-#include "Shader.h"
-#include "Context.h"
-#include "Shader/PixelShader.hpp"
-#include "Shader/VertexShader.hpp"
-
-#include <string>
-#include <vector>
-#include <set>
-
-namespace gl
-{
- class Device;
- class ResourceManager;
- class FragmentShader;
- class VertexShader;
-
- // Helper struct representing a single shader uniform
- struct Uniform
- {
- Uniform(GLenum type, GLenum precision, const std::string &name, unsigned int arraySize);
-
- ~Uniform();
-
- bool isArray() const;
- int size() const;
- int registerCount() const;
-
- const GLenum type;
- const GLenum precision;
- const std::string name;
- const unsigned int arraySize;
-
- unsigned char *data;
- bool dirty;
-
- short psRegisterIndex;
- short vsRegisterIndex;
- };
-
- // Struct used for correlating uniforms/elements of uniform arrays to handles
- struct UniformLocation
- {
- UniformLocation(const std::string &name, unsigned int element, unsigned int index);
-
- std::string name;
- unsigned int element;
- unsigned int index;
- };
-
- class Program
- {
- public:
- Program(ResourceManager *manager, GLuint handle);
-
- ~Program();
-
- bool attachShader(Shader *shader);
- bool detachShader(Shader *shader);
- int getAttachedShadersCount() const;
-
- sw::PixelShader *getPixelShader();
- sw::VertexShader *getVertexShader();
-
- void bindAttributeLocation(GLuint index, const char *name);
- GLuint getAttributeLocation(const char *name);
- int getAttributeStream(int attributeIndex);
-
- GLint getSamplerMapping(sw::SamplerType type, unsigned int samplerIndex);
- TextureType getSamplerTextureType(sw::SamplerType type, unsigned int samplerIndex);
-
- GLint getUniformLocation(std::string name);
- bool setUniform1fv(GLint location, GLsizei count, const GLfloat *v);
- bool setUniform2fv(GLint location, GLsizei count, const GLfloat *v);
- bool setUniform3fv(GLint location, GLsizei count, const GLfloat *v);
- bool setUniform4fv(GLint location, GLsizei count, const GLfloat *v);
- bool setUniformMatrix2fv(GLint location, GLsizei count, const GLfloat *value);
- bool setUniformMatrix3fv(GLint location, GLsizei count, const GLfloat *value);
- bool setUniformMatrix4fv(GLint location, GLsizei count, const GLfloat *value);
- bool setUniform1iv(GLint location, GLsizei count, const GLint *v);
- bool setUniform2iv(GLint location, GLsizei count, const GLint *v);
- bool setUniform3iv(GLint location, GLsizei count, const GLint *v);
- bool setUniform4iv(GLint location, GLsizei count, const GLint *v);
-
- bool getUniformfv(GLint location, GLsizei *bufSize, GLfloat *params);
- bool getUniformiv(GLint location, GLsizei *bufSize, GLint *params);
-
- void dirtyAllUniforms();
- void applyUniforms();
-
- void link();
- bool isLinked();
- int getInfoLogLength() const;
- void getInfoLog(GLsizei bufSize, GLsizei *length, char *infoLog);
- void getAttachedShaders(GLsizei maxCount, GLsizei *count, GLuint *shaders);
-
- void getActiveAttribute(GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, GLchar *name) const;
- GLint getActiveAttributeCount() const;
- GLint getActiveAttributeMaxLength() const;
-
- void getActiveUniform(GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, GLchar *name) const;
- GLint getActiveUniformCount() const;
- GLint getActiveUniformMaxLength() const;
-
- void addRef();
- void release();
- unsigned int getRefCount() const;
- void flagForDeletion();
- bool isFlaggedForDeletion() const;
-
- void validate();
- bool validateSamplers(bool logErrors);
- bool isValidated() const;
-
- unsigned int getSerial() const;
-
- private:
- void unlink();
-
- int packVaryings(const Varying *packing[][4]);
- bool linkVaryings();
-
- bool linkAttributes();
- int getAttributeBinding(const std::string &name);
-
- bool linkUniforms(Shader *shader);
- bool defineUniform(GLenum shader, GLenum type, GLenum precision, const std::string &_name, unsigned int arraySize, int registerIndex);
- bool applyUniform1bv(GLint location, GLsizei count, const GLboolean *v);
- bool applyUniform2bv(GLint location, GLsizei count, const GLboolean *v);
- bool applyUniform3bv(GLint location, GLsizei count, const GLboolean *v);
- bool applyUniform4bv(GLint location, GLsizei count, const GLboolean *v);
- bool applyUniform1fv(GLint location, GLsizei count, const GLfloat *v);
- bool applyUniform2fv(GLint location, GLsizei count, const GLfloat *v);
- bool applyUniform3fv(GLint location, GLsizei count, const GLfloat *v);
- bool applyUniform4fv(GLint location, GLsizei count, const GLfloat *v);
- bool applyUniformMatrix2fv(GLint location, GLsizei count, const GLfloat *value);
- bool applyUniformMatrix3fv(GLint location, GLsizei count, const GLfloat *value);
- bool applyUniformMatrix4fv(GLint location, GLsizei count, const GLfloat *value);
- bool applyUniform1iv(GLint location, GLsizei count, const GLint *v);
- bool applyUniform2iv(GLint location, GLsizei count, const GLint *v);
- bool applyUniform3iv(GLint location, GLsizei count, const GLint *v);
- bool applyUniform4iv(GLint location, GLsizei count, const GLint *v);
-
- void appendToInfoLog(const char *info, ...);
- void resetInfoLog();
-
- static unsigned int issueSerial();
-
- private:
- gl::Device *device;
- FragmentShader *fragmentShader;
- VertexShader *vertexShader;
-
- sw::PixelShader *pixelBinary;
- sw::VertexShader *vertexBinary;
-
- std::set<std::string> attributeBinding[MAX_VERTEX_ATTRIBS];
- sh::Attribute linkedAttribute[MAX_VERTEX_ATTRIBS];
- int attributeStream[MAX_VERTEX_ATTRIBS];
-
- struct Sampler
- {
- bool active;
- GLint logicalTextureUnit;
- TextureType textureType;
- };
-
- Sampler samplersPS[MAX_TEXTURE_IMAGE_UNITS];
- Sampler samplersVS[MAX_VERTEX_TEXTURE_IMAGE_UNITS];
-
- typedef std::vector<Uniform*> UniformArray;
- UniformArray uniforms;
- typedef std::vector<UniformLocation> UniformIndex;
- UniformIndex uniformIndex;
-
- bool linked;
- bool orphaned; // Flag to indicate that the program can be deleted when no longer in use
- char *infoLog;
- bool validated;
-
- unsigned int referenceCount;
- const unsigned int serial;
-
- static unsigned int currentSerial;
-
- ResourceManager *resourceManager;
- const GLuint handle;
- };
-}
-
-#endif // LIBGLESV2_PROGRAM_H_
diff --git a/src/GLES2/libGLES_CM/Query.cpp b/src/GLES2/libGLES_CM/Query.cpp
deleted file mode 100644
index 8e69d70..0000000
--- a/src/GLES2/libGLES_CM/Query.cpp
+++ /dev/null
@@ -1,127 +0,0 @@
-// SwiftShader Software Renderer
-//
-// Copyright(c) 2005-2012 TransGaming Inc.
-//
-// All rights reserved. No part of this software may be copied, distributed, transmitted,
-// transcribed, stored in a retrieval system, translated into any human or computer
-// language by any means, or disclosed to third parties without the explicit written
-// agreement of TransGaming Inc. Without such an agreement, no rights or licenses, express
-// or implied, including but not limited to any patent rights, are granted to you.
-//
-
-// Query.cpp: Implements the gl::Query class
-
-#include "Query.h"
-
-#include "main.h"
-#include "Common/Thread.hpp"
-
-namespace gl
-{
-
-Query::Query(GLuint id, GLenum type) : RefCountObject(id)
-{
- mQuery = NULL;
- mStatus = GL_FALSE;
- mResult = GL_FALSE;
- mType = type;
-}
-
-Query::~Query()
-{
- if(mQuery != NULL)
- {
- delete mQuery;
- }
-}
-
-void Query::begin()
-{
- if(mQuery == NULL)
- {
- mQuery = new sw::Query();
-
- if(!mQuery)
- {
- return error(GL_OUT_OF_MEMORY);
- }
- }
-
- Device *device = getDevice();
-
- mQuery->begin();
- device->addQuery(mQuery);
- device->setOcclusionEnabled(true);
-}
-
-void Query::end()
-{
- if(mQuery == NULL)
- {
- return error(GL_INVALID_OPERATION);
- }
-
- Device *device = getDevice();
-
- mQuery->end();
- device->removeQuery(mQuery);
- device->setOcclusionEnabled(false);
-
- mStatus = GL_FALSE;
- mResult = GL_FALSE;
-}
-
-GLuint Query::getResult()
-{
- if(mQuery != NULL)
- {
- while(!testQuery())
- {
- sw::Thread::yield();
- }
- }
-
- return (GLuint)mResult;
-}
-
-GLboolean Query::isResultAvailable()
-{
- if(mQuery != NULL)
- {
- testQuery();
- }
-
- return mStatus;
-}
-
-GLenum Query::getType() const
-{
- return mType;
-}
-
-GLboolean Query::testQuery()
-{
- if(mQuery != NULL && mStatus != GL_TRUE)
- {
- if(!mQuery->building && mQuery->reference == 0)
- {
- unsigned int numPixels = mQuery->data;
- mStatus = GL_TRUE;
-
- switch(mType)
- {
- case GL_ANY_SAMPLES_PASSED_EXT:
- case GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT:
- mResult = (numPixels > 0) ? GL_TRUE : GL_FALSE;
- break;
- default:
- ASSERT(false);
- }
- }
-
- return mStatus;
- }
-
- return GL_TRUE; // Prevent blocking when query is null
-}
-}
diff --git a/src/GLES2/libGLES_CM/Query.h b/src/GLES2/libGLES_CM/Query.h
deleted file mode 100644
index a80456e..0000000
--- a/src/GLES2/libGLES_CM/Query.h
+++ /dev/null
@@ -1,50 +0,0 @@
-// SwiftShader Software Renderer
-//
-// Copyright(c) 2005-2012 TransGaming Inc.
-//
-// All rights reserved. No part of this software may be copied, distributed, transmitted,
-// transcribed, stored in a retrieval system, translated into any human or computer
-// language by any means, or disclosed to third parties without the explicit written
-// agreement of TransGaming Inc. Without such an agreement, no rights or licenses, express
-// or implied, including but not limited to any patent rights, are granted to you.
-//
-
-// Query.h: Defines the gl::Query class
-
-#ifndef LIBGLESV2_QUERY_H_
-#define LIBGLESV2_QUERY_H_
-
-#include "RefCountObject.h"
-#include "Renderer/Renderer.hpp"
-
-#define GL_APICALL
-#include <GLES2/gl2.h>
-
-namespace gl
-{
-
-class Query : public RefCountObject
-{
- public:
- Query(GLuint id, GLenum type);
- virtual ~Query();
-
- void begin();
- void end();
- GLuint getResult();
- GLboolean isResultAvailable();
-
- GLenum getType() const;
-
- private:
- GLboolean testQuery();
-
- sw::Query* mQuery;
- GLenum mType;
- GLboolean mStatus;
- GLint mResult;
-};
-
-}
-
-#endif // LIBGLESV2_QUERY_H_
diff --git a/src/GLES2/libGLES_CM/RefCountObject.h b/src/GLES2/libGLES_CM/RefCountObject.h
index a9a11e0..add878e 100644
--- a/src/GLES2/libGLES_CM/RefCountObject.h
+++ b/src/GLES2/libGLES_CM/RefCountObject.h
@@ -14,13 +14,13 @@
// that need to be reference counted for correct cross-context deletion.
// (Concretely, textures, buffers and renderbuffers.)
-#ifndef LIBGLESV2_REFCOUNTOBJECT_H_
-#define LIBGLESV2_REFCOUNTOBJECT_H_
+#ifndef LIBGLES_CM_REFCOUNTOBJECT_H_
+#define LIBGLES_CM_REFCOUNTOBJECT_H_
#include "common/debug.h"
-#define GL_APICALL
-#include <GLES2/gl2.h>
+#define GL_APIL
+#include <GLES/gl.h>
#include <cstddef>
@@ -72,4 +72,4 @@
}
-#endif // LIBGLESV2_REFCOUNTOBJECT_H_
+#endif // LIBGLES_CM_REFCOUNTOBJECT_H_
diff --git a/src/GLES2/libGLES_CM/Renderbuffer.cpp b/src/GLES2/libGLES_CM/Renderbuffer.cpp
index 6ca0c15..5e1ea63 100644
--- a/src/GLES2/libGLES_CM/Renderbuffer.cpp
+++ b/src/GLES2/libGLES_CM/Renderbuffer.cpp
@@ -134,74 +134,6 @@
return 0;
}
-///// RenderbufferTextureCubeMap Implementation ////////
-
-RenderbufferTextureCubeMap::RenderbufferTextureCubeMap(TextureCubeMap *texture, GLenum target) : mTarget(target)
-{
- mTextureCubeMap.set(texture);
-}
-
-RenderbufferTextureCubeMap::~RenderbufferTextureCubeMap()
-{
- mTextureCubeMap.set(NULL);
-}
-
-// Textures need to maintain their own reference count for references via
-// Renderbuffers acting as proxies. Here, we notify the texture of a reference.
-void RenderbufferTextureCubeMap::addProxyRef(const Renderbuffer *proxy)
-{
- mTextureCubeMap->addProxyRef(proxy);
-}
-
-void RenderbufferTextureCubeMap::releaseProxy(const Renderbuffer *proxy)
-{
- mTextureCubeMap->releaseProxy(proxy);
-}
-
-// Increments refcount on image.
-// caller must release() the returned image
-Image *RenderbufferTextureCubeMap::getRenderTarget()
-{
- return mTextureCubeMap->getRenderTarget(mTarget, 0);
-}
-
-// Increments refcount on image.
-// caller must release() the returned image
-Image *RenderbufferTextureCubeMap::createSharedImage()
-{
- return mTextureCubeMap->createSharedImage(mTarget, 0);
-}
-
-bool RenderbufferTextureCubeMap::isShared() const
-{
- return mTextureCubeMap->isShared(mTarget, 0);
-}
-
-GLsizei RenderbufferTextureCubeMap::getWidth() const
-{
- return mTextureCubeMap->getWidth(mTarget, 0);
-}
-
-GLsizei RenderbufferTextureCubeMap::getHeight() const
-{
- return mTextureCubeMap->getHeight(mTarget, 0);
-}
-
-GLenum RenderbufferTextureCubeMap::getFormat() const
-{
- return mTextureCubeMap->getFormat(mTarget, 0);
-}
-
-sw::Format RenderbufferTextureCubeMap::getInternalFormat() const
-{
- return mTextureCubeMap->getInternalFormat(mTarget, 0);
-}
-
-GLsizei RenderbufferTextureCubeMap::getSamples() const
-{
- return 0;
-}
-
////// Renderbuffer Implementation //////
Renderbuffer::Renderbuffer(GLuint id, RenderbufferInterface *instance) : RefCountObject(id)
@@ -317,7 +249,7 @@
{
mWidth = 0;
mHeight = 0;
- format = GL_RGBA4;
+ format = GL_RGBA4_OES;
internalFormat = sw::FORMAT_A8R8G8B8;
mSamples = 0;
}
@@ -510,9 +442,9 @@
{
if(depthStencil)
{
- format = GL_DEPTH_COMPONENT16; // If the renderbuffer parameters are queried, the calling function
- // will expect one of the valid renderbuffer formats for use in
- // glRenderbufferStorage
+ format = GL_DEPTH_COMPONENT16_OES; // If the renderbuffer parameters are queried, the calling function
+ // will expect one of the valid renderbuffer formats for use in
+ // glRenderbufferStorage
}
}
@@ -520,9 +452,9 @@
{
if(mDepthStencil)
{
- format = GL_DEPTH_COMPONENT16; // If the renderbuffer parameters are queried, the calling function
- // will expect one of the valid renderbuffer formats for use in
- // glRenderbufferStorage
+ format = GL_DEPTH_COMPONENT16_OES; // If the renderbuffer parameters are queried, the calling function
+ // will expect one of the valid renderbuffer formats for use in
+ // glRenderbufferStorage
}
}
@@ -534,9 +466,9 @@
{
if(depthStencil)
{
- format = GL_STENCIL_INDEX8; // If the renderbuffer parameters are queried, the calling function
- // will expect one of the valid renderbuffer formats for use in
- // glRenderbufferStorage
+ format = GL_STENCIL_INDEX8_OES; // If the renderbuffer parameters are queried, the calling function
+ // will expect one of the valid renderbuffer formats for use in
+ // glRenderbufferStorage
}
}
@@ -544,9 +476,9 @@
{
if(mDepthStencil)
{
- format = GL_STENCIL_INDEX8; // If the renderbuffer parameters are queried, the calling function
- // will expect one of the valid renderbuffer formats for use in
- // glRenderbufferStorage
+ format = GL_STENCIL_INDEX8_OES; // If the renderbuffer parameters are queried, the calling function
+ // will expect one of the valid renderbuffer formats for use in
+ // glRenderbufferStorage
}
}
diff --git a/src/GLES2/libGLES_CM/Renderbuffer.h b/src/GLES2/libGLES_CM/Renderbuffer.h
index 2e8a49e..fd785d6 100644
--- a/src/GLES2/libGLES_CM/Renderbuffer.h
+++ b/src/GLES2/libGLES_CM/Renderbuffer.h
@@ -14,19 +14,18 @@
// DepthStencilbuffer, Depthbuffer and Stencilbuffer. Implements GL renderbuffer
// objects and related functionality. [OpenGL ES 2.0.24] section 4.4.3 page 108.
-#ifndef LIBGLESV2_RENDERBUFFER_H_
-#define LIBGLESV2_RENDERBUFFER_H_
+#ifndef LIBGLES_CM_RENDERBUFFER_H_
+#define LIBGLES_CM_RENDERBUFFER_H_
#include "RefCountObject.h"
#include "Image.hpp"
-#define GL_APICALL
-#include <GLES2/gl2.h>
+#define GL_API
+#include <GLES/gl.h>
namespace gl
{
class Texture2D;
-class TextureCubeMap;
class Renderbuffer;
class Colorbuffer;
class DepthStencilbuffer;
@@ -83,31 +82,6 @@
BindingPointer<Texture2D> mTexture2D;
};
-class RenderbufferTextureCubeMap : public RenderbufferInterface
-{
-public:
- RenderbufferTextureCubeMap(TextureCubeMap *texture, GLenum target);
-
- virtual ~RenderbufferTextureCubeMap();
-
- virtual void addProxyRef(const Renderbuffer *proxy);
- virtual void releaseProxy(const Renderbuffer *proxy);
-
- virtual Image *getRenderTarget();
- virtual Image *createSharedImage();
- virtual bool isShared() const;
-
- virtual GLsizei getWidth() const;
- virtual GLsizei getHeight() const;
- virtual GLenum getFormat() const;
- virtual sw::Format getInternalFormat() const;
- virtual GLsizei getSamples() const;
-
-private:
- BindingPointer<TextureCubeMap> mTextureCubeMap;
- GLenum mTarget;
-};
-
// A class derived from RenderbufferStorage is created whenever glRenderbufferStorage
// is called. The specific concrete type depends on whether the internal format is
// colour depth, stencil or packed depth/stencil.
@@ -226,4 +200,4 @@
};
}
-#endif // LIBGLESV2_RENDERBUFFER_H_
+#endif // LIBGLES_CM_RENDERBUFFER_H_
diff --git a/src/GLES2/libGLES_CM/ResourceManager.cpp b/src/GLES2/libGLES_CM/ResourceManager.cpp
index 8bddcc8..a25e085 100644
--- a/src/GLES2/libGLES_CM/ResourceManager.cpp
+++ b/src/GLES2/libGLES_CM/ResourceManager.cpp
@@ -15,9 +15,7 @@
#include "ResourceManager.h"
#include "Buffer.h"
-#include "Program.h"
#include "Renderbuffer.h"
-#include "Shader.h"
#include "Texture.h"
namespace gl
@@ -34,16 +32,6 @@
deleteBuffer(mBufferMap.begin()->first);
}
- while(!mProgramMap.empty())
- {
- deleteProgram(mProgramMap.begin()->first);
- }
-
- while(!mShaderMap.empty())
- {
- deleteShader(mShaderMap.begin()->first);
- }
-
while(!mRenderbufferMap.empty())
{
deleteRenderbuffer(mRenderbufferMap.begin()->first);
@@ -78,34 +66,6 @@
return handle;
}
-// Returns an unused shader/program name
-GLuint ResourceManager::createShader(GLenum type)
-{
- GLuint handle = mProgramShaderHandleAllocator.allocate();
-
- if(type == GL_VERTEX_SHADER)
- {
- mShaderMap[handle] = new VertexShader(this, handle);
- }
- else if(type == GL_FRAGMENT_SHADER)
- {
- mShaderMap[handle] = new FragmentShader(this, handle);
- }
- else UNREACHABLE();
-
- return handle;
-}
-
-// Returns an unused program/shader name
-GLuint ResourceManager::createProgram()
-{
- GLuint handle = mProgramShaderHandleAllocator.allocate();
-
- mProgramMap[handle] = new Program(this, handle);
-
- return handle;
-}
-
// Returns an unused texture name
GLuint ResourceManager::createTexture()
{
@@ -138,44 +98,6 @@
}
}
-void ResourceManager::deleteShader(GLuint shader)
-{
- ShaderMap::iterator shaderObject = mShaderMap.find(shader);
-
- if(shaderObject != mShaderMap.end())
- {
- if(shaderObject->second->getRefCount() == 0)
- {
- mProgramShaderHandleAllocator.release(shaderObject->first);
- delete shaderObject->second;
- mShaderMap.erase(shaderObject);
- }
- else
- {
- shaderObject->second->flagForDeletion();
- }
- }
-}
-
-void ResourceManager::deleteProgram(GLuint program)
-{
- ProgramMap::iterator programObject = mProgramMap.find(program);
-
- if(programObject != mProgramMap.end())
- {
- if(programObject->second->getRefCount() == 0)
- {
- mProgramShaderHandleAllocator.release(programObject->first);
- delete programObject->second;
- mProgramMap.erase(programObject);
- }
- else
- {
- programObject->second->flagForDeletion();
- }
- }
-}
-
void ResourceManager::deleteTexture(GLuint texture)
{
TextureMap::iterator textureObject = mTextureMap.find(texture);
@@ -214,20 +136,6 @@
}
}
-Shader *ResourceManager::getShader(unsigned int handle)
-{
- ShaderMap::iterator shader = mShaderMap.find(handle);
-
- if(shader == mShaderMap.end())
- {
- return NULL;
- }
- else
- {
- return shader->second;
- }
-}
-
Texture *ResourceManager::getTexture(unsigned int handle)
{
if(handle == 0) return NULL;
@@ -244,20 +152,6 @@
}
}
-Program *ResourceManager::getProgram(unsigned int handle)
-{
- ProgramMap::iterator program = mProgramMap.find(handle);
-
- if(program == mProgramMap.end())
- {
- return NULL;
- }
- else
- {
- return program->second;
- }
-}
-
Renderbuffer *ResourceManager::getRenderbuffer(unsigned int handle)
{
RenderbufferMap::iterator renderbuffer = mRenderbufferMap.find(handle);
@@ -297,10 +191,6 @@
{
textureObject = new Texture2D(texture);
}
- else if(type == TEXTURE_CUBE)
- {
- textureObject = new TextureCubeMap(texture);
- }
else if(type == TEXTURE_EXTERNAL)
{
textureObject = new TextureExternal(texture);
@@ -320,7 +210,7 @@
{
if(renderbuffer != 0 && !getRenderbuffer(renderbuffer))
{
- Renderbuffer *renderbufferObject = new Renderbuffer(renderbuffer, new Colorbuffer(0, 0, GL_RGBA4, 0));
+ Renderbuffer *renderbufferObject = new Renderbuffer(renderbuffer, new Colorbuffer(0, 0, GL_RGBA4_OES, 0));
mRenderbufferMap[renderbuffer] = renderbufferObject;
renderbufferObject->addRef();
}
diff --git a/src/GLES2/libGLES_CM/ResourceManager.h b/src/GLES2/libGLES_CM/ResourceManager.h
index cd4ae12..5e7be84 100644
--- a/src/GLES2/libGLES_CM/ResourceManager.h
+++ b/src/GLES2/libGLES_CM/ResourceManager.h
@@ -12,21 +12,19 @@
// ResourceManager.h : Defines the ResourceManager class, which tracks objects
// shared by multiple GL contexts.
-#ifndef LIBGLESV2_RESOURCEMANAGER_H_
-#define LIBGLESV2_RESOURCEMANAGER_H_
+#ifndef LIBGLES_CM_RESOURCEMANAGER_H_
+#define LIBGLES_CM_RESOURCEMANAGER_H_
#include "HandleAllocator.h"
-#define GL_APICALL
-#include <GLES2/gl2.h>
+#define GL_API
+#include <GLES/gl.h>
#include <map>
namespace gl
{
class Buffer;
-class Shader;
-class Program;
class Texture;
class Renderbuffer;
@@ -50,20 +48,14 @@
void release();
GLuint createBuffer();
- GLuint createShader(GLenum type);
- GLuint createProgram();
GLuint createTexture();
GLuint createRenderbuffer();
void deleteBuffer(GLuint buffer);
- void deleteShader(GLuint shader);
- void deleteProgram(GLuint program);
void deleteTexture(GLuint texture);
void deleteRenderbuffer(GLuint renderbuffer);
Buffer *getBuffer(GLuint handle);
- Shader *getShader(GLuint handle);
- Program *getProgram(GLuint handle);
Texture *getTexture(GLuint handle);
Renderbuffer *getRenderbuffer(GLuint handle);
@@ -79,14 +71,7 @@
typedef std::map<GLint, Buffer*> BufferMap;
BufferMap mBufferMap;
HandleAllocator mBufferHandleAllocator;
-
- typedef std::map<GLint, Shader*> ShaderMap;
- ShaderMap mShaderMap;
-
- typedef std::map<GLint, Program*> ProgramMap;
- ProgramMap mProgramMap;
- HandleAllocator mProgramShaderHandleAllocator;
-
+
typedef std::map<GLint, Texture*> TextureMap;
TextureMap mTextureMap;
HandleAllocator mTextureHandleAllocator;
@@ -98,4 +83,4 @@
}
-#endif // LIBGLESV2_RESOURCEMANAGER_H_
+#endif // LIBGLES_CM_RESOURCEMANAGER_H_
diff --git a/src/GLES2/libGLES_CM/Shader.cpp b/src/GLES2/libGLES_CM/Shader.cpp
deleted file mode 100644
index e4cb5ee..0000000
--- a/src/GLES2/libGLES_CM/Shader.cpp
+++ /dev/null
@@ -1,511 +0,0 @@
-// SwiftShader Software Renderer
-//
-// Copyright(c) 2005-2013 TransGaming Inc.
-//
-// All rights reserved. No part of this software may be copied, distributed, transmitted,
-// transcribed, stored in a retrieval system, translated into any human or computer
-// language by any means, or disclosed to third parties without the explicit written
-// agreement of TransGaming Inc. Without such an agreement, no rights or licenses, express
-// or implied, including but not limited to any patent rights, are granted to you.
-//
-
-// Shader.cpp: Implements the Shader class and its derived classes
-// VertexShader and FragmentShader. Implements GL shader objects and related
-// functionality. [OpenGL ES 2.0.24] section 2.10 page 24 and section 3.8 page 84.
-
-#include "Shader.h"
-
-#include "main.h"
-#include "utilities.h"
-
-#include "GLSLANG/ShaderLang.h"
-
-#include <string>
-
-namespace gl
-{
-Shader::Shader(ResourceManager *manager, GLuint handle) : mHandle(handle), mResourceManager(manager)
-{
- mSource = NULL;
- mInfoLog = NULL;
-
- clear();
-
- mRefCount = 0;
- mDeleteStatus = false;
-}
-
-Shader::~Shader()
-{
- delete[] mSource;
- delete[] mInfoLog;
-}
-
-GLuint Shader::getHandle() const
-{
- return mHandle;
-}
-
-void Shader::setSource(GLsizei count, const char **string, const GLint *length)
-{
- delete[] mSource;
- int totalLength = 0;
-
- for(int i = 0; i < count; i++)
- {
- if(length && length[i] >= 0)
- {
- totalLength += length[i];
- }
- else
- {
- totalLength += (int)strlen(string[i]);
- }
- }
-
- mSource = new char[totalLength + 1];
- char *code = mSource;
-
- for(int i = 0; i < count; i++)
- {
- int stringLength;
-
- if(length && length[i] >= 0)
- {
- stringLength = length[i];
- }
- else
- {
- stringLength = (int)strlen(string[i]);
- }
-
- strncpy(code, string[i], stringLength);
- code += stringLength;
- }
-
- mSource[totalLength] = '\0';
-}
-
-int Shader::getInfoLogLength() const
-{
- if(!mInfoLog)
- {
- return 0;
- }
- else
- {
- return strlen(mInfoLog) + 1;
- }
-}
-
-void Shader::getInfoLog(GLsizei bufSize, GLsizei *length, char *infoLog)
-{
- int index = 0;
-
- if(bufSize > 0)
- {
- if(mInfoLog)
- {
- index = std::min(bufSize - 1, (int)strlen(mInfoLog));
- memcpy(infoLog, mInfoLog, index);
- }
-
- infoLog[index] = '\0';
- }
-
- if(length)
- {
- *length = index;
- }
-}
-
-int Shader::getSourceLength() const
-{
- if(!mSource)
- {
- return 0;
- }
- else
- {
- return strlen(mSource) + 1;
- }
-}
-
-void Shader::getSource(GLsizei bufSize, GLsizei *length, char *source)
-{
- int index = 0;
-
- if(bufSize > 0)
- {
- if(mSource)
- {
- index = std::min(bufSize - 1, (int)strlen(mSource));
- memcpy(source, mSource, index);
- }
-
- source[index] = '\0';
- }
-
- if(length)
- {
- *length = index;
- }
-}
-
-TranslatorASM *Shader::createCompiler(ShShaderType type)
-{
- ShInitialize();
-
- TranslatorASM *assembler = new TranslatorASM(this, type, SH_GLES2_SPEC);
-
- ShBuiltInResources resources;
- ShInitBuiltInResources(&resources);
- resources.MaxVertexAttribs = MAX_VERTEX_ATTRIBS;
- resources.MaxVertexUniformVectors = MAX_VERTEX_UNIFORM_VECTORS;
- resources.MaxVaryingVectors = MAX_VARYING_VECTORS;
- resources.MaxVertexTextureImageUnits = MAX_VERTEX_TEXTURE_IMAGE_UNITS;
- resources.MaxCombinedTextureImageUnits = MAX_COMBINED_TEXTURE_IMAGE_UNITS;
- resources.MaxTextureImageUnits = MAX_TEXTURE_IMAGE_UNITS;
- resources.MaxFragmentUniformVectors = MAX_FRAGMENT_UNIFORM_VECTORS;
- resources.MaxDrawBuffers = MAX_DRAW_BUFFERS;
- resources.OES_standard_derivatives = 1;
- resources.OES_fragment_precision_high = 1;
- resources.MaxCallStackDepth = 16;
- assembler->Init(resources);
-
- return assembler;
-}
-
-void Shader::clear()
-{
- delete[] mInfoLog;
- mInfoLog = NULL;
-
- varyings.clear();
- activeAttributes.clear();
-}
-
-bool Shader::isCompiled()
-{
- return getShader() != 0;
-}
-
-sw::PixelShader *Shader::getPixelShader() const
-{
- return 0;
-}
-
-sw::VertexShader *Shader::getVertexShader() const
-{
- return 0;
-}
-
-void Shader::addRef()
-{
- mRefCount++;
-}
-
-void Shader::release()
-{
- mRefCount--;
-
- if(mRefCount == 0 && mDeleteStatus)
- {
- mResourceManager->deleteShader(mHandle);
- }
-}
-
-unsigned int Shader::getRefCount() const
-{
- return mRefCount;
-}
-
-bool Shader::isFlaggedForDeletion() const
-{
- return mDeleteStatus;
-}
-
-void Shader::flagForDeletion()
-{
- mDeleteStatus = true;
-}
-
-void Shader::releaseCompiler()
-{
- ShFinalize();
-}
-
-GLenum Shader::parseType(const std::string &type)
-{
- if(type == "float")
- {
- return GL_FLOAT;
- }
- else if(type == "float2")
- {
- return GL_FLOAT_VEC2;
- }
- else if(type == "float3")
- {
- return GL_FLOAT_VEC3;
- }
- else if(type == "float4")
- {
- return GL_FLOAT_VEC4;
- }
- else if(type == "float2x2")
- {
- return GL_FLOAT_MAT2;
- }
- else if(type == "float3x3")
- {
- return GL_FLOAT_MAT3;
- }
- else if(type == "float4x4")
- {
- return GL_FLOAT_MAT4;
- }
- else UNREACHABLE();
-
- return GL_NONE;
-}
-
-// true if varying x has a higher priority in packing than y
-bool Shader::compareVarying(const Varying &x, const Varying &y)
-{
- if(x.type == y.type)
- {
- return x.size() > y.size();
- }
-
- switch (x.type)
- {
- case GL_FLOAT_MAT4: return true;
- case GL_FLOAT_MAT2:
- switch(y.type)
- {
- case GL_FLOAT_MAT4: return false;
- case GL_FLOAT_MAT2: return true;
- case GL_FLOAT_VEC4: return true;
- case GL_FLOAT_MAT3: return true;
- case GL_FLOAT_VEC3: return true;
- case GL_FLOAT_VEC2: return true;
- case GL_FLOAT: return true;
- default: UNREACHABLE();
- }
- break;
- case GL_FLOAT_VEC4:
- switch(y.type)
- {
- case GL_FLOAT_MAT4: return false;
- case GL_FLOAT_MAT2: return false;
- case GL_FLOAT_VEC4: return true;
- case GL_FLOAT_MAT3: return true;
- case GL_FLOAT_VEC3: return true;
- case GL_FLOAT_VEC2: return true;
- case GL_FLOAT: return true;
- default: UNREACHABLE();
- }
- break;
- case GL_FLOAT_MAT3:
- switch(y.type)
- {
- case GL_FLOAT_MAT4: return false;
- case GL_FLOAT_MAT2: return false;
- case GL_FLOAT_VEC4: return false;
- case GL_FLOAT_MAT3: return true;
- case GL_FLOAT_VEC3: return true;
- case GL_FLOAT_VEC2: return true;
- case GL_FLOAT: return true;
- default: UNREACHABLE();
- }
- break;
- case GL_FLOAT_VEC3:
- switch(y.type)
- {
- case GL_FLOAT_MAT4: return false;
- case GL_FLOAT_MAT2: return false;
- case GL_FLOAT_VEC4: return false;
- case GL_FLOAT_MAT3: return false;
- case GL_FLOAT_VEC3: return true;
- case GL_FLOAT_VEC2: return true;
- case GL_FLOAT: return true;
- default: UNREACHABLE();
- }
- break;
- case GL_FLOAT_VEC2:
- switch(y.type)
- {
- case GL_FLOAT_MAT4: return false;
- case GL_FLOAT_MAT2: return false;
- case GL_FLOAT_VEC4: return false;
- case GL_FLOAT_MAT3: return false;
- case GL_FLOAT_VEC3: return false;
- case GL_FLOAT_VEC2: return true;
- case GL_FLOAT: return true;
- default: UNREACHABLE();
- }
- break;
- case GL_FLOAT: return false;
- default: UNREACHABLE();
- }
-
- return false;
-}
-
-VertexShader::VertexShader(ResourceManager *manager, GLuint handle) : Shader(manager, handle)
-{
- vertexShader = 0;
-}
-
-VertexShader::~VertexShader()
-{
- delete vertexShader;
-}
-
-GLenum VertexShader::getType()
-{
- return GL_VERTEX_SHADER;
-}
-
-void VertexShader::compile()
-{
- clear();
-
- delete vertexShader;
- vertexShader = new sw::VertexShader();
-
- TranslatorASM *compiler = createCompiler(SH_VERTEX_SHADER);
-
- // Ensure we don't pass a NULL source to the compiler
- char *source = "\0";
- if(mSource)
- {
- source = mSource;
- }
-
- int success = ShCompile(compiler, &source, 1, SH_OBJECT_CODE);
-
- if(false)
- {
- static int serial = 1;
- char buffer[256];
- sprintf(buffer, "vertex-input-%d-%d.txt", getHandle(), serial);
- FILE *file = fopen(buffer, "wt");
- fprintf(file, mSource);
- fclose(file);
- vertexShader->print("vertex-output-%d-%d.txt", getHandle(), serial);
- serial++;
- }
-
- if(!success)
- {
- delete vertexShader;
- vertexShader = 0;
-
- int infoLogLen = 0;
- ShGetInfo(compiler, SH_INFO_LOG_LENGTH, &infoLogLen);
- mInfoLog = new char[infoLogLen];
- ShGetInfoLog(compiler, mInfoLog);
- TRACE("\n%s", mInfoLog);
- }
-
- delete compiler;
-}
-
-int VertexShader::getSemanticIndex(const std::string &attributeName)
-{
- if(!attributeName.empty())
- {
- for(sh::ActiveAttributes::iterator attribute = activeAttributes.begin(); attribute != activeAttributes.end(); attribute++)
- {
- if(attribute->name == attributeName)
- {
- return attribute->registerIndex;
- }
- }
- }
-
- return -1;
-}
-
-sw::Shader *VertexShader::getShader() const
-{
- return vertexShader;
-}
-
-sw::VertexShader *VertexShader::getVertexShader() const
-{
- return vertexShader;
-}
-
-FragmentShader::FragmentShader(ResourceManager *manager, GLuint handle) : Shader(manager, handle)
-{
- pixelShader = 0;
-}
-
-FragmentShader::~FragmentShader()
-{
- delete pixelShader;
-}
-
-GLenum FragmentShader::getType()
-{
- return GL_FRAGMENT_SHADER;
-}
-
-void FragmentShader::compile()
-{
- clear();
-
- delete pixelShader;
- pixelShader = new sw::PixelShader();
-
- TranslatorASM *compiler = createCompiler(SH_FRAGMENT_SHADER);
-
- // Ensure we don't pass a NULL source to the compiler
- char *source = "\0";
- if(mSource)
- {
- source = mSource;
- }
-
- int success = ShCompile(compiler, &source, 1, SH_OBJECT_CODE);
-
- if(false)
- {
- static int serial = 1;
- char buffer[256];
- sprintf(buffer, "pixel-input-%d-%d.txt", getHandle(), serial);
- FILE *file = fopen(buffer, "wt");
- fprintf(file, mSource);
- fclose(file);
- pixelShader->print("pixel-output-%d-%d.txt", getHandle(), serial);
- serial++;
- }
-
- if(!success)
- {
- delete pixelShader;
- pixelShader = 0;
-
- int infoLogLen = 0;
- ShGetInfo(compiler, SH_INFO_LOG_LENGTH, &infoLogLen);
- mInfoLog = new char[infoLogLen];
- ShGetInfoLog(compiler, mInfoLog);
- TRACE("\n%s", mInfoLog);
- }
-
- delete compiler;
-}
-
-sw::Shader *FragmentShader::getShader() const
-{
- return pixelShader;
-}
-
-sw::PixelShader *FragmentShader::getPixelShader() const
-{
- return pixelShader;
-}
-}
diff --git a/src/GLES2/libGLES_CM/Shader.h b/src/GLES2/libGLES_CM/Shader.h
deleted file mode 100644
index b6e7e70..0000000
--- a/src/GLES2/libGLES_CM/Shader.h
+++ /dev/null
@@ -1,159 +0,0 @@
-// SwiftShader Software Renderer
-//
-// Copyright(c) 2005-2013 TransGaming Inc.
-//
-// All rights reserved. No part of this software may be copied, distributed, transmitted,
-// transcribed, stored in a retrieval system, translated into any human or computer
-// language by any means, or disclosed to third parties without the explicit written
-// agreement of TransGaming Inc. Without such an agreement, no rights or licenses, express
-// or implied, including but not limited to any patent rights, are granted to you.
-//
-
-// Shader.h: Defines the abstract Shader class and its concrete derived
-// classes VertexShader and FragmentShader. Implements GL shader objects and
-// related functionality. [OpenGL ES 2.0.24] section 2.10 page 24 and section
-// 3.8 page 84.
-
-#ifndef LIBGLESV2_SHADER_H_
-#define LIBGLESV2_SHADER_H_
-
-#include "ResourceManager.h"
-
-#include "compiler/TranslatorASM.h"
-
-#define GL_APICALL
-#include <GLES2/gl2.h>
-
-#include <list>
-#include <vector>
-
-namespace sh
-{
- class OutputASM;
-}
-
-namespace gl
-{
-struct Varying
-{
- Varying(GLenum type, const std::string &name, int arraySize, int reg = -1, int col = -1)
- : type(type), name(name), arraySize(arraySize), reg(reg), col(col)
- {
- }
-
- bool isArray() const
- {
- return arraySize >= 1;
- }
-
- int size() const // Unify with gl::Uniform?
- {
- return arraySize > 0 ? arraySize : 1;
- }
-
- GLenum type;
- std::string name;
- int arraySize;
-
- int reg; // First varying register, assigned during link
- int col; // First register element, assigned during link
-};
-
-typedef std::list<Varying> VaryingList;
-
-class Shader
-{
- friend class Program;
- friend class sh::OutputASM;
-
-public:
- Shader(ResourceManager *manager, GLuint handle);
-
- virtual ~Shader();
-
- virtual GLenum getType() = 0;
- GLuint getHandle() const;
-
- void deleteSource();
- void setSource(GLsizei count, const char **string, const GLint *length);
- int getInfoLogLength() const;
- void getInfoLog(GLsizei bufSize, GLsizei *length, char *infoLog);
- int getSourceLength() const;
- void getSource(GLsizei bufSize, GLsizei *length, char *source);
-
- virtual void compile() = 0;
- bool isCompiled();
-
- virtual sw::Shader *getShader() const = 0;
- virtual sw::PixelShader *getPixelShader() const;
- virtual sw::VertexShader *getVertexShader() const;
-
- void addRef();
- void release();
- unsigned int getRefCount() const;
- bool isFlaggedForDeletion() const;
- void flagForDeletion();
-
- static void releaseCompiler();
-
-protected:
- TranslatorASM *createCompiler(ShShaderType type);
- void clear();
-
- static GLenum parseType(const std::string &type);
- static bool compareVarying(const Varying &x, const Varying &y);
-
- char *mSource;
- char *mInfoLog;
-
- VaryingList varyings;
- sh::ActiveUniforms activeUniforms;
- sh::ActiveAttributes activeAttributes;
-
-private:
- const GLuint mHandle;
- unsigned int mRefCount; // Number of program objects this shader is attached to
- bool mDeleteStatus; // Flag to indicate that the shader can be deleted when no longer in use
-
- ResourceManager *mResourceManager;
-};
-
-class VertexShader : public Shader
-{
- friend class Program;
-
-public:
- VertexShader(ResourceManager *manager, GLuint handle);
-
- ~VertexShader();
-
- virtual GLenum getType();
- virtual void compile();
- int getSemanticIndex(const std::string &attributeName);
-
- virtual sw::Shader *getShader() const;
- virtual sw::VertexShader *getVertexShader() const;
-
-private:
- sw::VertexShader *vertexShader;
-};
-
-class FragmentShader : public Shader
-{
-public:
- FragmentShader(ResourceManager *manager, GLuint handle);
-
- ~FragmentShader();
-
- virtual GLenum getType();
- virtual void compile();
-
- virtual sw::Shader *getShader() const;
- virtual sw::PixelShader *getPixelShader() const;
-
-private:
- sw::PixelShader *pixelShader;
-};
-}
-
-#endif // LIBGLESV2_SHADER_H_
diff --git a/src/GLES2/libGLES_CM/Texture.cpp b/src/GLES2/libGLES_CM/Texture.cpp
index 25dbdb1..c3765e1 100644
--- a/src/GLES2/libGLES_CM/Texture.cpp
+++ b/src/GLES2/libGLES_CM/Texture.cpp
@@ -91,7 +91,7 @@
switch(wrap)
{
case GL_REPEAT:
- case GL_MIRRORED_REPEAT:
+ case GL_MIRRORED_REPEAT_OES:
if(getTarget() == GL_TEXTURE_EXTERNAL_OES)
{
return false;
@@ -111,7 +111,7 @@
switch(wrap)
{
case GL_REPEAT:
- case GL_MIRRORED_REPEAT:
+ case GL_MIRRORED_REPEAT_OES:
if(getTarget() == GL_TEXTURE_EXTERNAL_OES)
{
return false;
@@ -689,439 +689,6 @@
return image[level]->isShared();
}
-TextureCubeMap::TextureCubeMap(GLuint id) : Texture(id)
-{
- for(int f = 0; f < 6; f++)
- {
- for(int i = 0; i < MIPMAP_LEVELS; i++)
- {
- image[f][i] = 0;
- }
- }
-
- for(int f = 0; f < 6; f++)
- {
- mFaceProxies[f] = NULL;
- mFaceProxyRefs[f] = 0;
- }
-}
-
-TextureCubeMap::~TextureCubeMap()
-{
- resource->lock(sw::DESTRUCT);
-
- for(int f = 0; f < 6; f++)
- {
- for(int i = 0; i < MIPMAP_LEVELS; i++)
- {
- if(image[f][i])
- {
- image[f][i]->unbind();
- image[f][i] = 0;
- }
- }
- }
-
- resource->unlock();
-
- for(int i = 0; i < 6; i++)
- {
- mFaceProxies[i] = NULL;
- }
-}
-
-// We need to maintain a count of references to renderbuffers acting as
-// proxies for this texture, so that the texture is not deleted while
-// proxy references still exist. If the reference count drops to zero,
-// we set our proxy pointer NULL, so that a new attempt at referencing
-// will cause recreation.
-void TextureCubeMap::addProxyRef(const Renderbuffer *proxy)
-{
- for(int f = 0; f < 6; f++)
- {
- if(mFaceProxies[f] == proxy)
- {
- mFaceProxyRefs[f]++;
- }
- }
-}
-
-void TextureCubeMap::releaseProxy(const Renderbuffer *proxy)
-{
- for(int f = 0; f < 6; f++)
- {
- if(mFaceProxies[f] == proxy)
- {
- if(mFaceProxyRefs[f] > 0)
- {
- mFaceProxyRefs[f]--;
- }
-
- if(mFaceProxyRefs[f] == 0)
- {
- mFaceProxies[f] = NULL;
- }
- }
- }
-}
-
-GLenum TextureCubeMap::getTarget() const
-{
- return GL_TEXTURE_CUBE_MAP;
-}
-
-GLsizei TextureCubeMap::getWidth(GLenum target, GLint level) const
-{
- int face = CubeFaceIndex(target);
- return image[face][level] ? image[face][level]->getWidth() : 0;
-}
-
-GLsizei TextureCubeMap::getHeight(GLenum target, GLint level) const
-{
- int face = CubeFaceIndex(target);
- return image[face][level] ? image[face][level]->getHeight() : 0;
-}
-
-GLenum TextureCubeMap::getFormat(GLenum target, GLint level) const
-{
- int face = CubeFaceIndex(target);
- return image[face][level] ? image[face][level]->getFormat() : 0;
-}
-
-GLenum TextureCubeMap::getType(GLenum target, GLint level) const
-{
- int face = CubeFaceIndex(target);
- return image[face][level] ? image[face][level]->getType() : 0;
-}
-
-sw::Format TextureCubeMap::getInternalFormat(GLenum target, GLint level) const
-{
- int face = CubeFaceIndex(target);
- return image[face][level] ? image[face][level]->getInternalFormat() : sw::FORMAT_NULL;
-}
-
-int TextureCubeMap::getLevelCount() const
-{
- ASSERT(isSamplerComplete());
- int levels = 0;
-
- while(levels < MIPMAP_LEVELS && image[0][levels])
- {
- levels++;
- }
-
- return levels;
-}
-
-void TextureCubeMap::setCompressedImage(GLenum target, GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei imageSize, const void *pixels)
-{
- int face = CubeFaceIndex(target);
-
- if(image[face][level])
- {
- image[face][level]->unbind();
- }
-
- image[face][level] = new Image(this, width, height, format, GL_UNSIGNED_BYTE);
-
- if(!image[face][level])
- {
- return error(GL_OUT_OF_MEMORY);
- }
-
- Texture::setCompressedImage(imageSize, pixels, image[face][level]);
-}
-
-void TextureCubeMap::subImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels)
-{
- Texture::subImage(xoffset, yoffset, width, height, format, type, unpackAlignment, pixels, image[CubeFaceIndex(target)][level]);
-}
-
-void TextureCubeMap::subImageCompressed(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *pixels)
-{
- Texture::subImageCompressed(xoffset, yoffset, width, height, format, imageSize, pixels, image[CubeFaceIndex(target)][level]);
-}
-
-// Tests for cube map sampling completeness. [OpenGL ES 2.0.24] section 3.8.2 page 86.
-bool TextureCubeMap::isSamplerComplete() const
-{
- for(int face = 0; face < 6; face++)
- {
- if(!image[face][0])
- {
- return false;
- }
- }
-
- int size = image[0][0]->getWidth();
-
- if(size <= 0)
- {
- return false;
- }
-
- if(!isMipmapFiltered())
- {
- if(!isCubeComplete())
- {
- return false;
- }
- }
- else
- {
- if(!isMipmapCubeComplete()) // Also tests for isCubeComplete()
- {
- return false;
- }
- }
-
- return true;
-}
-
-// Tests for cube texture completeness. [OpenGL ES 2.0.24] section 3.7.10 page 81.
-bool TextureCubeMap::isCubeComplete() const
-{
- if(image[0][0]->getWidth() <= 0 || image[0][0]->getHeight() != image[0][0]->getWidth())
- {
- return false;
- }
-
- for(unsigned int face = 1; face < 6; face++)
- {
- if(image[face][0]->getWidth() != image[0][0]->getWidth() ||
- image[face][0]->getWidth() != image[0][0]->getHeight() ||
- image[face][0]->getFormat() != image[0][0]->getFormat() ||
- image[face][0]->getType() != image[0][0]->getType())
- {
- return false;
- }
- }
-
- return true;
-}
-
-bool TextureCubeMap::isMipmapCubeComplete() const
-{
- if(!isCubeComplete())
- {
- return false;
- }
-
- GLsizei size = image[0][0]->getWidth();
- int q = log2(size);
-
- for(int face = 0; face < 6; face++)
- {
- for(int level = 1; level <= q; level++)
- {
- if(!image[face][level])
- {
- return false;
- }
-
- if(image[face][level]->getFormat() != image[0][0]->getFormat())
- {
- return false;
- }
-
- if(image[face][level]->getType() != image[0][0]->getType())
- {
- return false;
- }
-
- if(image[face][level]->getWidth() != std::max(1, size >> level))
- {
- return false;
- }
- }
- }
-
- return true;
-}
-
-bool TextureCubeMap::isCompressed(GLenum target, GLint level) const
-{
- return IsCompressed(getFormat(target, level));
-}
-
-bool TextureCubeMap::isDepth(GLenum target, GLint level) const
-{
- return IsDepthTexture(getFormat(target, level));
-}
-
-void TextureCubeMap::setImage(GLenum target, GLint level, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels)
-{
- int face = CubeFaceIndex(target);
-
- if(image[face][level])
- {
- image[face][level]->unbind();
- }
-
- image[face][level] = new Image(this, width, height, format, type);
-
- if(!image[face][level])
- {
- return error(GL_OUT_OF_MEMORY);
- }
-
- Texture::setImage(format, type, unpackAlignment, pixels, image[face][level]);
-}
-
-void TextureCubeMap::copyImage(GLenum target, GLint level, GLenum format, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source)
-{
- Image *renderTarget = source->getRenderTarget();
-
- if(!renderTarget)
- {
- ERR("Failed to retrieve the render target.");
- return error(GL_OUT_OF_MEMORY);
- }
-
- int face = CubeFaceIndex(target);
-
- if(image[face][level])
- {
- image[face][level]->unbind();
- }
-
- image[face][level] = new Image(this, width, height, format, GL_UNSIGNED_BYTE);
-
- if(!image[face][level])
- {
- return error(GL_OUT_OF_MEMORY);
- }
-
- if(width != 0 && height != 0)
- {
- sw::Rect sourceRect = {x, y, x + width, y + height};
- sourceRect.clip(0, 0, source->getColorbuffer()->getWidth(), source->getColorbuffer()->getHeight());
-
- copy(renderTarget, sourceRect, format, 0, 0, image[face][level]);
- }
-
- renderTarget->release();
-}
-
-Image *TextureCubeMap::getImage(int face, unsigned int level)
-{
- return image[face][level];
-}
-
-Image *TextureCubeMap::getImage(GLenum face, unsigned int level)
-{
- return image[CubeFaceIndex(face)][level];
-}
-
-void TextureCubeMap::copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source)
-{
- int face = CubeFaceIndex(target);
-
- if(!image[face][level])
- {
- return error(GL_INVALID_OPERATION);
- }
-
- GLsizei size = image[face][level]->getWidth();
-
- if(xoffset + width > size || yoffset + height > size)
- {
- return error(GL_INVALID_VALUE);
- }
-
- Image *renderTarget = source->getRenderTarget();
-
- if(!renderTarget)
- {
- ERR("Failed to retrieve the render target.");
- return error(GL_OUT_OF_MEMORY);
- }
-
- sw::Rect sourceRect = {x, y, x + width, y + height};
- sourceRect.clip(0, 0, source->getColorbuffer()->getWidth(), source->getColorbuffer()->getHeight());
-
- copy(renderTarget, sourceRect, image[face][level]->getFormat(), xoffset, yoffset, image[face][level]);
-
- renderTarget->release();
-}
-
-void TextureCubeMap::generateMipmaps()
-{
- if(!isCubeComplete())
- {
- return error(GL_INVALID_OPERATION);
- }
-
- unsigned int q = log2(image[0][0]->getWidth());
-
- for(unsigned int f = 0; f < 6; f++)
- {
- for(unsigned int i = 1; i <= q; i++)
- {
- if(image[f][i])
- {
- image[f][i]->unbind();
- }
-
- image[f][i] = new Image(this, std::max(image[0][0]->getWidth() >> i, 1), std::max(image[0][0]->getHeight() >> i, 1), image[0][0]->getFormat(), image[0][0]->getType());
-
- if(!image[f][i])
- {
- return error(GL_OUT_OF_MEMORY);
- }
-
- getDevice()->stretchRect(image[f][i - 1], 0, image[f][i], 0, true);
- }
- }
-}
-
-Renderbuffer *TextureCubeMap::getRenderbuffer(GLenum target)
-{
- if(!IsCubemapTextureTarget(target))
- {
- return error(GL_INVALID_OPERATION, (Renderbuffer *)NULL);
- }
-
- int face = CubeFaceIndex(target);
-
- if(mFaceProxies[face] == NULL)
- {
- mFaceProxies[face] = new Renderbuffer(id(), new RenderbufferTextureCubeMap(this, target));
- }
-
- return mFaceProxies[face];
-}
-
-Image *TextureCubeMap::getRenderTarget(GLenum target, unsigned int level)
-{
- ASSERT(IsCubemapTextureTarget(target));
- ASSERT(level < IMPLEMENTATION_MAX_TEXTURE_LEVELS);
-
- int face = CubeFaceIndex(target);
-
- if(image[face][level])
- {
- image[face][level]->addRef();
- }
-
- return image[face][level];
-}
-
-bool TextureCubeMap::isShared(GLenum target, unsigned int level) const
-{
- ASSERT(IsCubemapTextureTarget(target));
- ASSERT(level < IMPLEMENTATION_MAX_TEXTURE_LEVELS);
-
- int face = CubeFaceIndex(target);
-
- if(!image[face][level])
- {
- return false;
- }
-
- return image[face][level]->isShared();
-}
-
TextureExternal::TextureExternal(GLuint id) : Texture2D(id)
{
mMinFilter = GL_LINEAR;
diff --git a/src/GLES2/libGLES_CM/Texture.h b/src/GLES2/libGLES_CM/Texture.h
index 085fe92..b37317c 100644
--- a/src/GLES2/libGLES_CM/Texture.h
+++ b/src/GLES2/libGLES_CM/Texture.h
@@ -13,16 +13,16 @@
// classes Texture2D and TextureCubeMap. Implements GL texture objects and
// related functionality. [OpenGL ES 2.0.24] section 3.7 page 63.
-#ifndef LIBGLESV2_TEXTURE_H_
-#define LIBGLESV2_TEXTURE_H_
+#ifndef LIBGLES_CM_TEXTURE_H_
+#define LIBGLES_CM_TEXTURE_H_
#include "Renderbuffer.h"
#include "RefCountObject.h"
#include "utilities.h"
#include "common/debug.h"
-#define GL_APICALL
-#include <GLES2/gl2.h>
+#define GL_API
+#include <GLES/gl.h>
#include <vector>
@@ -165,63 +165,6 @@
unsigned int mProxyRefs;
};
-class TextureCubeMap : public Texture
-{
-public:
- explicit TextureCubeMap(GLuint id);
-
- virtual ~TextureCubeMap();
-
- void addProxyRef(const Renderbuffer *proxy);
- void releaseProxy(const Renderbuffer *proxy);
-
- virtual GLenum getTarget() const;
-
- virtual GLsizei getWidth(GLenum target, GLint level) const;
- virtual GLsizei getHeight(GLenum target, GLint level) const;
- virtual GLenum getFormat(GLenum target, GLint level) const;
- virtual GLenum getType(GLenum target, GLint level) const;
- virtual sw::Format getInternalFormat(GLenum target, GLint level) const;
- virtual int getLevelCount() const;
-
- void setImage(GLenum target, GLint level, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
- void setCompressedImage(GLenum target, GLint level, GLenum format, GLsizei width, GLsizei height, GLsizei imageSize, const void *pixels);
-
- void subImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint unpackAlignment, const void *pixels);
- void subImageCompressed(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *pixels);
- void copyImage(GLenum target, GLint level, GLenum format, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source);
- virtual void copySubImage(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height, Framebuffer *source);
-
- virtual bool isSamplerComplete() const;
- virtual bool isCompressed(GLenum target, GLint level) const;
- virtual bool isDepth(GLenum target, GLint level) const;
-
- virtual void generateMipmaps();
-
- virtual Renderbuffer *getRenderbuffer(GLenum target);
- virtual Image *getRenderTarget(GLenum target, unsigned int level);
- virtual bool isShared(GLenum target, unsigned int level) const;
-
- Image *getImage(int face, unsigned int level);
-
-private:
- bool isCubeComplete() const;
- bool isMipmapCubeComplete() const;
-
- // face is one of the GL_TEXTURE_CUBE_MAP_* enumerants. Returns NULL on failure.
- Image *getImage(GLenum face, unsigned int level);
-
- Image *image[6][IMPLEMENTATION_MAX_TEXTURE_LEVELS];
-
- // A specific internal reference count is kept for colorbuffer proxy references,
- // because, as the renderbuffer acting as proxy will maintain a binding pointer
- // back to this texture, there would be a circular reference if we used a binding
- // pointer here. This reference count will cause the pointer to be set to NULL if
- // the count drops to zero, but will not cause deletion of the Renderbuffer.
- Renderbuffer *mFaceProxies[6];
- unsigned int mFaceProxyRefs[6];
-};
-
class TextureExternal : public Texture2D
{
public:
@@ -235,4 +178,4 @@
};
}
-#endif // LIBGLESV2_TEXTURE_H_
+#endif // LIBGLES_CM_TEXTURE_H_
diff --git a/src/GLES2/libGLES_CM/VertexDataManager.cpp b/src/GLES2/libGLES_CM/VertexDataManager.cpp
index ff88a6d..3911fb2 100644
--- a/src/GLES2/libGLES_CM/VertexDataManager.cpp
+++ b/src/GLES2/libGLES_CM/VertexDataManager.cpp
@@ -15,10 +15,11 @@
#include "VertexDataManager.h"
#include "Buffer.h"
-#include "Program.h"
#include "IndexDataManager.h"
#include "common/debug.h"
+#include <algorithm>
+
namespace
{
enum {INITIAL_STREAM_BUFFER_SIZE = 1024 * 1024};
@@ -116,12 +117,11 @@
}
const VertexAttributeArray &attribs = mContext->getVertexAttributes();
- Program *program = mContext->getCurrentProgram();
// Determine the required storage size per used buffer
for(int i = 0; i < MAX_VERTEX_ATTRIBS; i++)
{
- if(program->getAttributeStream(i) != -1 && attribs[i].mArrayEnabled)
+ if(attribs[i].mArrayEnabled)
{
if(!attribs[i].mBoundBuffer)
{
@@ -135,71 +135,68 @@
// Perform the vertex data translations
for(int i = 0; i < MAX_VERTEX_ATTRIBS; i++)
{
- if(program->getAttributeStream(i) != -1)
+ if(attribs[i].mArrayEnabled)
{
- if(attribs[i].mArrayEnabled)
+ Buffer *buffer = attribs[i].mBoundBuffer.get();
+
+ if(!buffer && attribs[i].mPointer == NULL)
{
- Buffer *buffer = attribs[i].mBoundBuffer.get();
+ // This is an application error that would normally result in a crash, but we catch it and return an error
+ ERR("An enabled vertex array has no buffer and no pointer.");
+ return GL_INVALID_OPERATION;
+ }
- if(!buffer && attribs[i].mPointer == NULL)
- {
- // This is an application error that would normally result in a crash, but we catch it and return an error
- ERR("An enabled vertex array has no buffer and no pointer.");
- return GL_INVALID_OPERATION;
- }
+ sw::Resource *staticBuffer = buffer ? buffer->getResource() : NULL;
- sw::Resource *staticBuffer = buffer ? buffer->getResource() : NULL;
-
- if(staticBuffer)
- {
- translated[i].vertexBuffer = staticBuffer;
- translated[i].offset = start * attribs[i].stride() + attribs[i].mOffset;
- translated[i].stride = attribs[i].stride();
- }
- else
- {
- unsigned int streamOffset = writeAttributeData(mStreamingBuffer, start, count, attribs[i]);
-
- if(streamOffset == -1)
- {
- return GL_OUT_OF_MEMORY;
- }
-
- translated[i].vertexBuffer = mStreamingBuffer->getResource();
- translated[i].offset = streamOffset;
- translated[i].stride = attribs[i].typeSize();
- }
-
- switch(attribs[i].mType)
- {
- case GL_BYTE: translated[i].type = sw::STREAMTYPE_SBYTE; break;
- case GL_UNSIGNED_BYTE: translated[i].type = sw::STREAMTYPE_BYTE; break;
- case GL_SHORT: translated[i].type = sw::STREAMTYPE_SHORT; break;
- case GL_UNSIGNED_SHORT: translated[i].type = sw::STREAMTYPE_USHORT; break;
- case GL_FIXED: translated[i].type = sw::STREAMTYPE_FIXED; break;
- case GL_FLOAT: translated[i].type = sw::STREAMTYPE_FLOAT; break;
- default: UNREACHABLE(); translated[i].type = sw::STREAMTYPE_FLOAT; break;
- }
-
- translated[i].count = attribs[i].mSize;
- translated[i].normalized = attribs[i].mNormalized;
+ if(staticBuffer)
+ {
+ translated[i].vertexBuffer = staticBuffer;
+ translated[i].offset = start * attribs[i].stride() + attribs[i].mOffset;
+ translated[i].stride = attribs[i].stride();
}
else
{
- if(mDirtyCurrentValue[i])
- {
- delete mCurrentValueBuffer[i];
- mCurrentValueBuffer[i] = new ConstantVertexBuffer(attribs[i].mCurrentValue[0], attribs[i].mCurrentValue[1], attribs[i].mCurrentValue[2], attribs[i].mCurrentValue[3]);
- mDirtyCurrentValue[i] = false;
- }
+ unsigned int streamOffset = writeAttributeData(mStreamingBuffer, start, count, attribs[i]);
- translated[i].vertexBuffer = mCurrentValueBuffer[i]->getResource();
+ if(streamOffset == -1)
+ {
+ return GL_OUT_OF_MEMORY;
+ }
- translated[i].type = sw::STREAMTYPE_FLOAT;
- translated[i].count = 4;
- translated[i].stride = 0;
- translated[i].offset = 0;
+ translated[i].vertexBuffer = mStreamingBuffer->getResource();
+ translated[i].offset = streamOffset;
+ translated[i].stride = attribs[i].typeSize();
}
+
+ switch(attribs[i].mType)
+ {
+ case GL_BYTE: translated[i].type = sw::STREAMTYPE_SBYTE; break;
+ case GL_UNSIGNED_BYTE: translated[i].type = sw::STREAMTYPE_BYTE; break;
+ case GL_SHORT: translated[i].type = sw::STREAMTYPE_SHORT; break;
+ case GL_UNSIGNED_SHORT: translated[i].type = sw::STREAMTYPE_USHORT; break;
+ case GL_FIXED: translated[i].type = sw::STREAMTYPE_FIXED; break;
+ case GL_FLOAT: translated[i].type = sw::STREAMTYPE_FLOAT; break;
+ default: UNREACHABLE(); translated[i].type = sw::STREAMTYPE_FLOAT; break;
+ }
+
+ translated[i].count = attribs[i].mSize;
+ translated[i].normalized = attribs[i].mNormalized;
+ }
+ else
+ {
+ if(mDirtyCurrentValue[i])
+ {
+ delete mCurrentValueBuffer[i];
+ mCurrentValueBuffer[i] = new ConstantVertexBuffer(attribs[i].mCurrentValue[0], attribs[i].mCurrentValue[1], attribs[i].mCurrentValue[2], attribs[i].mCurrentValue[3]);
+ mDirtyCurrentValue[i] = false;
+ }
+
+ translated[i].vertexBuffer = mCurrentValueBuffer[i]->getResource();
+
+ translated[i].type = sw::STREAMTYPE_FLOAT;
+ translated[i].count = 4;
+ translated[i].stride = 0;
+ translated[i].offset = 0;
}
}
diff --git a/src/GLES2/libGLES_CM/VertexDataManager.h b/src/GLES2/libGLES_CM/VertexDataManager.h
index 8800219..aae94b9 100644
--- a/src/GLES2/libGLES_CM/VertexDataManager.h
+++ b/src/GLES2/libGLES_CM/VertexDataManager.h
@@ -12,14 +12,14 @@
// VertexDataManager.h: Defines the VertexDataManager, a class that
// runs the Buffer translation process.
-#ifndef LIBGLESV2_VERTEXDATAMANAGER_H_
-#define LIBGLESV2_VERTEXDATAMANAGER_H_
+#ifndef LIBGLES_CM_VERTEXDATAMANAGER_H_
+#define LIBGLES_CM_VERTEXDATAMANAGER_H_
#include "Context.h"
#include "Device.hpp"
-#define GL_APICALL
-#include <GLES2/gl2.h>
+#define GL_API
+#include <GLES/gl.h>
namespace gl
{
@@ -96,4 +96,4 @@
}
-#endif // LIBGLESV2_VERTEXDATAMANAGER_H_
+#endif // LIBGLES_CM_VERTEXDATAMANAGER_H_
diff --git a/src/GLES2/libGLES_CM/libGLES_CM.cpp b/src/GLES2/libGLES_CM/libGLES_CM.cpp
index cde61ed..b3b502b 100644
--- a/src/GLES2/libGLES_CM/libGLES_CM.cpp
+++ b/src/GLES2/libGLES_CM/libGLES_CM.cpp
@@ -8,27 +8,25 @@
// agreement of TransGaming Inc. Without such an agreement, no rights or licenses, express
// or implied, including but not limited to any patent rights, are granted to you.
//
-// libGLESv2.cpp: Implements the exported OpenGL ES 2.0 functions.
+// libGLES_CM.cpp: Implements the exported OpenGL ES 1.1 functions.
#include "main.h"
#include "mathutil.h"
#include "utilities.h"
#include "Buffer.h"
#include "Context.h"
-#include "Fence.h"
#include "Framebuffer.h"
-#include "Program.h"
#include "Renderbuffer.h"
-#include "Shader.h"
#include "Texture.h"
#include "Query.h"
#include "common/debug.h"
#include "Common/Version.h"
#include "Main/Register.hpp"
-#define GL_APICALL
-#include <GLES2/gl2.h>
-#include <GLES2/gl2ext.h>
+#define GL_API
+#include <GLES/gl.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GLES/glext.h>
#include <exception>
#include <limits>
@@ -55,7 +53,7 @@
return error(GL_INVALID_OPERATION, false);
}
- if(format != GL_NONE && format != texture->getFormat(target, level))
+ if(format != GL_NONE_OES && format != texture->getFormat(target, level))
{
return error(GL_INVALID_OPERATION, false);
}
@@ -146,129 +144,14 @@
}
}
-void GL_APIENTRY glAttachShader(GLuint program, GLuint shader)
+void GL_APIENTRY glAlphaFunc(GLenum func, GLclampf ref)
{
- TRACE("(GLuint program = %d, GLuint shader = %d)", program, shader);
-
- try
- {
- gl::Context *context = gl::getContext();
-
- if(context)
- {
- gl::Program *programObject = context->getProgram(program);
- gl::Shader *shaderObject = context->getShader(shader);
-
- if(!programObject)
- {
- if(context->getShader(program))
- {
- return error(GL_INVALID_OPERATION);
- }
- else
- {
- return error(GL_INVALID_VALUE);
- }
- }
-
- if(!shaderObject)
- {
- if(context->getProgram(shader))
- {
- return error(GL_INVALID_OPERATION);
- }
- else
- {
- return error(GL_INVALID_VALUE);
- }
- }
-
- if(!programObject->attachShader(shaderObject))
- {
- return error(GL_INVALID_OPERATION);
- }
- }
- }
- catch(std::bad_alloc&)
- {
- return error(GL_OUT_OF_MEMORY);
- }
+ UNIMPLEMENTED();
}
-void GL_APIENTRY glBeginQueryEXT(GLenum target, GLuint id)
+void GL_APIENTRY glAlphaFuncx(GLenum func, GLclampx ref)
{
- TRACE("(GLenum target = 0x%X, GLuint %d)", target, id);
-
- try
- {
- switch(target)
- {
- case GL_ANY_SAMPLES_PASSED_EXT:
- case GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT:
- break;
- default:
- return error(GL_INVALID_ENUM);
- }
-
- if(id == 0)
- {
- return error(GL_INVALID_OPERATION);
- }
-
- gl::Context *context = gl::getContext();
-
- if(context)
- {
- context->beginQuery(target, id);
- }
- }
- catch(std::bad_alloc&)
- {
- return error(GL_OUT_OF_MEMORY);
- }
-}
-
-void GL_APIENTRY glBindAttribLocation(GLuint program, GLuint index, const GLchar* name)
-{
- TRACE("(GLuint program = %d, GLuint index = %d, const GLchar* name = 0x%0.8p)", program, index, name);
-
- try
- {
- if(index >= gl::MAX_VERTEX_ATTRIBS)
- {
- return error(GL_INVALID_VALUE);
- }
-
- gl::Context *context = gl::getContext();
-
- if(context)
- {
- gl::Program *programObject = context->getProgram(program);
-
- if(!programObject)
- {
- if(context->getShader(program))
- {
- return error(GL_INVALID_OPERATION);
- }
- else
- {
- return error(GL_INVALID_VALUE);
- }
- }
-
- if(strncmp(name, "gl_", 3) == 0)
- {
- return error(GL_INVALID_OPERATION);
- }
-
- programObject->bindAttributeLocation(index, name);
- }
- }
- catch(std::bad_alloc&)
- {
- return error(GL_OUT_OF_MEMORY);
- }
+ UNIMPLEMENTED();
}
void GL_APIENTRY glBindBuffer(GLenum target, GLuint buffer)
@@ -306,7 +189,7 @@
try
{
- if(target != GL_FRAMEBUFFER && target != GL_DRAW_FRAMEBUFFER_ANGLE && target != GL_READ_FRAMEBUFFER_ANGLE)
+ if(target != GL_FRAMEBUFFER_OES)
{
return error(GL_INVALID_ENUM);
}
@@ -315,15 +198,7 @@
if(context)
{
- if(target == GL_READ_FRAMEBUFFER_ANGLE || target == GL_FRAMEBUFFER)
- {
- context->bindReadFramebuffer(framebuffer);
- }
-
- if(target == GL_DRAW_FRAMEBUFFER_ANGLE || target == GL_FRAMEBUFFER)
- {
- context->bindDrawFramebuffer(framebuffer);
- }
+ context->bindFramebuffer(framebuffer);
}
}
catch(std::bad_alloc&)
@@ -332,13 +207,37 @@
}
}
-void GL_APIENTRY glBindRenderbuffer(GLenum target, GLuint renderbuffer)
+void GL_APIENTRY glBindFramebufferOES(GLenum target, GLuint framebuffer)
+{
+ TRACE("(GLenum target = 0x%X, GLuint framebuffer = %d)", target, framebuffer);
+
+ try
+ {
+ if(target != GL_FRAMEBUFFER_OES)
+ {
+ return error(GL_INVALID_ENUM);
+ }
+
+ gl::Context *context = gl::getContext();
+
+ if(context)
+ {
+ context->bindFramebuffer(framebuffer);
+ }
+ }
+ catch(std::bad_alloc&)
+ {
+ return error(GL_OUT_OF_MEMORY);
+ }
+}
+
+void GL_APIENTRY glBindRenderbufferOES(GLenum target, GLuint renderbuffer)
{
TRACE("(GLenum target = 0x%X, GLuint renderbuffer = %d)", target, renderbuffer);
try
{
- if(target != GL_RENDERBUFFER)
+ if(target != GL_RENDERBUFFER_OES)
{
return error(GL_INVALID_ENUM);
}
@@ -356,6 +255,7 @@
}
}
+
void GL_APIENTRY glBindTexture(GLenum target, GLuint texture)
{
TRACE("(GLenum target = 0x%X, GLuint texture = %d)", target, texture);
@@ -378,9 +278,6 @@
case GL_TEXTURE_2D:
context->bindTexture2D(texture);
return;
- case GL_TEXTURE_CUBE_MAP:
- context->bindTextureCubeMap(texture);
- return;
case GL_TEXTURE_EXTERNAL_OES:
context->bindTextureExternal(texture);
return;
@@ -395,32 +292,7 @@
}
}
-void GL_APIENTRY glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
-{
- TRACE("(GLclampf red = %f, GLclampf green = %f, GLclampf blue = %f, GLclampf alpha = %f)",
- red, green, blue, alpha);
-
- try
- {
- gl::Context* context = gl::getContext();
-
- if(context)
- {
- context->setBlendColor(gl::clamp01(red), gl::clamp01(green), gl::clamp01(blue), gl::clamp01(alpha));
- }
- }
- catch(std::bad_alloc&)
- {
- return error(GL_OUT_OF_MEMORY);
- }
-}
-
-void GL_APIENTRY glBlendEquation(GLenum mode)
-{
- glBlendEquationSeparate(mode, mode);
-}
-
-void GL_APIENTRY glBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha)
+void GL_APIENTRY glBlendEquationSeparateOES(GLenum modeRGB, GLenum modeAlpha)
{
TRACE("(GLenum modeRGB = 0x%X, GLenum modeAlpha = 0x%X)", modeRGB, modeAlpha);
@@ -428,9 +300,9 @@
{
switch(modeRGB)
{
- case GL_FUNC_ADD:
- case GL_FUNC_SUBTRACT:
- case GL_FUNC_REVERSE_SUBTRACT:
+ case GL_FUNC_ADD_OES:
+ case GL_FUNC_SUBTRACT_OES:
+ case GL_FUNC_REVERSE_SUBTRACT_OES:
case GL_MIN_EXT:
case GL_MAX_EXT:
break;
@@ -440,9 +312,9 @@
switch(modeAlpha)
{
- case GL_FUNC_ADD:
- case GL_FUNC_SUBTRACT:
- case GL_FUNC_REVERSE_SUBTRACT:
+ case GL_FUNC_ADD_OES:
+ case GL_FUNC_SUBTRACT_OES:
+ case GL_FUNC_REVERSE_SUBTRACT_OES:
case GL_MIN_EXT:
case GL_MAX_EXT:
break;
@@ -465,10 +337,10 @@
void GL_APIENTRY glBlendFunc(GLenum sfactor, GLenum dfactor)
{
- glBlendFuncSeparate(sfactor, dfactor, sfactor, dfactor);
+ glBlendFuncSeparateOES(sfactor, dfactor, sfactor, dfactor);
}
-void GL_APIENTRY glBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
+void GL_APIENTRY glBlendFuncSeparateOES(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha)
{
TRACE("(GLenum srcRGB = 0x%X, GLenum dstRGB = 0x%X, GLenum srcAlpha = 0x%X, GLenum dstAlpha = 0x%X)",
srcRGB, dstRGB, srcAlpha, dstAlpha);
@@ -487,10 +359,6 @@
case GL_ONE_MINUS_SRC_ALPHA:
case GL_DST_ALPHA:
case GL_ONE_MINUS_DST_ALPHA:
- case GL_CONSTANT_COLOR:
- case GL_ONE_MINUS_CONSTANT_COLOR:
- case GL_CONSTANT_ALPHA:
- case GL_ONE_MINUS_CONSTANT_ALPHA:
case GL_SRC_ALPHA_SATURATE:
break;
default:
@@ -509,10 +377,6 @@
case GL_ONE_MINUS_SRC_ALPHA:
case GL_DST_ALPHA:
case GL_ONE_MINUS_DST_ALPHA:
- case GL_CONSTANT_COLOR:
- case GL_ONE_MINUS_CONSTANT_COLOR:
- case GL_CONSTANT_ALPHA:
- case GL_ONE_MINUS_CONSTANT_ALPHA:
break;
default:
return error(GL_INVALID_ENUM);
@@ -530,10 +394,6 @@
case GL_ONE_MINUS_SRC_ALPHA:
case GL_DST_ALPHA:
case GL_ONE_MINUS_DST_ALPHA:
- case GL_CONSTANT_COLOR:
- case GL_ONE_MINUS_CONSTANT_COLOR:
- case GL_CONSTANT_ALPHA:
- case GL_ONE_MINUS_CONSTANT_ALPHA:
case GL_SRC_ALPHA_SATURATE:
break;
default:
@@ -552,10 +412,6 @@
case GL_ONE_MINUS_SRC_ALPHA:
case GL_DST_ALPHA:
case GL_ONE_MINUS_DST_ALPHA:
- case GL_CONSTANT_COLOR:
- case GL_ONE_MINUS_CONSTANT_COLOR:
- case GL_CONSTANT_ALPHA:
- case GL_ONE_MINUS_CONSTANT_ALPHA:
break;
default:
return error(GL_INVALID_ENUM);
@@ -588,7 +444,6 @@
switch(usage)
{
- case GL_STREAM_DRAW:
case GL_STATIC_DRAW:
case GL_DYNAMIC_DRAW:
break;
@@ -682,13 +537,13 @@
}
}
-GLenum GL_APIENTRY glCheckFramebufferStatus(GLenum target)
+GLenum GL_APIENTRY glCheckFramebufferStatusOES(GLenum target)
{
TRACE("(GLenum target = 0x%X)", target);
try
{
- if(target != GL_FRAMEBUFFER && target != GL_DRAW_FRAMEBUFFER_ANGLE && target != GL_READ_FRAMEBUFFER_ANGLE)
+ if(target != GL_FRAMEBUFFER_OES)
{
return error(GL_INVALID_ENUM, 0);
}
@@ -697,15 +552,7 @@
if(context)
{
- gl::Framebuffer *framebuffer = NULL;
- if(target == GL_READ_FRAMEBUFFER_ANGLE)
- {
- framebuffer = context->getReadFramebuffer();
- }
- else
- {
- framebuffer = context->getDrawFramebuffer();
- }
+ gl::Framebuffer *framebuffer = context->getFramebuffer();
return framebuffer->completeness();
}
@@ -762,6 +609,11 @@
}
}
+void GL_APIENTRY glClearColorx(GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha)
+{
+ UNIMPLEMENTED();
+}
+
void GL_APIENTRY glClearDepthf(GLclampf depth)
{
TRACE("(GLclampf depth = %f)", depth);
@@ -781,6 +633,11 @@
}
}
+void GL_APIENTRY glClearDepthx(GLclampx depth)
+{
+ UNIMPLEMENTED();
+}
+
void GL_APIENTRY glClearStencil(GLint s)
{
TRACE("(GLint s = %d)", s);
@@ -800,6 +657,36 @@
}
}
+void GL_APIENTRY glClientActiveTexture(GLenum texture)
+{
+ UNIMPLEMENTED();
+}
+
+void GL_APIENTRY glClipPlanef(GLenum plane, const GLfloat *equation)
+{
+ UNIMPLEMENTED();
+}
+
+void GL_APIENTRY glClipPlanex(GLenum plane, const GLfixed *equation)
+{
+ UNIMPLEMENTED();
+}
+
+void GL_APIENTRY glColor4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
+{
+ UNIMPLEMENTED();
+}
+
+void GL_APIENTRY glColor4ub(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha)
+{
+ UNIMPLEMENTED();
+}
+
+void GL_APIENTRY glColor4x(GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha)
+{
+ UNIMPLEMENTED();
+}
+
void GL_APIENTRY glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
{
TRACE("(GLboolean red = %d, GLboolean green = %d, GLboolean blue = %d, GLboolean alpha = %d)",
@@ -820,37 +707,9 @@
}
}
-void GL_APIENTRY glCompileShader(GLuint shader)
+void GL_APIENTRY glColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer)
{
- TRACE("(GLuint shader = %d)", shader);
-
- try
- {
- gl::Context *context = gl::getContext();
-
- if(context)
- {
- gl::Shader *shaderObject = context->getShader(shader);
-
- if(!shaderObject)
- {
- if(context->getProgram(shader))
- {
- return error(GL_INVALID_OPERATION);
- }
- else
- {
- return error(GL_INVALID_VALUE);
- }
- }
-
- shaderObject->compile();
- }
- }
- catch(std::bad_alloc&)
- {
- return error(GL_OUT_OF_MEMORY);
- }
+ UNIMPLEMENTED();
}
void GL_APIENTRY glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height,
@@ -871,15 +730,12 @@
{
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
- case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
- case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
if(!S3TC_SUPPORT)
{
return error(GL_INVALID_ENUM);
}
break;
- case GL_DEPTH_COMPONENT:
- case GL_DEPTH_COMPONENT16:
+ case GL_DEPTH_COMPONENT16_OES:
case GL_DEPTH_COMPONENT32_OES:
case GL_DEPTH_STENCIL_OES:
case GL_DEPTH24_STENCIL8_OES:
@@ -911,23 +767,6 @@
return error(GL_INVALID_VALUE);
}
break;
- case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
- case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
- case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
- if(width != height)
- {
- return error(GL_INVALID_VALUE);
- }
-
- if(width > (gl::IMPLEMENTATION_MAX_CUBE_MAP_TEXTURE_SIZE >> level) ||
- height > (gl::IMPLEMENTATION_MAX_CUBE_MAP_TEXTURE_SIZE >> level))
- {
- return error(GL_INVALID_VALUE);
- }
- break;
default:
return error(GL_INVALID_ENUM);
}
@@ -948,28 +787,7 @@
texture->setCompressedImage(level, internalformat, width, height, imageSize, data);
}
- else
- {
- gl::TextureCubeMap *texture = context->getTextureCubeMap();
-
- if(!texture)
- {
- return error(GL_INVALID_OPERATION);
- }
-
- switch(target)
- {
- case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
- case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
- case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
- texture->setCompressedImage(target, level, internalformat, width, height, imageSize, data);
- break;
- default: UNREACHABLE();
- }
- }
+ else UNREACHABLE();
}
}
catch(std::bad_alloc&)
@@ -1002,8 +820,6 @@
{
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
- case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
- case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
if(!S3TC_SUPPORT)
{
return error(GL_INVALID_ENUM);
@@ -1047,19 +863,7 @@
texture->subImageCompressed(level, xoffset, yoffset, width, height, format, imageSize, data);
}
}
- else if(gl::IsCubemapTextureTarget(target))
- {
- gl::TextureCubeMap *texture = context->getTextureCubeMap();
-
- if(validateSubImageParams(true, width, height, xoffset, yoffset, target, level, format, texture))
- {
- texture->subImageCompressed(target, level, xoffset, yoffset, width, height, format, imageSize, data);
- }
- }
- else
- {
- UNREACHABLE();
- }
+ else UNREACHABLE();
}
}
catch(std::bad_alloc&)
@@ -1099,35 +903,18 @@
return error(GL_INVALID_VALUE);
}
break;
- case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
- case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
- case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
- if(width != height)
- {
- return error(GL_INVALID_VALUE);
- }
-
- if(width > (gl::IMPLEMENTATION_MAX_CUBE_MAP_TEXTURE_SIZE >> level) ||
- height > (gl::IMPLEMENTATION_MAX_CUBE_MAP_TEXTURE_SIZE >> level))
- {
- return error(GL_INVALID_VALUE);
- }
- break;
default:
return error(GL_INVALID_ENUM);
}
- gl::Framebuffer *framebuffer = context->getReadFramebuffer();
+ gl::Framebuffer *framebuffer = context->getFramebuffer();
- if(framebuffer->completeness() != GL_FRAMEBUFFER_COMPLETE)
+ if(framebuffer->completeness() != GL_FRAMEBUFFER_COMPLETE_OES)
{
- return error(GL_INVALID_FRAMEBUFFER_OPERATION);
+ return error(GL_INVALID_FRAMEBUFFER_OPERATION_OES);
}
- if(context->getReadFramebufferHandle() != 0 && framebuffer->getColorbuffer()->getSamples() > 1)
+ if(context->getFramebufferHandle() != 0 && framebuffer->getColorbuffer()->getSamples() > 1)
{
return error(GL_INVALID_OPERATION);
}
@@ -1141,8 +928,8 @@
case GL_ALPHA:
if(colorbufferFormat != GL_ALPHA &&
colorbufferFormat != GL_RGBA &&
- colorbufferFormat != GL_RGBA4 &&
- colorbufferFormat != GL_RGB5_A1 &&
+ colorbufferFormat != GL_RGBA4_OES &&
+ colorbufferFormat != GL_RGB5_A1_OES &&
colorbufferFormat != GL_RGBA8_OES)
{
return error(GL_INVALID_OPERATION);
@@ -1151,11 +938,11 @@
case GL_LUMINANCE:
case GL_RGB:
if(colorbufferFormat != GL_RGB &&
- colorbufferFormat != GL_RGB565 &&
+ colorbufferFormat != GL_RGB565_OES &&
colorbufferFormat != GL_RGB8_OES &&
colorbufferFormat != GL_RGBA &&
- colorbufferFormat != GL_RGBA4 &&
- colorbufferFormat != GL_RGB5_A1 &&
+ colorbufferFormat != GL_RGBA4_OES &&
+ colorbufferFormat != GL_RGB5_A1_OES &&
colorbufferFormat != GL_RGBA8_OES)
{
return error(GL_INVALID_OPERATION);
@@ -1164,8 +951,8 @@
case GL_LUMINANCE_ALPHA:
case GL_RGBA:
if(colorbufferFormat != GL_RGBA &&
- colorbufferFormat != GL_RGBA4 &&
- colorbufferFormat != GL_RGB5_A1 &&
+ colorbufferFormat != GL_RGBA4_OES &&
+ colorbufferFormat != GL_RGB5_A1_OES &&
colorbufferFormat != GL_RGBA8_OES)
{
return error(GL_INVALID_OPERATION);
@@ -1173,8 +960,6 @@
break;
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
- case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
- case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
if(S3TC_SUPPORT)
{
return error(GL_INVALID_OPERATION);
@@ -1199,17 +984,6 @@
texture->copyImage(level, internalformat, x, y, width, height, framebuffer);
}
- else if(gl::IsCubemapTextureTarget(target))
- {
- gl::TextureCubeMap *texture = context->getTextureCubeMap();
-
- if(!texture)
- {
- return error(GL_INVALID_OPERATION);
- }
-
- texture->copyImage(target, level, internalformat, x, y, width, height, framebuffer);
- }
else UNREACHABLE();
}
}
@@ -1256,14 +1030,14 @@
return error(GL_INVALID_VALUE);
}
- gl::Framebuffer *framebuffer = context->getReadFramebuffer();
+ gl::Framebuffer *framebuffer = context->getFramebuffer();
- if(framebuffer->completeness() != GL_FRAMEBUFFER_COMPLETE)
+ if(framebuffer->completeness() != GL_FRAMEBUFFER_COMPLETE_OES)
{
- return error(GL_INVALID_FRAMEBUFFER_OPERATION);
+ return error(GL_INVALID_FRAMEBUFFER_OPERATION_OES);
}
- if(context->getReadFramebufferHandle() != 0 && framebuffer->getColorbuffer()->getSamples() > 1)
+ if(context->getFramebufferHandle() != 0 && framebuffer->getColorbuffer()->getSamples() > 1)
{
return error(GL_INVALID_OPERATION);
}
@@ -1276,13 +1050,9 @@
{
texture = context->getTexture2D();
}
- else if(gl::IsCubemapTextureTarget(target))
- {
- texture = context->getTextureCubeMap();
- }
else UNREACHABLE();
- if(!validateSubImageParams(false, width, height, xoffset, yoffset, target, level, GL_NONE, texture))
+ if(!validateSubImageParams(false, width, height, xoffset, yoffset, target, level, GL_NONE_OES, texture))
{
return;
}
@@ -1295,8 +1065,8 @@
case GL_ALPHA:
if(colorbufferFormat != GL_ALPHA &&
colorbufferFormat != GL_RGBA &&
- colorbufferFormat != GL_RGBA4 &&
- colorbufferFormat != GL_RGB5_A1 &&
+ colorbufferFormat != GL_RGBA4_OES &&
+ colorbufferFormat != GL_RGB5_A1_OES &&
colorbufferFormat != GL_RGBA8_OES)
{
return error(GL_INVALID_OPERATION);
@@ -1305,11 +1075,11 @@
case GL_LUMINANCE:
case GL_RGB:
if(colorbufferFormat != GL_RGB &&
- colorbufferFormat != GL_RGB565 &&
+ colorbufferFormat != GL_RGB565_OES &&
colorbufferFormat != GL_RGB8_OES &&
colorbufferFormat != GL_RGBA &&
- colorbufferFormat != GL_RGBA4 &&
- colorbufferFormat != GL_RGB5_A1 &&
+ colorbufferFormat != GL_RGBA4_OES &&
+ colorbufferFormat != GL_RGB5_A1_OES &&
colorbufferFormat != GL_RGBA8_OES)
{
return error(GL_INVALID_OPERATION);
@@ -1318,8 +1088,8 @@
case GL_LUMINANCE_ALPHA:
case GL_RGBA:
if(colorbufferFormat != GL_RGBA &&
- colorbufferFormat != GL_RGBA4 &&
- colorbufferFormat != GL_RGB5_A1 &&
+ colorbufferFormat != GL_RGBA4_OES &&
+ colorbufferFormat != GL_RGB5_A1_OES &&
colorbufferFormat != GL_RGBA8_OES)
{
return error(GL_INVALID_OPERATION);
@@ -1327,10 +1097,7 @@
break;
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
- case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
- case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
return error(GL_INVALID_OPERATION);
- case GL_DEPTH_COMPONENT:
case GL_DEPTH_STENCIL_OES:
return error(GL_INVALID_OPERATION);
default:
@@ -1347,55 +1114,6 @@
}
}
-GLuint GL_APIENTRY glCreateProgram(void)
-{
- TRACE("()");
-
- try
- {
- gl::Context *context = gl::getContext();
-
- if(context)
- {
- return context->createProgram();
- }
- }
- catch(std::bad_alloc&)
- {
- return error(GL_OUT_OF_MEMORY, 0);
- }
-
- return 0;
-}
-
-GLuint GL_APIENTRY glCreateShader(GLenum type)
-{
- TRACE("(GLenum type = 0x%X)", type);
-
- try
- {
- gl::Context *context = gl::getContext();
-
- if(context)
- {
- switch(type)
- {
- case GL_FRAGMENT_SHADER:
- case GL_VERTEX_SHADER:
- return context->createShader(type);
- default:
- return error(GL_INVALID_ENUM, 0);
- }
- }
- }
- catch(std::bad_alloc&)
- {
- return error(GL_OUT_OF_MEMORY, 0);
- }
-
- return 0;
-}
-
void GL_APIENTRY glCullFace(GLenum mode)
{
TRACE("(GLenum mode = 0x%X)", mode);
@@ -1453,34 +1171,7 @@
}
}
-void GL_APIENTRY glDeleteFencesNV(GLsizei n, const GLuint* fences)
-{
- TRACE("(GLsizei n = %d, const GLuint* fences = 0x%0.8p)", n, fences);
-
- try
- {
- if(n < 0)
- {
- return error(GL_INVALID_VALUE);
- }
-
- gl::Context *context = gl::getContext();
-
- if(context)
- {
- for(int i = 0; i < n; i++)
- {
- context->deleteFence(fences[i]);
- }
- }
- }
- catch(std::bad_alloc&)
- {
- return error(GL_OUT_OF_MEMORY);
- }
-}
-
-void GL_APIENTRY glDeleteFramebuffers(GLsizei n, const GLuint* framebuffers)
+void GL_APIENTRY glDeleteFramebuffersOES(GLsizei n, const GLuint* framebuffers)
{
TRACE("(GLsizei n = %d, const GLuint* framebuffers = 0x%0.8p)", n, framebuffers);
@@ -1510,70 +1201,7 @@
}
}
-void GL_APIENTRY glDeleteProgram(GLuint program)
-{
- TRACE("(GLuint program = %d)", program);
-
- try
- {
- if(program == 0)
- {
- return;
- }
-
- gl::Context *context = gl::getContext();
-
- if(context)
- {
- if(!context->getProgram(program))
- {
- if(context->getShader(program))
- {
- return error(GL_INVALID_OPERATION);
- }
- else
- {
- return error(GL_INVALID_VALUE);
- }
- }
-
- context->deleteProgram(program);
- }
- }
- catch(std::bad_alloc&)
- {
- return error(GL_OUT_OF_MEMORY);
- }
-}
-
-void GL_APIENTRY glDeleteQueriesEXT(GLsizei n, const GLuint *ids)
-{
- TRACE("(GLsizei n = %d, const GLuint *ids = 0x%0.8p)", n, ids);
-
- try
- {
- if(n < 0)
- {
- return error(GL_INVALID_VALUE);
- }
-
- gl::Context *context = gl::getContext();
-
- if(context)
- {
- for(int i = 0; i < n; i++)
- {
- context->deleteQuery(ids[i]);
- }
- }
- }
- catch(std::bad_alloc&)
- {
- return error(GL_OUT_OF_MEMORY);
- }
-}
-
-void GL_APIENTRY glDeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers)
+void GL_APIENTRY glDeleteRenderbuffersOES(GLsizei n, const GLuint* renderbuffers)
{
TRACE("(GLsizei n = %d, const GLuint* renderbuffers = 0x%0.8p)", n, renderbuffers);
@@ -1600,42 +1228,6 @@
}
}
-void GL_APIENTRY glDeleteShader(GLuint shader)
-{
- TRACE("(GLuint shader = %d)", shader);
-
- try
- {
- if(shader == 0)
- {
- return;
- }
-
- gl::Context *context = gl::getContext();
-
- if(context)
- {
- if(!context->getShader(shader))
- {
- if(context->getProgram(shader))
- {
- return error(GL_INVALID_OPERATION);
- }
- else
- {
- return error(GL_INVALID_VALUE);
- }
- }
-
- context->deleteShader(shader);
- }
- }
- catch(std::bad_alloc&)
- {
- return error(GL_OUT_OF_MEMORY);
- }
-}
-
void GL_APIENTRY glDeleteTextures(GLsizei n, const GLuint* textures)
{
TRACE("(GLsizei n = %d, const GLuint* textures = 0x%0.8p)", n, textures);
@@ -1719,6 +1311,11 @@
}
}
+void GL_APIENTRY glDepthRangex(GLclampx zNear, GLclampx zFar)
+{
+ UNIMPLEMENTED();
+}
+
void GL_APIENTRY glDepthRangef(GLclampf zNear, GLclampf zFar)
{
TRACE("(GLclampf zNear = %f, GLclampf zFar = %f)", zNear, zFar);
@@ -1738,59 +1335,6 @@
}
}
-void GL_APIENTRY glDetachShader(GLuint program, GLuint shader)
-{
- TRACE("(GLuint program = %d, GLuint shader = %d)", program, shader);
-
- try
- {
- gl::Context *context = gl::getContext();
-
- if(context)
- {
-
- gl::Program *programObject = context->getProgram(program);
- gl::Shader *shaderObject = context->getShader(shader);
-
- if(!programObject)
- {
- gl::Shader *shaderByProgramHandle;
- shaderByProgramHandle = context->getShader(program);
- if(!shaderByProgramHandle)
- {
- return error(GL_INVALID_VALUE);
- }
- else
- {
- return error(GL_INVALID_OPERATION);
- }
- }
-
- if(!shaderObject)
- {
- gl::Program *programByShaderHandle = context->getProgram(shader);
- if(!programByShaderHandle)
- {
- return error(GL_INVALID_VALUE);
- }
- else
- {
- return error(GL_INVALID_OPERATION);
- }
- }
-
- if(!programObject->detachShader(shaderObject))
- {
- return error(GL_INVALID_OPERATION);
- }
- }
- }
- catch(std::bad_alloc&)
- {
- return error(GL_OUT_OF_MEMORY);
- }
-}
-
void GL_APIENTRY glDisable(GLenum cap)
{
TRACE("(GLenum cap = 0x%X)", cap);
@@ -1823,28 +1367,9 @@
}
}
-void GL_APIENTRY glDisableVertexAttribArray(GLuint index)
+void GL_APIENTRY glDisableClientState(GLenum array)
{
- TRACE("(GLuint index = %d)", index);
-
- try
- {
- if(index >= gl::MAX_VERTEX_ATTRIBS)
- {
- return error(GL_INVALID_VALUE);
- }
-
- gl::Context *context = gl::getContext();
-
- if(context)
- {
- context->setEnableVertexAttribArray(index, false);
- }
- }
- catch(std::bad_alloc&)
- {
- return error(GL_OUT_OF_MEMORY);
- }
+ UNIMPLEMENTED();
}
void GL_APIENTRY glDrawArrays(GLenum mode, GLint first, GLsizei count)
@@ -1938,82 +1463,9 @@
}
}
-void GL_APIENTRY glEnableVertexAttribArray(GLuint index)
+void GL_APIENTRY glEnableClientState(GLenum array)
{
- TRACE("(GLuint index = %d)", index);
-
- try
- {
- if(index >= gl::MAX_VERTEX_ATTRIBS)
- {
- return error(GL_INVALID_VALUE);
- }
-
- gl::Context *context = gl::getContext();
-
- if(context)
- {
- context->setEnableVertexAttribArray(index, true);
- }
- }
- catch(std::bad_alloc&)
- {
- return error(GL_OUT_OF_MEMORY);
- }
-}
-
-void GL_APIENTRY glEndQueryEXT(GLenum target)
-{
- TRACE("GLenum target = 0x%X)", target);
-
- try
- {
- switch(target)
- {
- case GL_ANY_SAMPLES_PASSED_EXT:
- case GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT:
- break;
- default:
- return error(GL_INVALID_ENUM);
- }
-
- gl::Context *context = gl::getContext();
-
- if(context)
- {
- context->endQuery(target);
- }
- }
- catch(std::bad_alloc&)
- {
- return error(GL_OUT_OF_MEMORY);
- }
-}
-
-void GL_APIENTRY glFinishFenceNV(GLuint fence)
-{
- TRACE("(GLuint fence = %d)", fence);
-
- try
- {
- gl::Context *context = gl::getContext();
-
- if(context)
- {
- gl::Fence* fenceObject = context->getFence(fence);
-
- if(fenceObject == NULL)
- {
- return error(GL_INVALID_OPERATION);
- }
-
- fenceObject->finishFence();
- }
- }
- catch(std::bad_alloc&)
- {
- return error(GL_OUT_OF_MEMORY);
- }
+ UNIMPLEMENTED();
}
void GL_APIENTRY glFinish(void)
@@ -2054,15 +1506,14 @@
}
}
-void GL_APIENTRY glFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
+void GL_APIENTRY glFramebufferRenderbufferOES(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
{
TRACE("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLenum renderbuffertarget = 0x%X, "
"GLuint renderbuffer = %d)", target, attachment, renderbuffertarget, renderbuffer);
try
{
- if((target != GL_FRAMEBUFFER && target != GL_DRAW_FRAMEBUFFER_ANGLE && target != GL_READ_FRAMEBUFFER_ANGLE)
- || (renderbuffertarget != GL_RENDERBUFFER && renderbuffer != 0))
+ if(target != GL_FRAMEBUFFER_OES || (renderbuffertarget != GL_RENDERBUFFER_OES && renderbuffer != 0))
{
return error(GL_INVALID_ENUM);
}
@@ -2071,19 +1522,9 @@
if(context)
{
- gl::Framebuffer *framebuffer = NULL;
- GLuint framebufferHandle = 0;
- if(target == GL_READ_FRAMEBUFFER_ANGLE)
- {
- framebuffer = context->getReadFramebuffer();
- framebufferHandle = context->getReadFramebufferHandle();
- }
- else
- {
- framebuffer = context->getDrawFramebuffer();
- framebufferHandle = context->getDrawFramebufferHandle();
- }
-
+ gl::Framebuffer *framebuffer = context->getFramebuffer();
+ GLuint framebufferHandle = context->getFramebufferHandle();
+
if(!framebuffer || (framebufferHandle == 0 && renderbuffer != 0))
{
return error(GL_INVALID_OPERATION);
@@ -2091,14 +1532,14 @@
switch(attachment)
{
- case GL_COLOR_ATTACHMENT0:
- framebuffer->setColorbuffer(GL_RENDERBUFFER, renderbuffer);
+ case GL_COLOR_ATTACHMENT0_OES:
+ framebuffer->setColorbuffer(GL_RENDERBUFFER_OES, renderbuffer);
break;
- case GL_DEPTH_ATTACHMENT:
- framebuffer->setDepthbuffer(GL_RENDERBUFFER, renderbuffer);
+ case GL_DEPTH_ATTACHMENT_OES:
+ framebuffer->setDepthbuffer(GL_RENDERBUFFER_OES, renderbuffer);
break;
- case GL_STENCIL_ATTACHMENT:
- framebuffer->setStencilbuffer(GL_RENDERBUFFER, renderbuffer);
+ case GL_STENCIL_ATTACHMENT_OES:
+ framebuffer->setStencilbuffer(GL_RENDERBUFFER_OES, renderbuffer);
break;
default:
return error(GL_INVALID_ENUM);
@@ -2111,23 +1552,23 @@
}
}
-void GL_APIENTRY glFramebufferTexture2D(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
+void GL_APIENTRY glFramebufferTexture2DOES(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
{
TRACE("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLenum textarget = 0x%X, "
"GLuint texture = %d, GLint level = %d)", target, attachment, textarget, texture, level);
try
{
- if(target != GL_FRAMEBUFFER && target != GL_DRAW_FRAMEBUFFER_ANGLE && target != GL_READ_FRAMEBUFFER_ANGLE)
+ if(target != GL_FRAMEBUFFER_OES)
{
return error(GL_INVALID_ENUM);
}
switch(attachment)
{
- case GL_COLOR_ATTACHMENT0:
- case GL_DEPTH_ATTACHMENT:
- case GL_STENCIL_ATTACHMENT:
+ case GL_COLOR_ATTACHMENT0_OES:
+ case GL_DEPTH_ATTACHMENT_OES:
+ case GL_STENCIL_ATTACHMENT_OES:
break;
default:
return error(GL_INVALID_ENUM);
@@ -2139,7 +1580,7 @@
{
if(texture == 0)
{
- textarget = GL_NONE;
+ textarget = GL_NONE_OES;
}
else
{
@@ -2163,19 +1604,6 @@
return error(GL_INVALID_OPERATION);
}
break;
-
- case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
- case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
- case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
- if(tex->getTarget() != GL_TEXTURE_CUBE_MAP)
- {
- return error(GL_INVALID_OPERATION);
- }
- break;
-
default:
return error(GL_INVALID_ENUM);
}
@@ -2186,18 +1614,8 @@
}
}
- gl::Framebuffer *framebuffer = NULL;
- GLuint framebufferHandle = 0;
- if(target == GL_READ_FRAMEBUFFER_ANGLE)
- {
- framebuffer = context->getReadFramebuffer();
- framebufferHandle = context->getReadFramebufferHandle();
- }
- else
- {
- framebuffer = context->getDrawFramebuffer();
- framebufferHandle = context->getDrawFramebufferHandle();
- }
+ gl::Framebuffer *framebuffer = context->getFramebuffer();
+ GLuint framebufferHandle = context->getFramebufferHandle();
if(framebufferHandle == 0 || !framebuffer)
{
@@ -2206,9 +1624,9 @@
switch(attachment)
{
- case GL_COLOR_ATTACHMENT0: framebuffer->setColorbuffer(textarget, texture); break;
- case GL_DEPTH_ATTACHMENT: framebuffer->setDepthbuffer(textarget, texture); break;
- case GL_STENCIL_ATTACHMENT: framebuffer->setStencilbuffer(textarget, texture); break;
+ case GL_COLOR_ATTACHMENT0_OES: framebuffer->setColorbuffer(textarget, texture); break;
+ case GL_DEPTH_ATTACHMENT_OES: framebuffer->setDepthbuffer(textarget, texture); break;
+ case GL_STENCIL_ATTACHMENT_OES: framebuffer->setStencilbuffer(textarget, texture); break;
}
}
}
@@ -2218,6 +1636,26 @@
}
}
+void GL_APIENTRY glFogf(GLenum pname, GLfloat param)
+{
+ UNIMPLEMENTED();
+}
+
+void GL_APIENTRY glFogfv(GLenum pname, const GLfloat *params)
+{
+ UNIMPLEMENTED();
+}
+
+void GL_APIENTRY glFogx(GLenum pname, GLfixed param)
+{
+ UNIMPLEMENTED();
+}
+
+void GL_APIENTRY glFogxv(GLenum pname, const GLfixed *params)
+{
+ UNIMPLEMENTED();
+}
+
void GL_APIENTRY glFrontFace(GLenum mode)
{
TRACE("(GLenum mode = 0x%X)", mode);
@@ -2247,6 +1685,51 @@
}
}
+void GL_APIENTRY glFrustumf(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar)
+{
+ UNIMPLEMENTED();
+}
+
+void GL_APIENTRY glFrustumx(GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar)
+{
+ UNIMPLEMENTED();
+}
+
+void GL_APIENTRY glGenerateMipmapOES(GLenum target)
+{
+ TRACE("(GLenum target = 0x%X)", target);
+
+ try
+ {
+ gl::Context *context = gl::getContext();
+
+ if(context)
+ {
+ gl::Texture *texture;
+
+ switch(target)
+ {
+ case GL_TEXTURE_2D:
+ texture = context->getTexture2D();
+ break;
+ default:
+ return error(GL_INVALID_ENUM);
+ }
+
+ if(texture->isCompressed(target, 0) || texture->isDepth(target, 0))
+ {
+ return error(GL_INVALID_OPERATION);
+ }
+
+ texture->generateMipmaps();
+ }
+ }
+ catch(std::bad_alloc&)
+ {
+ return error(GL_OUT_OF_MEMORY);
+ }
+}
+
void GL_APIENTRY glGenBuffers(GLsizei n, GLuint* buffers)
{
TRACE("(GLsizei n = %d, GLuint* buffers = 0x%0.8p)", n, buffers);
@@ -2274,72 +1757,7 @@
}
}
-void GL_APIENTRY glGenerateMipmap(GLenum target)
-{
- TRACE("(GLenum target = 0x%X)", target);
-
- try
- {
- gl::Context *context = gl::getContext();
-
- if(context)
- {
- gl::Texture *texture;
-
- switch(target)
- {
- case GL_TEXTURE_2D:
- texture = context->getTexture2D();
- break;
- case GL_TEXTURE_CUBE_MAP:
- texture = context->getTextureCubeMap();
- break;
- default:
- return error(GL_INVALID_ENUM);
- }
-
- if(texture->isCompressed(target, 0) || texture->isDepth(target, 0))
- {
- return error(GL_INVALID_OPERATION);
- }
-
- texture->generateMipmaps();
- }
- }
- catch(std::bad_alloc&)
- {
- return error(GL_OUT_OF_MEMORY);
- }
-}
-
-void GL_APIENTRY glGenFencesNV(GLsizei n, GLuint* fences)
-{
- TRACE("(GLsizei n = %d, GLuint* fences = 0x%0.8p)", n, fences);
-
- try
- {
- if(n < 0)
- {
- return error(GL_INVALID_VALUE);
- }
-
- gl::Context *context = gl::getContext();
-
- if(context)
- {
- for(int i = 0; i < n; i++)
- {
- fences[i] = context->createFence();
- }
- }
- }
- catch(std::bad_alloc&)
- {
- return error(GL_OUT_OF_MEMORY);
- }
-}
-
-void GL_APIENTRY glGenFramebuffers(GLsizei n, GLuint* framebuffers)
+void GL_APIENTRY glGenFramebuffersOES(GLsizei n, GLuint* framebuffers)
{
TRACE("(GLsizei n = %d, GLuint* framebuffers = 0x%0.8p)", n, framebuffers);
@@ -2366,34 +1784,7 @@
}
}
-void GL_APIENTRY glGenQueriesEXT(GLsizei n, GLuint* ids)
-{
- TRACE("(GLsizei n = %d, GLuint* ids = 0x%0.8p)", n, ids);
-
- try
- {
- if(n < 0)
- {
- return error(GL_INVALID_VALUE);
- }
-
- gl::Context *context = gl::getContext();
-
- if(context)
- {
- for(int i = 0; i < n; i++)
- {
- ids[i] = context->createQuery();
- }
- }
- }
- catch(std::bad_alloc&)
- {
- return error(GL_OUT_OF_MEMORY);
- }
-}
-
-void GL_APIENTRY glGenRenderbuffers(GLsizei n, GLuint* renderbuffers)
+void GL_APIENTRY glGenRenderbuffersOES(GLsizei n, GLuint* renderbuffers)
{
TRACE("(GLsizei n = %d, GLuint* renderbuffers = 0x%0.8p)", n, renderbuffers);
@@ -2447,43 +1838,42 @@
}
}
-void GL_APIENTRY glGetActiveAttrib(GLuint program, GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, GLchar *name)
+void GL_APIENTRY glGetRenderbufferParameterivOES(GLenum target, GLenum pname, GLint* params)
{
- TRACE("(GLuint program = %d, GLuint index = %d, GLsizei bufsize = %d, GLsizei *length = 0x%0.8p, "
- "GLint *size = 0x%0.8p, GLenum *type = %0.8p, GLchar *name = %0.8p)",
- program, index, bufsize, length, size, type, name);
+ TRACE("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", target, pname, params);
try
{
- if(bufsize < 0)
- {
- return error(GL_INVALID_VALUE);
- }
-
gl::Context *context = gl::getContext();
if(context)
{
- gl::Program *programObject = context->getProgram(program);
-
- if(!programObject)
+ if(target != GL_RENDERBUFFER_OES)
{
- if(context->getShader(program))
- {
- return error(GL_INVALID_OPERATION);
- }
- else
- {
- return error(GL_INVALID_VALUE);
- }
+ return error(GL_INVALID_ENUM);
}
- if(index >= (GLuint)programObject->getActiveAttributeCount())
+ if(context->getRenderbufferHandle() == 0)
{
- return error(GL_INVALID_VALUE);
+ return error(GL_INVALID_OPERATION);
}
- programObject->getActiveAttribute(index, bufsize, length, size, type, name);
+ gl::Renderbuffer *renderbuffer = context->getRenderbuffer(context->getRenderbufferHandle());
+
+ switch(pname)
+ {
+ case GL_RENDERBUFFER_WIDTH_OES: *params = renderbuffer->getWidth(); break;
+ case GL_RENDERBUFFER_HEIGHT_OES: *params = renderbuffer->getHeight(); break;
+ case GL_RENDERBUFFER_INTERNAL_FORMAT_OES: *params = renderbuffer->getFormat(); break;
+ case GL_RENDERBUFFER_RED_SIZE_OES: *params = renderbuffer->getRedSize(); break;
+ case GL_RENDERBUFFER_GREEN_SIZE_OES: *params = renderbuffer->getGreenSize(); break;
+ case GL_RENDERBUFFER_BLUE_SIZE_OES: *params = renderbuffer->getBlueSize(); break;
+ case GL_RENDERBUFFER_ALPHA_SIZE_OES: *params = renderbuffer->getAlphaSize(); break;
+ case GL_RENDERBUFFER_DEPTH_SIZE_OES: *params = renderbuffer->getDepthSize(); break;
+ case GL_RENDERBUFFER_STENCIL_SIZE_OES: *params = renderbuffer->getStencilSize(); break;
+ default:
+ return error(GL_INVALID_ENUM);
+ }
}
}
catch(std::bad_alloc&)
@@ -2492,131 +1882,6 @@
}
}
-void GL_APIENTRY glGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name)
-{
- TRACE("(GLuint program = %d, GLuint index = %d, GLsizei bufsize = %d, "
- "GLsizei* length = 0x%0.8p, GLint* size = 0x%0.8p, GLenum* type = 0x%0.8p, GLchar* name = 0x%0.8p)",
- program, index, bufsize, length, size, type, name);
-
- try
- {
- if(bufsize < 0)
- {
- return error(GL_INVALID_VALUE);
- }
-
- gl::Context *context = gl::getContext();
-
- if(context)
- {
- gl::Program *programObject = context->getProgram(program);
-
- if(!programObject)
- {
- if(context->getShader(program))
- {
- return error(GL_INVALID_OPERATION);
- }
- else
- {
- return error(GL_INVALID_VALUE);
- }
- }
-
- if(index >= (GLuint)programObject->getActiveUniformCount())
- {
- return error(GL_INVALID_VALUE);
- }
-
- programObject->getActiveUniform(index, bufsize, length, size, type, name);
- }
- }
- catch(std::bad_alloc&)
- {
- return error(GL_OUT_OF_MEMORY);
- }
-}
-
-void GL_APIENTRY glGetAttachedShaders(GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders)
-{
- TRACE("(GLuint program = %d, GLsizei maxcount = %d, GLsizei* count = 0x%0.8p, GLuint* shaders = 0x%0.8p)",
- program, maxcount, count, shaders);
-
- try
- {
- if(maxcount < 0)
- {
- return error(GL_INVALID_VALUE);
- }
-
- gl::Context *context = gl::getContext();
-
- if(context)
- {
- gl::Program *programObject = context->getProgram(program);
-
- if(!programObject)
- {
- if(context->getShader(program))
- {
- return error(GL_INVALID_OPERATION);
- }
- else
- {
- return error(GL_INVALID_VALUE);
- }
- }
-
- return programObject->getAttachedShaders(maxcount, count, shaders);
- }
- }
- catch(std::bad_alloc&)
- {
- return error(GL_OUT_OF_MEMORY);
- }
-}
-
-int GL_APIENTRY glGetAttribLocation(GLuint program, const GLchar* name)
-{
- TRACE("(GLuint program = %d, const GLchar* name = %s)", program, name);
-
- try
- {
- gl::Context *context = gl::getContext();
-
- if(context)
- {
-
- gl::Program *programObject = context->getProgram(program);
-
- if(!programObject)
- {
- if(context->getShader(program))
- {
- return error(GL_INVALID_OPERATION, -1);
- }
- else
- {
- return error(GL_INVALID_VALUE, -1);
- }
- }
-
- if(!programObject->isLinked())
- {
- return error(GL_INVALID_OPERATION, -1);
- }
-
- return programObject->getAttributeLocation(name);
- }
- }
- catch(std::bad_alloc&)
- {
- return error(GL_OUT_OF_MEMORY, -1);
- }
-
- return -1;
-}
-
void GL_APIENTRY glGetBooleanv(GLenum pname, GLboolean* params)
{
TRACE("(GLenum pname = 0x%X, GLboolean* params = 0x%0.8p)", pname, params);
@@ -2629,15 +1894,19 @@
{
if(!(context->getBooleanv(pname, params)))
{
- GLenum nativeType;
- unsigned int numParams = 0;
- if(!context->getQueryParameterInfo(pname, &nativeType, &numParams))
- return error(GL_INVALID_ENUM);
+ unsigned int numParams = context->getQueryParameterNum(pname);
+
+ if(numParams < 0)
+ {
+ return error(GL_INVALID_ENUM);
+ }
- if(numParams == 0)
- return; // it is known that the pname is valid, but there are no parameters to return
+ if(numParams == 0)
+ {
+ return;
+ }
- if(nativeType == GL_FLOAT)
+ if(context->isQueryParameterFloat(pname))
{
GLfloat *floatParams = NULL;
floatParams = new GLfloat[numParams];
@@ -2654,7 +1923,7 @@
delete [] floatParams;
}
- else if(nativeType == GL_INT)
+ else if(context->isQueryParameterInt(pname))
{
GLint *intParams = NULL;
intParams = new GLint[numParams];
@@ -2727,6 +1996,16 @@
}
}
+void GL_APIENTRY glGetClipPlanef(GLenum pname, GLfloat eqn[4])
+{
+ UNIMPLEMENTED();
+}
+
+void GL_APIENTRY glGetClipPlanex(GLenum pname, GLfixed eqn[4])
+{
+ UNIMPLEMENTED();
+}
+
GLenum GL_APIENTRY glGetError(void)
{
TRACE("()");
@@ -2741,30 +2020,9 @@
return GL_NO_ERROR;
}
-void GL_APIENTRY glGetFenceivNV(GLuint fence, GLenum pname, GLint *params)
+void GL_APIENTRY glGetFixedv(GLenum pname, GLfixed *params)
{
- TRACE("(GLuint fence = %d, GLenum pname = 0x%X, GLint *params = 0x%0.8p)", fence, pname, params);
-
- try
- {
- gl::Context *context = gl::getContext();
-
- if(context)
- {
- gl::Fence *fenceObject = context->getFence(fence);
-
- if(fenceObject == NULL)
- {
- return error(GL_INVALID_OPERATION);
- }
-
- fenceObject->getFenceiv(pname, params);
- }
- }
- catch(std::bad_alloc&)
- {
- return error(GL_OUT_OF_MEMORY);
- }
+ UNIMPLEMENTED();
}
void GL_APIENTRY glGetFloatv(GLenum pname, GLfloat* params)
@@ -2779,15 +2037,19 @@
{
if(!(context->getFloatv(pname, params)))
{
- GLenum nativeType;
- unsigned int numParams = 0;
- if(!context->getQueryParameterInfo(pname, &nativeType, &numParams))
- return error(GL_INVALID_ENUM);
+ unsigned int numParams = context->getQueryParameterNum(pname);
+
+ if(numParams < 0)
+ {
+ return error(GL_INVALID_ENUM);
+ }
- if(numParams == 0)
- return; // it is known that the pname is valid, but that there are no parameters to return.
+ if(numParams == 0)
+ {
+ return;
+ }
- if(nativeType == GL_BOOL)
+ if(context->isQueryParameterBool(pname))
{
GLboolean *boolParams = NULL;
boolParams = new GLboolean[numParams];
@@ -2804,7 +2066,7 @@
delete [] boolParams;
}
- else if(nativeType == GL_INT)
+ else if(context->isQueryParameterInt(pname))
{
GLint *intParams = NULL;
intParams = new GLint[numParams];
@@ -2827,7 +2089,7 @@
}
}
-void GL_APIENTRY glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params)
+void GL_APIENTRY glGetFramebufferAttachmentParameterivOES(GLenum target, GLenum attachment, GLenum pname, GLint* params)
{
TRACE("(GLenum target = 0x%X, GLenum attachment = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)",
target, attachment, pname, params);
@@ -2838,52 +2100,40 @@
if(context)
{
- if(target != GL_FRAMEBUFFER && target != GL_DRAW_FRAMEBUFFER_ANGLE && target != GL_READ_FRAMEBUFFER_ANGLE)
+ if(target != GL_FRAMEBUFFER_OES)
{
return error(GL_INVALID_ENUM);
}
-
- gl::Framebuffer *framebuffer = NULL;
- if(target == GL_READ_FRAMEBUFFER_ANGLE)
+
+ if(context->getFramebufferHandle() == 0)
{
- if(context->getReadFramebufferHandle() == 0)
- {
- return error(GL_INVALID_OPERATION);
- }
-
- framebuffer = context->getReadFramebuffer();
- }
- else
- {
- if(context->getDrawFramebufferHandle() == 0)
- {
- return error(GL_INVALID_OPERATION);
- }
-
- framebuffer = context->getDrawFramebuffer();
+ return error(GL_INVALID_OPERATION);
}
+ gl::Framebuffer *framebuffer = context->getFramebuffer();
+
GLenum attachmentType;
GLuint attachmentHandle;
switch(attachment)
{
- case GL_COLOR_ATTACHMENT0:
+ case GL_COLOR_ATTACHMENT0_OES:
attachmentType = framebuffer->getColorbufferType();
attachmentHandle = framebuffer->getColorbufferHandle();
break;
- case GL_DEPTH_ATTACHMENT:
+ case GL_DEPTH_ATTACHMENT_OES:
attachmentType = framebuffer->getDepthbufferType();
attachmentHandle = framebuffer->getDepthbufferHandle();
break;
- case GL_STENCIL_ATTACHMENT:
+ case GL_STENCIL_ATTACHMENT_OES:
attachmentType = framebuffer->getStencilbufferType();
attachmentHandle = framebuffer->getStencilbufferHandle();
break;
- default: return error(GL_INVALID_ENUM);
+ default:
+ return error(GL_INVALID_ENUM);
}
GLenum attachmentObjectType; // Type category
- if(attachmentType == GL_NONE || attachmentType == GL_RENDERBUFFER)
+ if(attachmentType == GL_NONE_OES || attachmentType == GL_RENDERBUFFER_OES)
{
attachmentObjectType = attachmentType;
}
@@ -2895,11 +2145,11 @@
switch(pname)
{
- case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:
+ case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_OES:
*params = attachmentObjectType;
break;
- case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
- if(attachmentObjectType == GL_RENDERBUFFER || attachmentObjectType == GL_TEXTURE)
+ case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_OES:
+ if(attachmentObjectType == GL_RENDERBUFFER_OES || attachmentObjectType == GL_TEXTURE)
{
*params = attachmentHandle;
}
@@ -2908,7 +2158,7 @@
return error(GL_INVALID_ENUM);
}
break;
- case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL:
+ case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_OES:
if(attachmentObjectType == GL_TEXTURE)
{
*params = 0; // FramebufferTexture2D will not allow level to be set to anything else in GL ES 2.0
@@ -2918,24 +2168,7 @@
return error(GL_INVALID_ENUM);
}
break;
- case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE:
- if(attachmentObjectType == GL_TEXTURE)
- {
- if(gl::IsCubemapTextureTarget(attachmentType))
- {
- *params = attachmentType;
- }
- else
- {
- *params = 0;
- }
- }
- else
- {
- return error(GL_INVALID_ENUM);
- }
- break;
- default:
+ default:
return error(GL_INVALID_ENUM);
}
}
@@ -2946,13 +2179,6 @@
}
}
-GLenum GL_APIENTRY glGetGraphicsResetStatusEXT(void)
-{
- TRACE("()");
-
- return GL_NO_ERROR;
-}
-
void GL_APIENTRY glGetIntegerv(GLenum pname, GLint* params)
{
TRACE("(GLenum pname = 0x%X, GLint* params = 0x%0.8p)", pname, params);
@@ -2965,15 +2191,19 @@
{
if(!(context->getIntegerv(pname, params)))
{
- GLenum nativeType;
- unsigned int numParams = 0;
- if(!context->getQueryParameterInfo(pname, &nativeType, &numParams))
- return error(GL_INVALID_ENUM);
+ unsigned int numParams = context->getQueryParameterNum(pname);
+
+ if(numParams < 0)
+ {
+ return error(GL_INVALID_ENUM);
+ }
- if(numParams == 0)
- return; // it is known that pname is valid, but there are no parameters to return
+ if(numParams == 0)
+ {
+ return;
+ }
- if(nativeType == GL_BOOL)
+ if(context->isQueryParameterBool(pname))
{
GLboolean *boolParams = NULL;
boolParams = new GLboolean[numParams];
@@ -2990,7 +2220,7 @@
delete [] boolParams;
}
- else if(nativeType == GL_FLOAT)
+ else if(context->isQueryParameterFloat(pname))
{
GLfloat *floatParams = NULL;
floatParams = new GLfloat[numParams];
@@ -2999,7 +2229,7 @@
for(unsigned int i = 0; i < numParams; ++i)
{
- if(pname == GL_DEPTH_RANGE || pname == GL_COLOR_CLEAR_VALUE || pname == GL_DEPTH_CLEAR_VALUE || pname == GL_BLEND_COLOR)
+ if(pname == GL_DEPTH_RANGE || pname == GL_COLOR_CLEAR_VALUE || pname == GL_DEPTH_CLEAR_VALUE)
{
params[i] = (GLint)(((GLfloat)(0xFFFFFFFF) * floatParams[i] - 1.0f) / 2.0f);
}
@@ -3018,368 +2248,29 @@
}
}
-void GL_APIENTRY glGetProgramiv(GLuint program, GLenum pname, GLint* params)
+void GL_APIENTRY glGetLightfv(GLenum light, GLenum pname, GLfloat *params)
{
- TRACE("(GLuint program = %d, GLenum pname = %d, GLint* params = 0x%0.8p)", program, pname, params);
-
- try
- {
- gl::Context *context = gl::getContext();
-
- if(context)
- {
- gl::Program *programObject = context->getProgram(program);
-
- if(!programObject)
- {
- return error(GL_INVALID_VALUE);
- }
-
- switch(pname)
- {
- case GL_DELETE_STATUS:
- *params = programObject->isFlaggedForDeletion();
- return;
- case GL_LINK_STATUS:
- *params = programObject->isLinked();
- return;
- case GL_VALIDATE_STATUS:
- *params = programObject->isValidated();
- return;
- case GL_INFO_LOG_LENGTH:
- *params = programObject->getInfoLogLength();
- return;
- case GL_ATTACHED_SHADERS:
- *params = programObject->getAttachedShadersCount();
- return;
- case GL_ACTIVE_ATTRIBUTES:
- *params = programObject->getActiveAttributeCount();
- return;
- case GL_ACTIVE_ATTRIBUTE_MAX_LENGTH:
- *params = programObject->getActiveAttributeMaxLength();
- return;
- case GL_ACTIVE_UNIFORMS:
- *params = programObject->getActiveUniformCount();
- return;
- case GL_ACTIVE_UNIFORM_MAX_LENGTH:
- *params = programObject->getActiveUniformMaxLength();
- return;
- default:
- return error(GL_INVALID_ENUM);
- }
- }
- }
- catch(std::bad_alloc&)
- {
- return error(GL_OUT_OF_MEMORY);
- }
+ UNIMPLEMENTED();
}
-void GL_APIENTRY glGetProgramInfoLog(GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog)
+void GL_APIENTRY glGetLightxv(GLenum light, GLenum pname, GLfixed *params)
{
- TRACE("(GLuint program = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLchar* infolog = 0x%0.8p)",
- program, bufsize, length, infolog);
-
- try
- {
- if(bufsize < 0)
- {
- return error(GL_INVALID_VALUE);
- }
-
- gl::Context *context = gl::getContext();
-
- if(context)
- {
- gl::Program *programObject = context->getProgram(program);
-
- if(!programObject)
- {
- return error(GL_INVALID_VALUE);
- }
-
- programObject->getInfoLog(bufsize, length, infolog);
- }
- }
- catch(std::bad_alloc&)
- {
- return error(GL_OUT_OF_MEMORY);
- }
+ UNIMPLEMENTED();
}
-void GL_APIENTRY glGetQueryivEXT(GLenum target, GLenum pname, GLint *params)
+void GL_APIENTRY glGetMaterialfv(GLenum face, GLenum pname, GLfloat *params)
{
- TRACE("GLenum target = 0x%X, GLenum pname = 0x%X, GLint *params = 0x%0.8p)", target, pname, params);
-
- try
- {
- switch(pname)
- {
- case GL_CURRENT_QUERY_EXT:
- break;
- default:
- return error(GL_INVALID_ENUM);
- }
-
- gl::Context *context = gl::getContext();
-
- if(context)
- {
- params[0] = context->getActiveQuery(target);
- }
- }
- catch(std::bad_alloc&)
- {
- return error(GL_OUT_OF_MEMORY);
- }
+ UNIMPLEMENTED();
}
-void GL_APIENTRY glGetQueryObjectuivEXT(GLuint id, GLenum pname, GLuint *params)
+void GL_APIENTRY glGetMaterialxv(GLenum face, GLenum pname, GLfixed *params)
{
- TRACE("(GLuint id = %d, GLenum pname = 0x%X, GLuint *params = 0x%0.8p)", id, pname, params);
-
- try
- {
- switch(pname)
- {
- case GL_QUERY_RESULT_EXT:
- case GL_QUERY_RESULT_AVAILABLE_EXT:
- break;
- default:
- return error(GL_INVALID_ENUM);
- }
-
- gl::Context *context = gl::getContext();
-
- if(context)
- {
- gl::Query *queryObject = context->getQuery(id, false, GL_NONE);
-
- if(!queryObject)
- {
- return error(GL_INVALID_OPERATION);
- }
-
- if(context->getActiveQuery(queryObject->getType()) == id)
- {
- return error(GL_INVALID_OPERATION);
- }
-
- switch(pname)
- {
- case GL_QUERY_RESULT_EXT:
- params[0] = queryObject->getResult();
- break;
- case GL_QUERY_RESULT_AVAILABLE_EXT:
- params[0] = queryObject->isResultAvailable();
- break;
- default:
- ASSERT(false);
- }
- }
- }
- catch(std::bad_alloc&)
- {
- return error(GL_OUT_OF_MEMORY);
- }
+ UNIMPLEMENTED();
}
-void GL_APIENTRY glGetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params)
+void GL_APIENTRY glGetPointerv(GLenum pname, GLvoid **params)
{
- TRACE("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", target, pname, params);
-
- try
- {
- gl::Context *context = gl::getContext();
-
- if(context)
- {
- if(target != GL_RENDERBUFFER)
- {
- return error(GL_INVALID_ENUM);
- }
-
- if(context->getRenderbufferHandle() == 0)
- {
- return error(GL_INVALID_OPERATION);
- }
-
- gl::Renderbuffer *renderbuffer = context->getRenderbuffer(context->getRenderbufferHandle());
-
- switch(pname)
- {
- case GL_RENDERBUFFER_WIDTH: *params = renderbuffer->getWidth(); break;
- case GL_RENDERBUFFER_HEIGHT: *params = renderbuffer->getHeight(); break;
- case GL_RENDERBUFFER_INTERNAL_FORMAT: *params = renderbuffer->getFormat(); break;
- case GL_RENDERBUFFER_RED_SIZE: *params = renderbuffer->getRedSize(); break;
- case GL_RENDERBUFFER_GREEN_SIZE: *params = renderbuffer->getGreenSize(); break;
- case GL_RENDERBUFFER_BLUE_SIZE: *params = renderbuffer->getBlueSize(); break;
- case GL_RENDERBUFFER_ALPHA_SIZE: *params = renderbuffer->getAlphaSize(); break;
- case GL_RENDERBUFFER_DEPTH_SIZE: *params = renderbuffer->getDepthSize(); break;
- case GL_RENDERBUFFER_STENCIL_SIZE: *params = renderbuffer->getStencilSize(); break;
- case GL_RENDERBUFFER_SAMPLES_ANGLE: *params = renderbuffer->getSamples(); break;
- default:
- return error(GL_INVALID_ENUM);
- }
- }
- }
- catch(std::bad_alloc&)
- {
- return error(GL_OUT_OF_MEMORY);
- }
-}
-
-void GL_APIENTRY glGetShaderiv(GLuint shader, GLenum pname, GLint* params)
-{
- TRACE("(GLuint shader = %d, GLenum pname = %d, GLint* params = 0x%0.8p)", shader, pname, params);
-
- try
- {
- gl::Context *context = gl::getContext();
-
- if(context)
- {
- gl::Shader *shaderObject = context->getShader(shader);
-
- if(!shaderObject)
- {
- return error(GL_INVALID_VALUE);
- }
-
- switch(pname)
- {
- case GL_SHADER_TYPE:
- *params = shaderObject->getType();
- return;
- case GL_DELETE_STATUS:
- *params = shaderObject->isFlaggedForDeletion();
- return;
- case GL_COMPILE_STATUS:
- *params = shaderObject->isCompiled() ? GL_TRUE : GL_FALSE;
- return;
- case GL_INFO_LOG_LENGTH:
- *params = shaderObject->getInfoLogLength();
- return;
- case GL_SHADER_SOURCE_LENGTH:
- *params = shaderObject->getSourceLength();
- return;
- default:
- return error(GL_INVALID_ENUM);
- }
- }
- }
- catch(std::bad_alloc&)
- {
- return error(GL_OUT_OF_MEMORY);
- }
-}
-
-void GL_APIENTRY glGetShaderInfoLog(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog)
-{
- TRACE("(GLuint shader = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLchar* infolog = 0x%0.8p)",
- shader, bufsize, length, infolog);
-
- try
- {
- if(bufsize < 0)
- {
- return error(GL_INVALID_VALUE);
- }
-
- gl::Context *context = gl::getContext();
-
- if(context)
- {
- gl::Shader *shaderObject = context->getShader(shader);
-
- if(!shaderObject)
- {
- return error(GL_INVALID_VALUE);
- }
-
- shaderObject->getInfoLog(bufsize, length, infolog);
- }
- }
- catch(std::bad_alloc&)
- {
- return error(GL_OUT_OF_MEMORY);
- }
-}
-
-void GL_APIENTRY glGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision)
-{
- TRACE("(GLenum shadertype = 0x%X, GLenum precisiontype = 0x%X, GLint* range = 0x%0.8p, GLint* precision = 0x%0.8p)",
- shadertype, precisiontype, range, precision);
-
- try
- {
- switch(shadertype)
- {
- case GL_VERTEX_SHADER:
- case GL_FRAGMENT_SHADER:
- break;
- default:
- return error(GL_INVALID_ENUM);
- }
-
- switch(precisiontype)
- {
- case GL_LOW_FLOAT:
- case GL_MEDIUM_FLOAT:
- case GL_HIGH_FLOAT:
- // IEEE 754 single-precision
- range[0] = 127;
- range[1] = 127;
- *precision = 23;
- break;
- case GL_LOW_INT:
- case GL_MEDIUM_INT:
- case GL_HIGH_INT:
- // Single-precision floating-point numbers can accurately represent integers up to +/-16777216
- range[0] = 24;
- range[1] = 24;
- *precision = 0;
- break;
- default:
- return error(GL_INVALID_ENUM);
- }
- }
- catch(std::bad_alloc&)
- {
- return error(GL_OUT_OF_MEMORY);
- }
-}
-
-void GL_APIENTRY glGetShaderSource(GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source)
-{
- TRACE("(GLuint shader = %d, GLsizei bufsize = %d, GLsizei* length = 0x%0.8p, GLchar* source = 0x%0.8p)",
- shader, bufsize, length, source);
-
- try
- {
- if(bufsize < 0)
- {
- return error(GL_INVALID_VALUE);
- }
-
- gl::Context *context = gl::getContext();
-
- if(context)
- {
- gl::Shader *shaderObject = context->getShader(shader);
-
- if(!shaderObject)
- {
- return error(GL_INVALID_OPERATION);
- }
-
- shaderObject->getSource(bufsize, length, source);
- }
- }
- catch(std::bad_alloc&)
- {
- return error(GL_OUT_OF_MEMORY);
- }
+ UNIMPLEMENTED();
}
const GLubyte* GL_APIENTRY glGetString(GLenum name)
@@ -3397,40 +2288,39 @@
case GL_RENDERER:
return (GLubyte*)"SwiftShader";
case GL_VERSION:
- return (GLubyte*)"OpenGL ES 2.0 SwiftShader "VERSION_STRING;
- case GL_SHADING_LANGUAGE_VERSION:
- return (GLubyte*)"OpenGL ES GLSL ES 1.00 SwiftShader "VERSION_STRING;
+ return (GLubyte*)"OpenGL ES 1.1 SwiftShader "VERSION_STRING;
case GL_EXTENSIONS:
// Keep list sorted in following order:
// OES extensions
// EXT extensions
// Vendor extensions
return (GLubyte*)
+ "GL_OES_blend_equation_separate "
+ "GL_OES_blend_func_separate "
+ "GL_OES_blend_subtract "
"GL_OES_depth_texture "
- "GL_OES_depth_texture_cube_map "
"GL_OES_EGL_image_external "
"GL_OES_element_index_uint "
+ "GL_OES_framebuffer_object "
"GL_OES_packed_depth_stencil "
"GL_OES_rgb8_rgba8 "
- "GL_OES_standard_derivatives "
+ "GL_OES_stencil8 "
+ "GL_OES_stencil_wrap "
"GL_OES_texture_float "
"GL_OES_texture_float_linear "
"GL_OES_texture_half_float "
"GL_OES_texture_half_float_linear "
+ "GL_OES_texture_mirrored_repeat "
"GL_OES_texture_npot "
"GL_EXT_blend_minmax "
- "GL_EXT_occlusion_query_boolean "
"GL_EXT_read_format_bgra "
- #if (S3TC_SUPPORT)
+ #if (S3TC_SUPPORT)
"GL_EXT_texture_compression_dxt1 "
"GL_ANGLE_texture_compression_dxt3 "
"GL_ANGLE_texture_compression_dxt5 "
- #endif
+ #endif
"GL_EXT_texture_filter_anisotropic "
- "GL_EXT_texture_format_BGRA8888 "
- "GL_ANGLE_framebuffer_blit "
- "GL_ANGLE_framebuffer_multisample "
- "GL_NV_fence";
+ "GL_EXT_texture_format_BGRA8888";
default:
return error(GL_INVALID_ENUM, (GLubyte*)NULL);
}
@@ -3460,9 +2350,6 @@
case GL_TEXTURE_2D:
texture = context->getTexture2D();
break;
- case GL_TEXTURE_CUBE_MAP:
- texture = context->getTextureCubeMap();
- break;
case GL_TEXTURE_EXTERNAL_OES:
texture = context->getTextureExternal();
break;
@@ -3518,9 +2405,6 @@
case GL_TEXTURE_2D:
texture = context->getTexture2D();
break;
- case GL_TEXTURE_CUBE_MAP:
- texture = context->getTextureCubeMap();
- break;
case GL_TEXTURE_EXTERNAL_OES:
texture = context->getTextureExternal();
break;
@@ -3559,343 +2443,24 @@
}
}
-void GL_APIENTRY glGetnUniformfvEXT(GLuint program, GLint location, GLsizei bufSize, GLfloat* params)
+void GL_APIENTRY glGetTexEnvfv(GLenum env, GLenum pname, GLfloat *params)
{
- TRACE("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLfloat* params = 0x%0.8p)",
- program, location, bufSize, params);
-
- try
- {
- if(bufSize < 0)
- {
- return error(GL_INVALID_VALUE);
- }
-
- gl::Context *context = gl::getContext();
-
- if(context)
- {
- if(program == 0)
- {
- return error(GL_INVALID_VALUE);
- }
-
- gl::Program *programObject = context->getProgram(program);
-
- if(!programObject || !programObject->isLinked())
- {
- return error(GL_INVALID_OPERATION);
- }
-
- if(!programObject->getUniformfv(location, &bufSize, params))
- {
- return error(GL_INVALID_OPERATION);
- }
- }
- }
- catch(std::bad_alloc&)
- {
- return error(GL_OUT_OF_MEMORY);
- }
+ UNIMPLEMENTED();
}
-void GL_APIENTRY glGetUniformfv(GLuint program, GLint location, GLfloat* params)
+void GL_APIENTRY glGetTexEnviv(GLenum env, GLenum pname, GLint *params)
{
- TRACE("(GLuint program = %d, GLint location = %d, GLfloat* params = 0x%0.8p)", program, location, params);
-
- try
- {
- gl::Context *context = gl::getContext();
-
- if(context)
- {
- if(program == 0)
- {
- return error(GL_INVALID_VALUE);
- }
-
- gl::Program *programObject = context->getProgram(program);
-
- if(!programObject || !programObject->isLinked())
- {
- return error(GL_INVALID_OPERATION);
- }
-
- if(!programObject->getUniformfv(location, NULL, params))
- {
- return error(GL_INVALID_OPERATION);
- }
- }
- }
- catch(std::bad_alloc&)
- {
- return error(GL_OUT_OF_MEMORY);
- }
+ UNIMPLEMENTED();
}
-void GL_APIENTRY glGetnUniformivEXT(GLuint program, GLint location, GLsizei bufSize, GLint* params)
+void GL_APIENTRY glGetTexEnvxv(GLenum env, GLenum pname, GLfixed *params)
{
- TRACE("(GLuint program = %d, GLint location = %d, GLsizei bufSize = %d, GLint* params = 0x%0.8p)",
- program, location, bufSize, params);
-
- try
- {
- if(bufSize < 0)
- {
- return error(GL_INVALID_VALUE);
- }
-
- gl::Context *context = gl::getContext();
-
- if(context)
- {
- if(program == 0)
- {
- return error(GL_INVALID_VALUE);
- }
-
- gl::Program *programObject = context->getProgram(program);
-
- if(!programObject || !programObject->isLinked())
- {
- return error(GL_INVALID_OPERATION);
- }
-
- if(!programObject)
- {
- return error(GL_INVALID_OPERATION);
- }
-
- if(!programObject->getUniformiv(location, &bufSize, params))
- {
- return error(GL_INVALID_OPERATION);
- }
- }
- }
- catch(std::bad_alloc&)
- {
- return error(GL_OUT_OF_MEMORY);
- }
+ UNIMPLEMENTED();
}
-void GL_APIENTRY glGetUniformiv(GLuint program, GLint location, GLint* params)
+void GL_APIENTRY glGetTexParameterxv(GLenum target, GLenum pname, GLfixed *params)
{
- TRACE("(GLuint program = %d, GLint location = %d, GLint* params = 0x%0.8p)", program, location, params);
-
- try
- {
- gl::Context *context = gl::getContext();
-
- if(context)
- {
- if(program == 0)
- {
- return error(GL_INVALID_VALUE);
- }
-
- gl::Program *programObject = context->getProgram(program);
-
- if(!programObject || !programObject->isLinked())
- {
- return error(GL_INVALID_OPERATION);
- }
-
- if(!programObject)
- {
- return error(GL_INVALID_OPERATION);
- }
-
- if(!programObject->getUniformiv(location, NULL, params))
- {
- return error(GL_INVALID_OPERATION);
- }
- }
- }
- catch(std::bad_alloc&)
- {
- return error(GL_OUT_OF_MEMORY);
- }
-}
-
-int GL_APIENTRY glGetUniformLocation(GLuint program, const GLchar* name)
-{
- TRACE("(GLuint program = %d, const GLchar* name = 0x%0.8p)", program, name);
-
- try
- {
- gl::Context *context = gl::getContext();
-
- if(strstr(name, "gl_") == name)
- {
- return -1;
- }
-
- if(context)
- {
- gl::Program *programObject = context->getProgram(program);
-
- if(!programObject)
- {
- if(context->getShader(program))
- {
- return error(GL_INVALID_OPERATION, -1);
- }
- else
- {
- return error(GL_INVALID_VALUE, -1);
- }
- }
-
- if(!programObject->isLinked())
- {
- return error(GL_INVALID_OPERATION, -1);
- }
-
- return programObject->getUniformLocation(name);
- }
- }
- catch(std::bad_alloc&)
- {
- return error(GL_OUT_OF_MEMORY, -1);
- }
-
- return -1;
-}
-
-void GL_APIENTRY glGetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params)
-{
- TRACE("(GLuint index = %d, GLenum pname = 0x%X, GLfloat* params = 0x%0.8p)", index, pname, params);
-
- try
- {
- gl::Context *context = gl::getContext();
-
- if(context)
- {
- if(index >= gl::MAX_VERTEX_ATTRIBS)
- {
- return error(GL_INVALID_VALUE);
- }
-
- const gl::VertexAttribute &attribState = context->getVertexAttribState(index);
-
- switch(pname)
- {
- case GL_VERTEX_ATTRIB_ARRAY_ENABLED:
- *params = (GLfloat)(attribState.mArrayEnabled ? GL_TRUE : GL_FALSE);
- break;
- case GL_VERTEX_ATTRIB_ARRAY_SIZE:
- *params = (GLfloat)attribState.mSize;
- break;
- case GL_VERTEX_ATTRIB_ARRAY_STRIDE:
- *params = (GLfloat)attribState.mStride;
- break;
- case GL_VERTEX_ATTRIB_ARRAY_TYPE:
- *params = (GLfloat)attribState.mType;
- break;
- case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED:
- *params = (GLfloat)(attribState.mNormalized ? GL_TRUE : GL_FALSE);
- break;
- case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING:
- *params = (GLfloat)attribState.mBoundBuffer.id();
- break;
- case GL_CURRENT_VERTEX_ATTRIB:
- for(int i = 0; i < 4; ++i)
- {
- params[i] = attribState.mCurrentValue[i];
- }
- break;
- default: return error(GL_INVALID_ENUM);
- }
- }
- }
- catch(std::bad_alloc&)
- {
- return error(GL_OUT_OF_MEMORY);
- }
-}
-
-void GL_APIENTRY glGetVertexAttribiv(GLuint index, GLenum pname, GLint* params)
-{
- TRACE("(GLuint index = %d, GLenum pname = 0x%X, GLint* params = 0x%0.8p)", index, pname, params);
-
- try
- {
- gl::Context *context = gl::getContext();
-
- if(context)
- {
- if(index >= gl::MAX_VERTEX_ATTRIBS)
- {
- return error(GL_INVALID_VALUE);
- }
-
- const gl::VertexAttribute &attribState = context->getVertexAttribState(index);
-
- switch(pname)
- {
- case GL_VERTEX_ATTRIB_ARRAY_ENABLED:
- *params = (attribState.mArrayEnabled ? GL_TRUE : GL_FALSE);
- break;
- case GL_VERTEX_ATTRIB_ARRAY_SIZE:
- *params = attribState.mSize;
- break;
- case GL_VERTEX_ATTRIB_ARRAY_STRIDE:
- *params = attribState.mStride;
- break;
- case GL_VERTEX_ATTRIB_ARRAY_TYPE:
- *params = attribState.mType;
- break;
- case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED:
- *params = (attribState.mNormalized ? GL_TRUE : GL_FALSE);
- break;
- case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING:
- *params = attribState.mBoundBuffer.id();
- break;
- case GL_CURRENT_VERTEX_ATTRIB:
- for(int i = 0; i < 4; ++i)
- {
- float currentValue = attribState.mCurrentValue[i];
- params[i] = (GLint)(currentValue > 0.0f ? floor(currentValue + 0.5f) : ceil(currentValue - 0.5f));
- }
- break;
- default: return error(GL_INVALID_ENUM);
- }
- }
- }
- catch(std::bad_alloc&)
- {
- return error(GL_OUT_OF_MEMORY);
- }
-}
-
-void GL_APIENTRY glGetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid** pointer)
-{
- TRACE("(GLuint index = %d, GLenum pname = 0x%X, GLvoid** pointer = 0x%0.8p)", index, pname, pointer);
-
- try
- {
- gl::Context *context = gl::getContext();
-
- if(context)
- {
- if(index >= gl::MAX_VERTEX_ATTRIBS)
- {
- return error(GL_INVALID_VALUE);
- }
-
- if(pname != GL_VERTEX_ATTRIB_ARRAY_POINTER)
- {
- return error(GL_INVALID_ENUM);
- }
-
- *pointer = const_cast<GLvoid*>(context->getVertexAttribPointer(index));
- }
- }
- catch(std::bad_alloc&)
- {
- return error(GL_OUT_OF_MEMORY);
- }
+ UNIMPLEMENTED();
}
void GL_APIENTRY glHint(GLenum target, GLenum mode)
@@ -3920,9 +2485,6 @@
case GL_GENERATE_MIPMAP_HINT:
if(context) context->setGenerateMipmapHint(mode);
break;
- case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES:
- if(context) context->setFragmentShaderDerivativeHint(mode);
- break;
default:
return error(GL_INVALID_ENUM);
}
@@ -3993,35 +2555,7 @@
return false;
}
-GLboolean GL_APIENTRY glIsFenceNV(GLuint fence)
-{
- TRACE("(GLuint fence = %d)", fence);
-
- try
- {
- gl::Context *context = gl::getContext();
-
- if(context)
- {
- gl::Fence *fenceObject = context->getFence(fence);
-
- if(fenceObject == NULL)
- {
- return GL_FALSE;
- }
-
- return fenceObject->isFence();
- }
- }
- catch(std::bad_alloc&)
- {
- return error(GL_OUT_OF_MEMORY, GL_FALSE);
- }
-
- return GL_FALSE;
-}
-
-GLboolean GL_APIENTRY glIsFramebuffer(GLuint framebuffer)
+GLboolean GL_APIENTRY glIsFramebufferOES(GLuint framebuffer)
{
TRACE("(GLuint framebuffer = %d)", framebuffer);
@@ -4047,115 +2581,6 @@
return GL_FALSE;
}
-GLboolean GL_APIENTRY glIsProgram(GLuint program)
-{
- TRACE("(GLuint program = %d)", program);
-
- try
- {
- gl::Context *context = gl::getContext();
-
- if(context && program)
- {
- gl::Program *programObject = context->getProgram(program);
-
- if(programObject)
- {
- return GL_TRUE;
- }
- }
- }
- catch(std::bad_alloc&)
- {
- return error(GL_OUT_OF_MEMORY, GL_FALSE);
- }
-
- return GL_FALSE;
-}
-
-GLboolean GL_APIENTRY glIsQueryEXT(GLuint id)
-{
- TRACE("(GLuint id = %d)", id);
-
- try
- {
- if(id == 0)
- {
- return GL_FALSE;
- }
-
- gl::Context *context = gl::getContext();
-
- if(context)
- {
- gl::Query *queryObject = context->getQuery(id, false, GL_NONE);
-
- if(queryObject)
- {
- return GL_TRUE;
- }
- }
- }
- catch(std::bad_alloc&)
- {
- return error(GL_OUT_OF_MEMORY, GL_FALSE);
- }
-
- return GL_FALSE;
-}
-
-GLboolean GL_APIENTRY glIsRenderbuffer(GLuint renderbuffer)
-{
- TRACE("(GLuint renderbuffer = %d)", renderbuffer);
-
- try
- {
- gl::Context *context = gl::getContext();
-
- if(context && renderbuffer)
- {
- gl::Renderbuffer *renderbufferObject = context->getRenderbuffer(renderbuffer);
-
- if(renderbufferObject)
- {
- return GL_TRUE;
- }
- }
- }
- catch(std::bad_alloc&)
- {
- return error(GL_OUT_OF_MEMORY, GL_FALSE);
- }
-
- return GL_FALSE;
-}
-
-GLboolean GL_APIENTRY glIsShader(GLuint shader)
-{
- TRACE("(GLuint shader = %d)", shader);
-
- try
- {
- gl::Context *context = gl::getContext();
-
- if(context && shader)
- {
- gl::Shader *shaderObject = context->getShader(shader);
-
- if(shaderObject)
- {
- return GL_TRUE;
- }
- }
- }
- catch(std::bad_alloc&)
- {
- return error(GL_OUT_OF_MEMORY, GL_FALSE);
- }
-
- return GL_FALSE;
-}
-
GLboolean GL_APIENTRY glIsTexture(GLuint texture)
{
TRACE("(GLuint texture = %d)", texture);
@@ -4182,6 +2607,72 @@
return GL_FALSE;
}
+GLboolean GL_APIENTRY glIsRenderbufferOES(GLuint renderbuffer)
+{
+ TRACE("(GLuint renderbuffer = %d)", renderbuffer);
+
+ try
+ {
+ gl::Context *context = gl::getContext();
+
+ if(context && renderbuffer)
+ {
+ gl::Renderbuffer *renderbufferObject = context->getRenderbuffer(renderbuffer);
+
+ if(renderbufferObject)
+ {
+ return GL_TRUE;
+ }
+ }
+ }
+ catch(std::bad_alloc&)
+ {
+ return error(GL_OUT_OF_MEMORY, GL_FALSE);
+ }
+
+ return GL_FALSE;
+}
+
+void GL_APIENTRY glLightModelf(GLenum pname, GLfloat param)
+{
+ UNIMPLEMENTED();
+}
+
+void GL_APIENTRY glLightModelfv(GLenum pname, const GLfloat *params)
+{
+ UNIMPLEMENTED();
+}
+
+void GL_APIENTRY glLightModelx(GLenum pname, GLfixed param)
+{
+ UNIMPLEMENTED();
+}
+
+void GL_APIENTRY glLightModelxv(GLenum pname, const GLfixed *params)
+{
+ UNIMPLEMENTED();
+}
+
+void GL_APIENTRY glLightf(GLenum light, GLenum pname, GLfloat param)
+{
+ UNIMPLEMENTED();
+}
+
+void GL_APIENTRY glLightfv(GLenum light, GLenum pname, const GLfloat *params)
+{
+ UNIMPLEMENTED();
+}
+
+void GL_APIENTRY glLightx(GLenum light, GLenum pname, GLfixed param)
+{
+ UNIMPLEMENTED();
+}
+
+void GL_APIENTRY glLightxv(GLenum light, GLenum pname, const GLfixed *params)
+{
+ UNIMPLEMENTED();
+}
+
void GL_APIENTRY glLineWidth(GLfloat width)
{
TRACE("(GLfloat width = %f)", width);
@@ -4206,37 +2697,99 @@
}
}
-void GL_APIENTRY glLinkProgram(GLuint program)
+void GL_APIENTRY glLineWidthx(GLfixed width)
{
- TRACE("(GLuint program = %d)", program);
+ UNIMPLEMENTED();
+}
- try
- {
- gl::Context *context = gl::getContext();
+void GL_APIENTRY glLoadIdentity(void)
+{
+ UNIMPLEMENTED();
+}
- if(context)
- {
- gl::Program *programObject = context->getProgram(program);
+void GL_APIENTRY glLoadMatrixf(const GLfloat *m)
+{
+ UNIMPLEMENTED();
+}
- if(!programObject)
- {
- if(context->getShader(program))
- {
- return error(GL_INVALID_OPERATION);
- }
- else
- {
- return error(GL_INVALID_VALUE);
- }
- }
+void GL_APIENTRY glLoadMatrixx(const GLfixed *m)
+{
+ UNIMPLEMENTED();
+}
- programObject->link();
- }
- }
- catch(std::bad_alloc&)
- {
- return error(GL_OUT_OF_MEMORY);
- }
+void GL_APIENTRY glLogicOp(GLenum opcode)
+{
+ UNIMPLEMENTED();
+}
+
+void GL_APIENTRY glMaterialf(GLenum face, GLenum pname, GLfloat param)
+{
+ UNIMPLEMENTED();
+}
+
+void GL_APIENTRY glMaterialfv(GLenum face, GLenum pname, const GLfloat *params)
+{
+ UNIMPLEMENTED();
+}
+
+void GL_APIENTRY glMaterialx(GLenum face, GLenum pname, GLfixed param)
+{
+ UNIMPLEMENTED();
+}
+
+void GL_APIENTRY glMaterialxv(GLenum face, GLenum pname, const GLfixed *params)
+{
+ UNIMPLEMENTED();
+}
+
+void GL_APIENTRY glMatrixMode(GLenum mode)
+{
+ UNIMPLEMENTED();
+}
+
+void GL_APIENTRY glMultMatrixf(const GLfloat *m)
+{
+ UNIMPLEMENTED();
+}
+
+void GL_APIENTRY glMultMatrixx(const GLfixed *m)
+{
+ UNIMPLEMENTED();
+}
+
+void GL_APIENTRY glMultiTexCoord4f(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q)
+{
+ UNIMPLEMENTED();
+}
+
+void GL_APIENTRY glMultiTexCoord4x(GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q)
+{
+ UNIMPLEMENTED();
+}
+
+void GL_APIENTRY glNormal3f(GLfloat nx, GLfloat ny, GLfloat nz)
+{
+ UNIMPLEMENTED();
+}
+
+void GL_APIENTRY glNormal3x(GLfixed nx, GLfixed ny, GLfixed nz)
+{
+ UNIMPLEMENTED();
+}
+
+void GL_APIENTRY glNormalPointer(GLenum type, GLsizei stride, const GLvoid *pointer)
+{
+ UNIMPLEMENTED();
+}
+
+void GL_APIENTRY glOrthof(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat zNear, GLfloat zFar)
+{
+ UNIMPLEMENTED();
+}
+
+void GL_APIENTRY glOrthox(GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, GLfixed zNear, GLfixed zFar)
+{
+ UNIMPLEMENTED();
}
void GL_APIENTRY glPixelStorei(GLenum pname, GLint param)
@@ -4280,6 +2833,36 @@
}
}
+void GL_APIENTRY glPointParameterf(GLenum pname, GLfloat param)
+{
+ UNIMPLEMENTED();
+}
+
+void GL_APIENTRY glPointParameterfv(GLenum pname, const GLfloat *params)
+{
+ UNIMPLEMENTED();
+}
+
+void GL_APIENTRY glPointParameterx(GLenum pname, GLfixed param)
+{
+ UNIMPLEMENTED();
+}
+
+void GL_APIENTRY glPointParameterxv(GLenum pname, const GLfixed *params)
+{
+ UNIMPLEMENTED();
+}
+
+void GL_APIENTRY glPointSize(GLfloat size)
+{
+ UNIMPLEMENTED();
+}
+
+void GL_APIENTRY glPointSizex(GLfixed size)
+{
+ UNIMPLEMENTED();
+}
+
void GL_APIENTRY glPolygonOffset(GLfloat factor, GLfloat units)
{
TRACE("(GLfloat factor = %f, GLfloat units = %f)", factor, units);
@@ -4299,37 +2882,19 @@
}
}
-void GL_APIENTRY glReadnPixelsEXT(GLint x, GLint y, GLsizei width, GLsizei height,
- GLenum format, GLenum type, GLsizei bufSize,
- GLvoid *data)
+void GL_APIENTRY glPolygonOffsetx(GLfixed factor, GLfixed units)
{
- TRACE("(GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d, "
- "GLenum format = 0x%X, GLenum type = 0x%X, GLsizei bufSize = 0x%d, GLvoid *data = 0x%0.8p)",
- x, y, width, height, format, type, bufSize, data);
+ UNIMPLEMENTED();
+}
- try
- {
- if(width < 0 || height < 0 || bufSize < 0)
- {
- return error(GL_INVALID_VALUE);
- }
+void GL_APIENTRY glPopMatrix(void)
+{
+ UNIMPLEMENTED();
+}
- if(!validReadFormatType(format, type))
- {
- return error(GL_INVALID_OPERATION);
- }
-
- gl::Context *context = gl::getContext();
-
- if(context)
- {
- context->readPixels(x, y, width, height, format, type, &bufSize, data);
- }
- }
- catch(std::bad_alloc&)
- {
- return error(GL_OUT_OF_MEMORY);
- }
+void GL_APIENTRY glPushMatrix(void)
+{
+ UNIMPLEMENTED();
}
void GL_APIENTRY glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels)
@@ -4363,32 +2928,18 @@
}
}
-void GL_APIENTRY glReleaseShaderCompiler(void)
+void GL_APIENTRY glRenderbufferStorageOES(GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
{
- TRACE("()");
-
- try
- {
- gl::Shader::releaseCompiler();
- }
- catch(std::bad_alloc&)
- {
- return error(GL_OUT_OF_MEMORY);
- }
-}
-
-void GL_APIENTRY glRenderbufferStorageMultisampleANGLE(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
-{
- TRACE("(GLenum target = 0x%X, GLsizei samples = %d, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)",
- target, samples, internalformat, width, height);
+ TRACE("(GLenum target = 0x%X, GLenum internalformat = 0x%X, GLsizei width = %d, GLsizei height = %d)",
+ target, internalformat, width, height);
try
{
switch(target)
{
- case GL_RENDERBUFFER:
+ case GL_RENDERBUFFER_OES:
break;
- default:
+ default:
return error(GL_INVALID_ENUM);
}
@@ -4397,7 +2948,7 @@
return error(GL_INVALID_ENUM);
}
- if(width < 0 || height < 0 || samples < 0)
+ if(width < 0 || height < 0)
{
return error(GL_INVALID_VALUE);
}
@@ -4407,8 +2958,7 @@
if(context)
{
if(width > gl::IMPLEMENTATION_MAX_RENDERBUFFER_SIZE ||
- height > gl::IMPLEMENTATION_MAX_RENDERBUFFER_SIZE ||
- samples > gl::IMPLEMENTATION_MAX_SAMPLES)
+ height > gl::IMPLEMENTATION_MAX_RENDERBUFFER_SIZE)
{
return error(GL_INVALID_VALUE);
}
@@ -4421,23 +2971,23 @@
switch(internalformat)
{
- case GL_DEPTH_COMPONENT16:
- context->setRenderbufferStorage(new gl::Depthbuffer(width, height, samples));
+ case GL_DEPTH_COMPONENT16_OES:
+ context->setRenderbufferStorage(new gl::Depthbuffer(width, height, 0));
break;
- case GL_RGBA4:
- case GL_RGB5_A1:
- case GL_RGB565:
- case GL_RGB8_OES:
- case GL_RGBA8_OES:
- context->setRenderbufferStorage(new gl::Colorbuffer(width, height, internalformat, samples));
+ case GL_RGBA4_OES:
+ case GL_RGB5_A1_OES:
+ case GL_RGB565_OES:
+ case GL_RGB8_OES:
+ case GL_RGBA8_OES:
+ context->setRenderbufferStorage(new gl::Colorbuffer(width, height, internalformat, 0));
break;
- case GL_STENCIL_INDEX8:
- context->setRenderbufferStorage(new gl::Stencilbuffer(width, height, samples));
+ case GL_STENCIL_INDEX8_OES:
+ context->setRenderbufferStorage(new gl::Stencilbuffer(width, height, 0));
break;
- case GL_DEPTH24_STENCIL8_OES:
- context->setRenderbufferStorage(new gl::DepthStencilbuffer(width, height, samples));
+ case GL_DEPTH24_STENCIL8_OES:
+ context->setRenderbufferStorage(new gl::DepthStencilbuffer(width, height, 0));
break;
- default:
+ default:
return error(GL_INVALID_ENUM);
}
}
@@ -4448,9 +2998,14 @@
}
}
-void GL_APIENTRY glRenderbufferStorage(GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
+void GL_APIENTRY glRotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z)
{
- glRenderbufferStorageMultisampleANGLE(target, 0, internalformat, width, height);
+ UNIMPLEMENTED();
+}
+
+void GL_APIENTRY glRotatex(GLfixed angle, GLfixed x, GLfixed y, GLfixed z)
+{
+ UNIMPLEMENTED();
}
void GL_APIENTRY glSampleCoverage(GLclampf value, GLboolean invert)
@@ -4472,35 +3027,19 @@
}
}
-void GL_APIENTRY glSetFenceNV(GLuint fence, GLenum condition)
+void GL_APIENTRY glSampleCoveragex(GLclampx value, GLboolean invert)
{
- TRACE("(GLuint fence = %d, GLenum condition = 0x%X)", fence, condition);
+ UNIMPLEMENTED();
+}
- try
- {
- if(condition != GL_ALL_COMPLETED_NV)
- {
- return error(GL_INVALID_ENUM);
- }
+void GL_APIENTRY glScalef(GLfloat x, GLfloat y, GLfloat z)
+{
+ UNIMPLEMENTED();
+}
- gl::Context *context = gl::getContext();
-
- if(context)
- {
- gl::Fence *fenceObject = context->getFence(fence);
-
- if(fenceObject == NULL)
- {
- return error(GL_INVALID_OPERATION);
- }
-
- fenceObject->setFence(condition);
- }
- }
- catch(std::bad_alloc&)
- {
- return error(GL_OUT_OF_MEMORY);
- }
+void GL_APIENTRY glScalex(GLfixed x, GLfixed y, GLfixed z)
+{
+ UNIMPLEMENTED();
}
void GL_APIENTRY glScissor(GLint x, GLint y, GLsizei width, GLsizei height)
@@ -4527,83 +3066,17 @@
}
}
-void GL_APIENTRY glShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length)
+void GL_APIENTRY glShadeModel(GLenum mode)
{
- TRACE("(GLsizei n = %d, const GLuint* shaders = 0x%0.8p, GLenum binaryformat = 0x%X, "
- "const GLvoid* binary = 0x%0.8p, GLsizei length = %d)",
- n, shaders, binaryformat, binary, length);
-
- try
- {
- // No binary shader formats are supported.
- return error(GL_INVALID_ENUM);
- }
- catch(std::bad_alloc&)
- {
- return error(GL_OUT_OF_MEMORY);
- }
-}
-
-void GL_APIENTRY glShaderSource(GLuint shader, GLsizei count, const GLchar** string, const GLint* length)
-{
- TRACE("(GLuint shader = %d, GLsizei count = %d, const GLchar** string = 0x%0.8p, const GLint* length = 0x%0.8p)",
- shader, count, string, length);
-
- try
- {
- if(count < 0)
- {
- return error(GL_INVALID_VALUE);
- }
-
- gl::Context *context = gl::getContext();
-
- if(context)
- {
- gl::Shader *shaderObject = context->getShader(shader);
-
- if(!shaderObject)
- {
- if(context->getProgram(shader))
- {
- return error(GL_INVALID_OPERATION);
- }
- else
- {
- return error(GL_INVALID_VALUE);
- }
- }
-
- shaderObject->setSource(count, string, length);
- }
- }
- catch(std::bad_alloc&)
- {
- return error(GL_OUT_OF_MEMORY);
- }
+ UNIMPLEMENTED();
}
void GL_APIENTRY glStencilFunc(GLenum func, GLint ref, GLuint mask)
{
- glStencilFuncSeparate(GL_FRONT_AND_BACK, func, ref, mask);
-}
-
-void GL_APIENTRY glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
-{
- TRACE("(GLenum face = 0x%X, GLenum func = 0x%X, GLint ref = %d, GLuint mask = %d)", face, func, ref, mask);
+ TRACE("(GLenum func = 0x%X, GLint ref = %d, GLuint mask = %d)", func, ref, mask);
try
{
- switch(face)
- {
- case GL_FRONT:
- case GL_BACK:
- case GL_FRONT_AND_BACK:
- break;
- default:
- return error(GL_INVALID_ENUM);
- }
-
switch(func)
{
case GL_NEVER:
@@ -4623,15 +3096,7 @@
if(context)
{
- if(face == GL_FRONT || face == GL_FRONT_AND_BACK)
- {
- context->setStencilParams(func, ref, mask);
- }
-
- if(face == GL_BACK || face == GL_FRONT_AND_BACK)
- {
- context->setStencilBackParams(func, ref, mask);
- }
+ context->setStencilParams(func, ref, mask);
}
}
catch(std::bad_alloc&)
@@ -4642,38 +3107,15 @@
void GL_APIENTRY glStencilMask(GLuint mask)
{
- glStencilMaskSeparate(GL_FRONT_AND_BACK, mask);
-}
-
-void GL_APIENTRY glStencilMaskSeparate(GLenum face, GLuint mask)
-{
- TRACE("(GLenum face = 0x%X, GLuint mask = %d)", face, mask);
+ TRACE("(GLuint mask = %d)", mask);
try
{
- switch(face)
- {
- case GL_FRONT:
- case GL_BACK:
- case GL_FRONT_AND_BACK:
- break;
- default:
- return error(GL_INVALID_ENUM);
- }
-
gl::Context *context = gl::getContext();
if(context)
{
- if(face == GL_FRONT || face == GL_FRONT_AND_BACK)
- {
- context->setStencilWritemask(mask);
- }
-
- if(face == GL_BACK || face == GL_FRONT_AND_BACK)
- {
- context->setStencilBackWritemask(mask);
- }
+ context->setStencilWritemask(mask);
}
}
catch(std::bad_alloc&)
@@ -4684,26 +3126,10 @@
void GL_APIENTRY glStencilOp(GLenum fail, GLenum zfail, GLenum zpass)
{
- glStencilOpSeparate(GL_FRONT_AND_BACK, fail, zfail, zpass);
-}
-
-void GL_APIENTRY glStencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
-{
- TRACE("(GLenum face = 0x%X, GLenum fail = 0x%X, GLenum zfail = 0x%X, GLenum zpas = 0x%Xs)",
- face, fail, zfail, zpass);
+ TRACE("(GLenum fail = 0x%X, GLenum zfail = 0x%X, GLenum zpas = 0x%Xs)", fail, zfail, zpass);
try
{
- switch(face)
- {
- case GL_FRONT:
- case GL_BACK:
- case GL_FRONT_AND_BACK:
- break;
- default:
- return error(GL_INVALID_ENUM);
- }
-
switch(fail)
{
case GL_ZERO:
@@ -4712,8 +3138,8 @@
case GL_INCR:
case GL_DECR:
case GL_INVERT:
- case GL_INCR_WRAP:
- case GL_DECR_WRAP:
+ case GL_INCR_WRAP_OES:
+ case GL_DECR_WRAP_OES:
break;
default:
return error(GL_INVALID_ENUM);
@@ -4727,8 +3153,8 @@
case GL_INCR:
case GL_DECR:
case GL_INVERT:
- case GL_INCR_WRAP:
- case GL_DECR_WRAP:
+ case GL_INCR_WRAP_OES:
+ case GL_DECR_WRAP_OES:
break;
default:
return error(GL_INVALID_ENUM);
@@ -4742,8 +3168,8 @@
case GL_INCR:
case GL_DECR:
case GL_INVERT:
- case GL_INCR_WRAP:
- case GL_DECR_WRAP:
+ case GL_INCR_WRAP_OES:
+ case GL_DECR_WRAP_OES:
break;
default:
return error(GL_INVALID_ENUM);
@@ -4753,15 +3179,7 @@
if(context)
{
- if(face == GL_FRONT || face == GL_FRONT_AND_BACK)
- {
- context->setStencilOperations(fail, zfail, zpass);
- }
-
- if(face == GL_BACK || face == GL_FRONT_AND_BACK)
- {
- context->setStencilBackOperations(fail, zfail, zpass);
- }
+ context->setStencilOperations(fail, zfail, zpass);
}
}
catch(std::bad_alloc&)
@@ -4770,32 +3188,39 @@
}
}
-GLboolean GL_APIENTRY glTestFenceNV(GLuint fence)
+void GL_APIENTRY glTexCoordPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer)
{
- TRACE("(GLuint fence = %d)", fence);
+ UNIMPLEMENTED();
+}
- try
- {
- gl::Context *context = gl::getContext();
+void GL_APIENTRY glTexEnvf(GLenum target, GLenum pname, GLfloat param)
+{
+ UNIMPLEMENTED();
+}
- if(context)
- {
- gl::Fence *fenceObject = context->getFence(fence);
+void GL_APIENTRY glTexEnvfv(GLenum target, GLenum pname, const GLfloat *params)
+{
+ UNIMPLEMENTED();
+}
- if(fenceObject == NULL)
- {
- return error(GL_INVALID_OPERATION, GL_TRUE);
- }
+void GL_APIENTRY glTexEnvi(GLenum target, GLenum pname, GLint param)
+{
+ UNIMPLEMENTED();
+}
- return fenceObject->testFence();
- }
- }
- catch(std::bad_alloc&)
- {
- error(GL_OUT_OF_MEMORY);
- }
-
- return GL_TRUE;
+void GL_APIENTRY glTexEnvx(GLenum target, GLenum pname, GLfixed param)
+{
+ UNIMPLEMENTED();
+}
+
+void GL_APIENTRY glTexEnviv(GLenum target, GLenum pname, const GLint *params)
+{
+ UNIMPLEMENTED();
+}
+
+void GL_APIENTRY glTexEnvxv(GLenum target, GLenum pname, const GLfixed *params)
+{
+ UNIMPLEMENTED();
}
void GL_APIENTRY glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height,
@@ -4826,7 +3251,6 @@
{
case GL_UNSIGNED_BYTE:
case GL_FLOAT:
- case GL_HALF_FLOAT_OES:
break;
default:
return error(GL_INVALID_ENUM);
@@ -4838,7 +3262,6 @@
case GL_UNSIGNED_BYTE:
case GL_UNSIGNED_SHORT_5_6_5:
case GL_FLOAT:
- case GL_HALF_FLOAT_OES:
break;
default:
return error(GL_INVALID_ENUM);
@@ -4851,7 +3274,6 @@
case GL_UNSIGNED_SHORT_4_4_4_4:
case GL_UNSIGNED_SHORT_5_5_5_1:
case GL_FLOAT:
- case GL_HALF_FLOAT_OES:
break;
default:
return error(GL_INVALID_ENUM);
@@ -4868,19 +3290,7 @@
break;
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: // error cases for compressed textures are handled below
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
- case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
- case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
break;
- case GL_DEPTH_COMPONENT:
- switch(type)
- {
- case GL_UNSIGNED_SHORT:
- case GL_UNSIGNED_INT:
- break;
- default:
- return error(GL_INVALID_ENUM);
- }
- break;
case GL_DEPTH_STENCIL_OES:
switch(type)
{
@@ -4912,31 +3322,12 @@
return error(GL_INVALID_VALUE);
}
break;
- case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
- case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
- case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
- if(width != height)
- {
- return error(GL_INVALID_VALUE);
- }
-
- if(width > (gl::IMPLEMENTATION_MAX_CUBE_MAP_TEXTURE_SIZE >> level) ||
- height > (gl::IMPLEMENTATION_MAX_CUBE_MAP_TEXTURE_SIZE >> level))
- {
- return error(GL_INVALID_VALUE);
- }
- break;
default:
return error(GL_INVALID_ENUM);
}
if(format == GL_COMPRESSED_RGB_S3TC_DXT1_EXT ||
- format == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT ||
- format == GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE ||
- format == GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE)
+ format == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT)
{
if(S3TC_SUPPORT)
{
@@ -4959,17 +3350,7 @@
texture->setImage(level, width, height, format, type, context->getUnpackAlignment(), pixels);
}
- else
- {
- gl::TextureCubeMap *texture = context->getTextureCubeMap();
-
- if(!texture)
- {
- return error(GL_INVALID_OPERATION);
- }
-
- texture->setImage(target, level, width, height, format, type, context->getUnpackAlignment(), pixels);
- }
+ else UNREACHABLE();
}
}
catch(std::bad_alloc&)
@@ -4995,9 +3376,6 @@
case GL_TEXTURE_2D:
texture = context->getTexture2D();
break;
- case GL_TEXTURE_CUBE_MAP:
- texture = context->getTextureCubeMap();
- break;
case GL_TEXTURE_EXTERNAL_OES:
texture = context->getTextureExternal();
break;
@@ -5070,9 +3448,6 @@
case GL_TEXTURE_2D:
texture = context->getTexture2D();
break;
- case GL_TEXTURE_CUBE_MAP:
- texture = context->getTextureCubeMap();
- break;
case GL_TEXTURE_EXTERNAL_OES:
texture = context->getTextureExternal();
break;
@@ -5128,6 +3503,16 @@
glTexParameteri(target, pname, *params);
}
+void GL_APIENTRY glTexParameterx(GLenum target, GLenum pname, GLfixed param)
+{
+ UNIMPLEMENTED();
+}
+
+void GL_APIENTRY glTexParameterxv(GLenum target, GLenum pname, const GLfixed *params)
+{
+ UNIMPLEMENTED();
+}
+
void GL_APIENTRY glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
GLenum format, GLenum type, const GLvoid* pixels)
{
@@ -5181,19 +3566,7 @@
texture->subImage(level, xoffset, yoffset, width, height, format, type, context->getUnpackAlignment(), pixels);
}
}
- else if(gl::IsCubemapTextureTarget(target))
- {
- gl::TextureCubeMap *texture = context->getTextureCubeMap();
-
- if(validateSubImageParams(false, width, height, xoffset, yoffset, target, level, format, texture))
- {
- texture->subImage(target, level, xoffset, yoffset, width, height, format, type, context->getUnpackAlignment(), pixels);
- }
- }
- else
- {
- UNREACHABLE();
- }
+ else UNREACHABLE();
}
}
catch(std::bad_alloc&)
@@ -5202,807 +3575,19 @@
}
}
-void GL_APIENTRY glUniform1f(GLint location, GLfloat x)
+void GL_APIENTRY glTranslatef(GLfloat x, GLfloat y, GLfloat z)
{
- glUniform1fv(location, 1, &x);
+ UNIMPLEMENTED();
}
-void GL_APIENTRY glUniform1fv(GLint location, GLsizei count, const GLfloat* v)
+void GL_APIENTRY glTranslatex(GLfixed x, GLfixed y, GLfixed z)
{
- TRACE("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
-
- try
- {
- if(count < 0)
- {
- return error(GL_INVALID_VALUE);
- }
-
- if(location == -1)
- {
- return;
- }
-
- gl::Context *context = gl::getContext();
-
- if(context)
- {
- gl::Program *program = context->getCurrentProgram();
-
- if(!program)
- {
- return error(GL_INVALID_OPERATION);
- }
-
- if(!program->setUniform1fv(location, count, v))
- {
- return error(GL_INVALID_OPERATION);
- }
- }
- }
- catch(std::bad_alloc&)
- {
- return error(GL_OUT_OF_MEMORY);
- }
+ UNIMPLEMENTED();
}
-void GL_APIENTRY glUniform1i(GLint location, GLint x)
+void GL_APIENTRY glVertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer)
{
- glUniform1iv(location, 1, &x);
-}
-
-void GL_APIENTRY glUniform1iv(GLint location, GLsizei count, const GLint* v)
-{
- TRACE("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
-
- try
- {
- if(count < 0)
- {
- return error(GL_INVALID_VALUE);
- }
-
- if(location == -1)
- {
- return;
- }
-
- gl::Context *context = gl::getContext();
-
- if(context)
- {
- gl::Program *program = context->getCurrentProgram();
-
- if(!program)
- {
- return error(GL_INVALID_OPERATION);
- }
-
- if(!program->setUniform1iv(location, count, v))
- {
- return error(GL_INVALID_OPERATION);
- }
- }
- }
- catch(std::bad_alloc&)
- {
- return error(GL_OUT_OF_MEMORY);
- }
-}
-
-void GL_APIENTRY glUniform2f(GLint location, GLfloat x, GLfloat y)
-{
- GLfloat xy[2] = {x, y};
-
- glUniform2fv(location, 1, (GLfloat*)&xy);
-}
-
-void GL_APIENTRY glUniform2fv(GLint location, GLsizei count, const GLfloat* v)
-{
- TRACE("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
-
- try
- {
- if(count < 0)
- {
- return error(GL_INVALID_VALUE);
- }
-
- if(location == -1)
- {
- return;
- }
-
- gl::Context *context = gl::getContext();
-
- if(context)
- {
- gl::Program *program = context->getCurrentProgram();
-
- if(!program)
- {
- return error(GL_INVALID_OPERATION);
- }
-
- if(!program->setUniform2fv(location, count, v))
- {
- return error(GL_INVALID_OPERATION);
- }
- }
- }
- catch(std::bad_alloc&)
- {
- return error(GL_OUT_OF_MEMORY);
- }
-}
-
-void GL_APIENTRY glUniform2i(GLint location, GLint x, GLint y)
-{
- GLint xy[4] = {x, y};
-
- glUniform2iv(location, 1, (GLint*)&xy);
-}
-
-void GL_APIENTRY glUniform2iv(GLint location, GLsizei count, const GLint* v)
-{
- TRACE("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
-
- try
- {
- if(count < 0)
- {
- return error(GL_INVALID_VALUE);
- }
-
- if(location == -1)
- {
- return;
- }
-
- gl::Context *context = gl::getContext();
-
- if(context)
- {
- gl::Program *program = context->getCurrentProgram();
-
- if(!program)
- {
- return error(GL_INVALID_OPERATION);
- }
-
- if(!program->setUniform2iv(location, count, v))
- {
- return error(GL_INVALID_OPERATION);
- }
- }
- }
- catch(std::bad_alloc&)
- {
- return error(GL_OUT_OF_MEMORY);
- }
-}
-
-void GL_APIENTRY glUniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z)
-{
- GLfloat xyz[3] = {x, y, z};
-
- glUniform3fv(location, 1, (GLfloat*)&xyz);
-}
-
-void GL_APIENTRY glUniform3fv(GLint location, GLsizei count, const GLfloat* v)
-{
- TRACE("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
-
- try
- {
- if(count < 0)
- {
- return error(GL_INVALID_VALUE);
- }
-
- if(location == -1)
- {
- return;
- }
-
- gl::Context *context = gl::getContext();
-
- if(context)
- {
- gl::Program *program = context->getCurrentProgram();
-
- if(!program)
- {
- return error(GL_INVALID_OPERATION);
- }
-
- if(!program->setUniform3fv(location, count, v))
- {
- return error(GL_INVALID_OPERATION);
- }
- }
- }
- catch(std::bad_alloc&)
- {
- return error(GL_OUT_OF_MEMORY);
- }
-}
-
-void GL_APIENTRY glUniform3i(GLint location, GLint x, GLint y, GLint z)
-{
- GLint xyz[3] = {x, y, z};
-
- glUniform3iv(location, 1, (GLint*)&xyz);
-}
-
-void GL_APIENTRY glUniform3iv(GLint location, GLsizei count, const GLint* v)
-{
- TRACE("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
-
- try
- {
- if(count < 0)
- {
- return error(GL_INVALID_VALUE);
- }
-
- if(location == -1)
- {
- return;
- }
-
- gl::Context *context = gl::getContext();
-
- if(context)
- {
- gl::Program *program = context->getCurrentProgram();
-
- if(!program)
- {
- return error(GL_INVALID_OPERATION);
- }
-
- if(!program->setUniform3iv(location, count, v))
- {
- return error(GL_INVALID_OPERATION);
- }
- }
- }
- catch(std::bad_alloc&)
- {
- return error(GL_OUT_OF_MEMORY);
- }
-}
-
-void GL_APIENTRY glUniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
-{
- GLfloat xyzw[4] = {x, y, z, w};
-
- glUniform4fv(location, 1, (GLfloat*)&xyzw);
-}
-
-void GL_APIENTRY glUniform4fv(GLint location, GLsizei count, const GLfloat* v)
-{
- TRACE("(GLint location = %d, GLsizei count = %d, const GLfloat* v = 0x%0.8p)", location, count, v);
-
- try
- {
- if(count < 0)
- {
- return error(GL_INVALID_VALUE);
- }
-
- if(location == -1)
- {
- return;
- }
-
- gl::Context *context = gl::getContext();
-
- if(context)
- {
- gl::Program *program = context->getCurrentProgram();
-
- if(!program)
- {
- return error(GL_INVALID_OPERATION);
- }
-
- if(!program->setUniform4fv(location, count, v))
- {
- return error(GL_INVALID_OPERATION);
- }
- }
- }
- catch(std::bad_alloc&)
- {
- return error(GL_OUT_OF_MEMORY);
- }
-}
-
-void GL_APIENTRY glUniform4i(GLint location, GLint x, GLint y, GLint z, GLint w)
-{
- GLint xyzw[4] = {x, y, z, w};
-
- glUniform4iv(location, 1, (GLint*)&xyzw);
-}
-
-void GL_APIENTRY glUniform4iv(GLint location, GLsizei count, const GLint* v)
-{
- TRACE("(GLint location = %d, GLsizei count = %d, const GLint* v = 0x%0.8p)", location, count, v);
-
- try
- {
- if(count < 0)
- {
- return error(GL_INVALID_VALUE);
- }
-
- if(location == -1)
- {
- return;
- }
-
- gl::Context *context = gl::getContext();
-
- if(context)
- {
- gl::Program *program = context->getCurrentProgram();
-
- if(!program)
- {
- return error(GL_INVALID_OPERATION);
- }
-
- if(!program->setUniform4iv(location, count, v))
- {
- return error(GL_INVALID_OPERATION);
- }
- }
- }
- catch(std::bad_alloc&)
- {
- return error(GL_OUT_OF_MEMORY);
- }
-}
-
-void GL_APIENTRY glUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
-{
- TRACE("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %d, const GLfloat* value = 0x%0.8p)",
- location, count, transpose, value);
-
- try
- {
- if(count < 0 || transpose != GL_FALSE)
- {
- return error(GL_INVALID_VALUE);
- }
-
- if(location == -1)
- {
- return;
- }
-
- gl::Context *context = gl::getContext();
-
- if(context)
- {
- gl::Program *program = context->getCurrentProgram();
-
- if(!program)
- {
- return error(GL_INVALID_OPERATION);
- }
-
- if(!program->setUniformMatrix2fv(location, count, value))
- {
- return error(GL_INVALID_OPERATION);
- }
- }
- }
- catch(std::bad_alloc&)
- {
- return error(GL_OUT_OF_MEMORY);
- }
-}
-
-void GL_APIENTRY glUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
-{
- TRACE("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %d, const GLfloat* value = 0x%0.8p)",
- location, count, transpose, value);
-
- try
- {
- if(count < 0 || transpose != GL_FALSE)
- {
- return error(GL_INVALID_VALUE);
- }
-
- if(location == -1)
- {
- return;
- }
-
- gl::Context *context = gl::getContext();
-
- if(context)
- {
- gl::Program *program = context->getCurrentProgram();
-
- if(!program)
- {
- return error(GL_INVALID_OPERATION);
- }
-
- if(!program->setUniformMatrix3fv(location, count, value))
- {
- return error(GL_INVALID_OPERATION);
- }
- }
- }
- catch(std::bad_alloc&)
- {
- return error(GL_OUT_OF_MEMORY);
- }
-}
-
-void GL_APIENTRY glUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat* value)
-{
- TRACE("(GLint location = %d, GLsizei count = %d, GLboolean transpose = %d, const GLfloat* value = 0x%0.8p)",
- location, count, transpose, value);
-
- try
- {
- if(count < 0 || transpose != GL_FALSE)
- {
- return error(GL_INVALID_VALUE);
- }
-
- if(location == -1)
- {
- return;
- }
-
- gl::Context *context = gl::getContext();
-
- if(context)
- {
- gl::Program *program = context->getCurrentProgram();
-
- if(!program)
- {
- return error(GL_INVALID_OPERATION);
- }
-
- if(!program->setUniformMatrix4fv(location, count, value))
- {
- return error(GL_INVALID_OPERATION);
- }
- }
- }
- catch(std::bad_alloc&)
- {
- return error(GL_OUT_OF_MEMORY);
- }
-}
-
-void GL_APIENTRY glUseProgram(GLuint program)
-{
- TRACE("(GLuint program = %d)", program);
-
- try
- {
- gl::Context *context = gl::getContext();
-
- if(context)
- {
- gl::Program *programObject = context->getProgram(program);
-
- if(!programObject && program != 0)
- {
- if(context->getShader(program))
- {
- return error(GL_INVALID_OPERATION);
- }
- else
- {
- return error(GL_INVALID_VALUE);
- }
- }
-
- if(program != 0 && !programObject->isLinked())
- {
- return error(GL_INVALID_OPERATION);
- }
-
- context->useProgram(program);
- }
- }
- catch(std::bad_alloc&)
- {
- return error(GL_OUT_OF_MEMORY);
- }
-}
-
-void GL_APIENTRY glValidateProgram(GLuint program)
-{
- TRACE("(GLuint program = %d)", program);
-
- try
- {
- gl::Context *context = gl::getContext();
-
- if(context)
- {
- gl::Program *programObject = context->getProgram(program);
-
- if(!programObject)
- {
- if(context->getShader(program))
- {
- return error(GL_INVALID_OPERATION);
- }
- else
- {
- return error(GL_INVALID_VALUE);
- }
- }
-
- programObject->validate();
- }
- }
- catch(std::bad_alloc&)
- {
- return error(GL_OUT_OF_MEMORY);
- }
-}
-
-void GL_APIENTRY glVertexAttrib1f(GLuint index, GLfloat x)
-{
- TRACE("(GLuint index = %d, GLfloat x = %f)", index, x);
-
- try
- {
- if(index >= gl::MAX_VERTEX_ATTRIBS)
- {
- return error(GL_INVALID_VALUE);
- }
-
- gl::Context *context = gl::getContext();
-
- if(context)
- {
- GLfloat vals[4] = { x, 0, 0, 1 };
- context->setVertexAttrib(index, vals);
- }
- }
- catch(std::bad_alloc&)
- {
- return error(GL_OUT_OF_MEMORY);
- }
-}
-
-void GL_APIENTRY glVertexAttrib1fv(GLuint index, const GLfloat* values)
-{
- TRACE("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
-
- try
- {
- if(index >= gl::MAX_VERTEX_ATTRIBS)
- {
- return error(GL_INVALID_VALUE);
- }
-
- gl::Context *context = gl::getContext();
-
- if(context)
- {
- GLfloat vals[4] = { values[0], 0, 0, 1 };
- context->setVertexAttrib(index, vals);
- }
- }
- catch(std::bad_alloc&)
- {
- return error(GL_OUT_OF_MEMORY);
- }
-}
-
-void GL_APIENTRY glVertexAttrib2f(GLuint index, GLfloat x, GLfloat y)
-{
- TRACE("(GLuint index = %d, GLfloat x = %f, GLfloat y = %f)", index, x, y);
-
- try
- {
- if(index >= gl::MAX_VERTEX_ATTRIBS)
- {
- return error(GL_INVALID_VALUE);
- }
-
- gl::Context *context = gl::getContext();
-
- if(context)
- {
- GLfloat vals[4] = { x, y, 0, 1 };
- context->setVertexAttrib(index, vals);
- }
- }
- catch(std::bad_alloc&)
- {
- return error(GL_OUT_OF_MEMORY);
- }
-}
-
-void GL_APIENTRY glVertexAttrib2fv(GLuint index, const GLfloat* values)
-{
- TRACE("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
-
- try
- {
- if(index >= gl::MAX_VERTEX_ATTRIBS)
- {
- return error(GL_INVALID_VALUE);
- }
-
- gl::Context *context = gl::getContext();
-
- if(context)
- {
- GLfloat vals[4] = { values[0], values[1], 0, 1 };
- context->setVertexAttrib(index, vals);
- }
- }
- catch(std::bad_alloc&)
- {
- return error(GL_OUT_OF_MEMORY);
- }
-}
-
-void GL_APIENTRY glVertexAttrib3f(GLuint index, GLfloat x, GLfloat y, GLfloat z)
-{
- TRACE("(GLuint index = %d, GLfloat x = %f, GLfloat y = %f, GLfloat z = %f)", index, x, y, z);
-
- try
- {
- if(index >= gl::MAX_VERTEX_ATTRIBS)
- {
- return error(GL_INVALID_VALUE);
- }
-
- gl::Context *context = gl::getContext();
-
- if(context)
- {
- GLfloat vals[4] = { x, y, z, 1 };
- context->setVertexAttrib(index, vals);
- }
- }
- catch(std::bad_alloc&)
- {
- return error(GL_OUT_OF_MEMORY);
- }
-}
-
-void GL_APIENTRY glVertexAttrib3fv(GLuint index, const GLfloat* values)
-{
- TRACE("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
-
- try
- {
- if(index >= gl::MAX_VERTEX_ATTRIBS)
- {
- return error(GL_INVALID_VALUE);
- }
-
- gl::Context *context = gl::getContext();
-
- if(context)
- {
- GLfloat vals[4] = { values[0], values[1], values[2], 1 };
- context->setVertexAttrib(index, vals);
- }
- }
- catch(std::bad_alloc&)
- {
- return error(GL_OUT_OF_MEMORY);
- }
-}
-
-void GL_APIENTRY glVertexAttrib4f(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
-{
- TRACE("(GLuint index = %d, GLfloat x = %f, GLfloat y = %f, GLfloat z = %f, GLfloat w = %f)", index, x, y, z, w);
-
- try
- {
- if(index >= gl::MAX_VERTEX_ATTRIBS)
- {
- return error(GL_INVALID_VALUE);
- }
-
- gl::Context *context = gl::getContext();
-
- if(context)
- {
- GLfloat vals[4] = { x, y, z, w };
- context->setVertexAttrib(index, vals);
- }
- }
- catch(std::bad_alloc&)
- {
- return error(GL_OUT_OF_MEMORY);
- }
-}
-
-void GL_APIENTRY glVertexAttrib4fv(GLuint index, const GLfloat* values)
-{
- TRACE("(GLuint index = %d, const GLfloat* values = 0x%0.8p)", index, values);
-
- try
- {
- if(index >= gl::MAX_VERTEX_ATTRIBS)
- {
- return error(GL_INVALID_VALUE);
- }
-
- gl::Context *context = gl::getContext();
-
- if(context)
- {
- context->setVertexAttrib(index, values);
- }
- }
- catch(std::bad_alloc&)
- {
- return error(GL_OUT_OF_MEMORY);
- }
-}
-
-void GL_APIENTRY glVertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr)
-{
- TRACE("(GLuint index = %d, GLint size = %d, GLenum type = 0x%X, "
- "GLboolean normalized = %d, GLsizei stride = %d, const GLvoid* ptr = 0x%0.8p)",
- index, size, type, normalized, stride, ptr);
-
- try
- {
- if(index >= gl::MAX_VERTEX_ATTRIBS)
- {
- return error(GL_INVALID_VALUE);
- }
-
- if(size < 1 || size > 4)
- {
- return error(GL_INVALID_VALUE);
- }
-
- switch(type)
- {
- case GL_BYTE:
- case GL_UNSIGNED_BYTE:
- case GL_SHORT:
- case GL_UNSIGNED_SHORT:
- case GL_FIXED:
- case GL_FLOAT:
- break;
- default:
- return error(GL_INVALID_ENUM);
- }
-
- if(stride < 0)
- {
- return error(GL_INVALID_VALUE);
- }
-
- gl::Context *context = gl::getContext();
-
- if(context)
- {
- context->setVertexAttribState(index, context->getArrayBuffer(), size, type, (normalized == GL_TRUE), stride, ptr);
- }
- }
- catch(std::bad_alloc&)
- {
- return error(GL_OUT_OF_MEMORY);
- }
+ UNIMPLEMENTED();
}
void GL_APIENTRY glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
@@ -6029,72 +3614,6 @@
}
}
-void GL_APIENTRY glBlitFramebufferANGLE(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
- GLbitfield mask, GLenum filter)
-{
- TRACE("(GLint srcX0 = %d, GLint srcY0 = %d, GLint srcX1 = %d, GLint srcY1 = %d, "
- "GLint dstX0 = %d, GLint dstY0 = %d, GLint dstX1 = %d, GLint dstY1 = %d, "
- "GLbitfield mask = 0x%X, GLenum filter = 0x%X)",
- srcX0, srcY0, srcX1, srcX1, dstX0, dstY0, dstX1, dstY1, mask, filter);
-
- try
- {
- switch(filter)
- {
- case GL_NEAREST:
- break;
- default:
- return error(GL_INVALID_ENUM);
- }
-
- if((mask & ~(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)) != 0)
- {
- return error(GL_INVALID_VALUE);
- }
-
- if(srcX1 - srcX0 != dstX1 - dstX0 || srcY1 - srcY0 != dstY1 - dstY0)
- {
- ERR("Scaling and flipping in BlitFramebufferANGLE not supported by this implementation");
- return error(GL_INVALID_OPERATION);
- }
-
- gl::Context *context = gl::getContext();
-
- if(context)
- {
- if(context->getReadFramebufferHandle() == context->getDrawFramebufferHandle())
- {
- ERR("Blits with the same source and destination framebuffer are not supported by this implementation.");
- return error(GL_INVALID_OPERATION);
- }
-
- context->blitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask);
- }
- }
- catch(std::bad_alloc&)
- {
- return error(GL_OUT_OF_MEMORY);
- }
-}
-
-void GL_APIENTRY glTexImage3DOES(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth,
- GLint border, GLenum format, GLenum type, const GLvoid* pixels)
-{
- TRACE("(GLenum target = 0x%X, GLint level = %d, GLenum internalformat = 0x%X, "
- "GLsizei width = %d, GLsizei height = %d, GLsizei depth = %d, GLint border = %d, "
- "GLenum format = 0x%X, GLenum type = 0x%x, const GLvoid* pixels = 0x%0.8p)",
- target, level, internalformat, width, height, depth, border, format, type, pixels);
-
- try
- {
- UNIMPLEMENTED(); // FIXME
- }
- catch(std::bad_alloc&)
- {
- return error(GL_OUT_OF_MEMORY);
- }
-}
-
void GL_APIENTRY glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOES image)
{
TRACE("(GLenum target = 0x%X, GLeglImageOES image = 0x%0.8p)", target, image);
@@ -6146,28 +3665,24 @@
static const Extension glExtensions[] =
{
- {"glTexImage3DOES", (__eglMustCastToProperFunctionPointerType)glTexImage3DOES},
- {"glBlitFramebufferANGLE", (__eglMustCastToProperFunctionPointerType)glBlitFramebufferANGLE},
- {"glRenderbufferStorageMultisampleANGLE", (__eglMustCastToProperFunctionPointerType)glRenderbufferStorageMultisampleANGLE},
- {"glDeleteFencesNV", (__eglMustCastToProperFunctionPointerType)glDeleteFencesNV},
- {"glGenFencesNV", (__eglMustCastToProperFunctionPointerType)glGenFencesNV},
- {"glIsFenceNV", (__eglMustCastToProperFunctionPointerType)glIsFenceNV},
- {"glTestFenceNV", (__eglMustCastToProperFunctionPointerType)glTestFenceNV},
- {"glGetFenceivNV", (__eglMustCastToProperFunctionPointerType)glGetFenceivNV},
- {"glFinishFenceNV", (__eglMustCastToProperFunctionPointerType)glFinishFenceNV},
- {"glSetFenceNV", (__eglMustCastToProperFunctionPointerType)glSetFenceNV},
- {"glGetGraphicsResetStatusEXT", (__eglMustCastToProperFunctionPointerType)glGetGraphicsResetStatusEXT},
- {"glReadnPixelsEXT", (__eglMustCastToProperFunctionPointerType)glReadnPixelsEXT},
- {"glGetnUniformfvEXT", (__eglMustCastToProperFunctionPointerType)glGetnUniformfvEXT},
- {"glGetnUniformivEXT", (__eglMustCastToProperFunctionPointerType)glGetnUniformivEXT},
- {"glGenQueriesEXT", (__eglMustCastToProperFunctionPointerType)glGenQueriesEXT},
- {"glDeleteQueriesEXT", (__eglMustCastToProperFunctionPointerType)glDeleteQueriesEXT},
- {"glIsQueryEXT", (__eglMustCastToProperFunctionPointerType)glIsQueryEXT},
- {"glBeginQueryEXT", (__eglMustCastToProperFunctionPointerType)glBeginQueryEXT},
- {"glEndQueryEXT", (__eglMustCastToProperFunctionPointerType)glEndQueryEXT},
- {"glGetQueryivEXT", (__eglMustCastToProperFunctionPointerType)glGetQueryivEXT},
- {"glGetQueryObjectuivEXT", (__eglMustCastToProperFunctionPointerType)glGetQueryObjectuivEXT},
- {"glEGLImageTargetTexture2DOES", (__eglMustCastToProperFunctionPointerType)glEGLImageTargetTexture2DOES}
+ {"glEGLImageTargetTexture2DOES", (__eglMustCastToProperFunctionPointerType)glEGLImageTargetTexture2DOES},
+ {"glIsRenderbufferOES", (__eglMustCastToProperFunctionPointerType)glIsRenderbufferOES},
+ {"glBindRenderbufferOES", (__eglMustCastToProperFunctionPointerType)glBindRenderbufferOES},
+ {"glDeleteRenderbuffersOES", (__eglMustCastToProperFunctionPointerType)glDeleteRenderbuffersOES},
+ {"glGenRenderbuffersOES", (__eglMustCastToProperFunctionPointerType)glGenRenderbuffersOES},
+ {"glRenderbufferStorageOES", (__eglMustCastToProperFunctionPointerType)glRenderbufferStorageOES},
+ {"glGetRenderbufferParameterivOES", (__eglMustCastToProperFunctionPointerType)glGetRenderbufferParameterivOES},
+ {"glIsFramebufferOES", (__eglMustCastToProperFunctionPointerType)glIsFramebufferOES},
+ {"glBindFramebufferOES", (__eglMustCastToProperFunctionPointerType)glBindFramebufferOES},
+ {"glDeleteFramebuffersOES", (__eglMustCastToProperFunctionPointerType)glDeleteFramebuffersOES},
+ {"glGenFramebuffersOES", (__eglMustCastToProperFunctionPointerType)glGenFramebuffersOES},
+ {"glCheckFramebufferStatusOES", (__eglMustCastToProperFunctionPointerType)glCheckFramebufferStatusOES},
+ {"glFramebufferRenderbufferOES", (__eglMustCastToProperFunctionPointerType)glFramebufferRenderbufferOES},
+ {"glFramebufferTexture2DOES", (__eglMustCastToProperFunctionPointerType)glFramebufferTexture2DOES},
+ {"glGetFramebufferAttachmentParameterivOES", (__eglMustCastToProperFunctionPointerType)glGetFramebufferAttachmentParameterivOES},
+ {"glGenerateMipmapOES", (__eglMustCastToProperFunctionPointerType)glGenerateMipmapOES},
+ {"glBlendEquationSeparateOES", (__eglMustCastToProperFunctionPointerType)glBlendEquationSeparateOES},
+ {"glBlendFuncSeparateOES", (__eglMustCastToProperFunctionPointerType)glBlendFuncSeparateOES}
};
for(int ext = 0; ext < sizeof(glExtensions) / sizeof(Extension); ext++)
diff --git a/src/GLES2/libGLES_CM/libGLES_CM.def b/src/GLES2/libGLES_CM/libGLES_CM.def
index bd087d3..22640eb 100644
--- a/src/GLES2/libGLES_CM/libGLES_CM.def
+++ b/src/GLES2/libGLES_CM/libGLES_CM.def
@@ -1,172 +1,149 @@
-LIBRARY libGLESv2
+LIBRARY libGLES_CM
EXPORTS
- glActiveTexture @1
- glAttachShader @2
- glBindAttribLocation @3
- glBindBuffer @4
- glBindFramebuffer @5
- glBindRenderbuffer @6
- glBindTexture @7
- glBlendColor @8
- glBlendEquation @9
- glBlendEquationSeparate @10
- glBlendFunc @11
- glBlendFuncSeparate @12
- glBufferData @13
- glBufferSubData @14
- glCheckFramebufferStatus @15
- glClear @16
- glClearColor @17
- glClearDepthf @18
- glClearStencil @19
- glColorMask @20
- glCompileShader @21
- glCompressedTexImage2D @22
- glCompressedTexSubImage2D @23
- glCopyTexImage2D @24
- glCopyTexSubImage2D @25
- glCreateProgram @26
- glCreateShader @27
- glCullFace @28
- glDeleteBuffers @29
- glDeleteFramebuffers @30
- glDeleteProgram @32
- glDeleteRenderbuffers @33
- glDeleteShader @34
- glDeleteTextures @31
- glDepthFunc @36
- glDepthMask @37
- glDepthRangef @38
- glDetachShader @35
- glDisable @39
- glDisableVertexAttribArray @40
- glDrawArrays @41
- glDrawElements @42
- glEnable @43
- glEnableVertexAttribArray @44
- glFinish @45
- glFlush @46
- glFramebufferRenderbuffer @47
- glFramebufferTexture2D @48
- glFrontFace @49
- glGenBuffers @50
- glGenFramebuffers @52
- glGenRenderbuffers @53
- glGenTextures @54
- glGenerateMipmap @51
- glGetActiveAttrib @55
- glGetActiveUniform @56
- glGetAttachedShaders @57
- glGetAttribLocation @58
- glGetBooleanv @59
- glGetBufferParameteriv @60
- glGetError @61
- glGetFloatv @62
- glGetFramebufferAttachmentParameteriv @63
- glGetIntegerv @64
- glGetProgramInfoLog @66
- glGetProgramiv @65
- glGetRenderbufferParameteriv @67
- glGetShaderInfoLog @69
- glGetShaderPrecisionFormat @70
- glGetShaderSource @71
- glGetShaderiv @68
- glGetString @72
- glGetTexParameterfv @73
- glGetTexParameteriv @74
- glGetUniformLocation @77
- glGetUniformfv @75
- glGetUniformiv @76
- glGetVertexAttribPointerv @80
- glGetVertexAttribfv @78
- glGetVertexAttribiv @79
- glHint @81
- glIsBuffer @82
- glIsEnabled @83
- glIsFramebuffer @84
- glIsProgram @85
- glIsRenderbuffer @86
- glIsShader @87
- glIsTexture @88
- glLineWidth @89
- glLinkProgram @90
- glPixelStorei @91
- glPolygonOffset @92
- glReadPixels @93
- glReleaseShaderCompiler @94
- glRenderbufferStorage @95
- glSampleCoverage @96
- glScissor @97
- glShaderBinary @98
- glShaderSource @99
- glStencilFunc @100
- glStencilFuncSeparate @101
- glStencilMask @102
- glStencilMaskSeparate @103
- glStencilOp @104
- glStencilOpSeparate @105
- glTexImage2D @106
- glTexParameterf @107
- glTexParameterfv @108
- glTexParameteri @109
- glTexParameteriv @110
- glTexSubImage2D @111
- glUniform1f @112
- glUniform1fv @113
- glUniform1i @114
- glUniform1iv @115
- glUniform2f @116
- glUniform2fv @117
- glUniform2i @118
- glUniform2iv @119
- glUniform3f @120
- glUniform3fv @121
- glUniform3i @122
- glUniform3iv @123
- glUniform4f @124
- glUniform4fv @125
- glUniform4i @126
- glUniform4iv @127
- glUniformMatrix2fv @128
- glUniformMatrix3fv @129
- glUniformMatrix4fv @130
- glUseProgram @131
- glValidateProgram @132
- glVertexAttrib1f @133
- glVertexAttrib1fv @134
- glVertexAttrib2f @135
- glVertexAttrib2fv @136
- glVertexAttrib3f @137
- glVertexAttrib3fv @138
- glVertexAttrib4f @139
- glVertexAttrib4fv @140
- glVertexAttribPointer @141
- glViewport @142
-
- ; Extensions
- glTexImage3DOES @143
- glBlitFramebufferANGLE @149
- glRenderbufferStorageMultisampleANGLE @150
- glDeleteFencesNV @151
- glFinishFenceNV @152
- glGenFencesNV @153
- glGetFenceivNV @154
- glIsFenceNV @155
- glSetFenceNV @156
- glTestFenceNV @157
- ;glGetTranslatedShaderSourceANGLE @159
- ;glTexStorage2DEXT @160
- glGetGraphicsResetStatusEXT @161
- glReadnPixelsEXT @162
- glGetnUniformfvEXT @163
- glGetnUniformivEXT @164
- glGenQueriesEXT @165
- glDeleteQueriesEXT @166
- glIsQueryEXT @167
- glBeginQueryEXT @168
- glEndQueryEXT @169
- glGetQueryivEXT @170
- glGetQueryObjectuivEXT @171
+ glActiveTexture
+ glAlphaFunc
+ glAlphaFuncx
+ glBindBuffer
+ glBindTexture
+ glBlendFunc
+ glBufferData
+ glBufferSubData
+ glClear
+ glClearColor
+ glClearColorx
+ glClearDepthf
+ glClearDepthx
+ glClearStencil
+ glClientActiveTexture
+ glClipPlanef
+ glClipPlanex
+ glColor4f
+ glColor4ub
+ glColor4x
+ glColorMask
+ glColorPointer
+ glCompressedTexImage2D
+ glCompressedTexSubImage2D
+ glCopyTexImage2D
+ glCopyTexSubImage2D
+ glCullFace
+ glDeleteBuffers
+ glDeleteTextures
+ glDepthFunc
+ glDepthMask
+ glDepthRangef
+ glDepthRangex
+ glDisable
+ glDisableClientState
+ glDrawArrays
+ glDrawElements
+ glEnable
+ glEnableClientState
+ glFinish
+ glFlush
+ glFogf
+ glFogfv
+ glFogx
+ glFogxv
+ glFrontFace
+ glFrustumf
+ glFrustumx
+ glGenBuffers
+ glGenTextures
+ glGetBooleanv
+ glGetBufferParameteriv
+ glGetClipPlanef
+ glGetClipPlanex
+ glGetError
+ glGetFixedv
+ glGetFloatv
+ glGetIntegerv
+ glGetLightfv
+ glGetLightxv
+ glGetMaterialfv
+ glGetMaterialxv
+ glGetPointerv
+ glGetString
+ glGetTexEnvfv
+ glGetTexEnviv
+ glGetTexEnvxv
+ glGetTexParameterfv
+ glGetTexParameteriv
+ glGetTexParameterxv
+ glHint
+ glIsBuffer
+ glIsEnabled
+ glIsTexture
+ glLightModelf
+ glLightModelfv
+ glLightModelx
+ glLightModelxv
+ glLightf
+ glLightfv
+ glLightx
+ glLightxv
+ glLineWidth
+ glLineWidthx
+ glLoadIdentity
+ glLoadMatrixf
+ glLoadMatrixx
+ glLogicOp
+ glMaterialf
+ glMaterialfv
+ glMaterialx
+ glMaterialxv
+ glMatrixMode
+ glMultMatrixf
+ glMultMatrixx
+ glMultiTexCoord4f
+ glMultiTexCoord4x
+ glNormal3f
+ glNormal3x
+ glNormalPointer
+ glOrthof
+ glOrthox
+ glPixelStorei
+ glPointParameterf
+ glPointParameterfv
+ glPointParameterx
+ glPointParameterxv
+ glPointSize
+ glPointSizex
+ glPolygonOffset
+ glPolygonOffsetx
+ glPopMatrix
+ glPushMatrix
+ glReadPixels
+ glRotatef
+ glRotatex
+ glSampleCoverage
+ glSampleCoveragex
+ glScalef
+ glScalex
+ glScissor
+ glShadeModel
+ glStencilFunc
+ glStencilMask
+ glStencilOp
+ glTexCoordPointer
+ glTexEnvf
+ glTexEnvfv
+ glTexEnvi
+ glTexEnviv
+ glTexEnvx
+ glTexEnvxv
+ glTexImage2D
+ glTexParameterf
+ glTexParameterfv
+ glTexParameteri
+ glTexParameteriv
+ glTexParameterx
+ glTexParameterxv
+ glTexSubImage2D
+ glTranslatef
+ glTranslatex
+ glVertexPointer
+ glViewport
; EGL dependencies
glCreateContext @144
diff --git a/src/GLES2/libGLES_CM/libGLES_CM.rc b/src/GLES2/libGLES_CM/libGLES_CM.rc
index 919c7ed..ec97aa0 100644
--- a/src/GLES2/libGLES_CM/libGLES_CM.rc
+++ b/src/GLES2/libGLES_CM/libGLES_CM.rc
@@ -70,13 +70,13 @@
BEGIN
BLOCK "040904b0"
BEGIN
- VALUE "FileDescription", "SwiftShader libGLESv2 Dynamic Link Library"
+ VALUE "FileDescription", "SwiftShader libGLES_CM Dynamic Link Library"
VALUE "FileVersion", VERSION_STRING
- VALUE "InternalName", "libGLESv2"
+ VALUE "InternalName", "libGLES_CM"
VALUE "LegalCopyright", "Copyright (C) 2012 TransGaming Inc."
- VALUE "OriginalFilename", "libGLESv2.dll"
+ VALUE "OriginalFilename", "libGLES_CM.dll"
VALUE "PrivateBuild", VERSION_STRING
- VALUE "ProductName", "SwiftShader libGLESv2 Dynamic Link Library"
+ VALUE "ProductName", "SwiftShader libGLES_CM Dynamic Link Library"
VALUE "ProductVersion", VERSION_STRING
END
END
diff --git a/src/GLES2/libGLES_CM/libGLES_CM.vcxproj b/src/GLES2/libGLES_CM/libGLES_CM.vcxproj
index 49c5386..549e620 100644
--- a/src/GLES2/libGLES_CM/libGLES_CM.vcxproj
+++ b/src/GLES2/libGLES_CM/libGLES_CM.vcxproj
@@ -164,19 +164,15 @@
<ClCompile Include="Context.cpp" />
<ClCompile Include="..\common\debug.cpp" />
<ClCompile Include="Device.cpp" />
- <ClCompile Include="Fence.cpp" />
<ClCompile Include="Framebuffer.cpp" />
<ClCompile Include="HandleAllocator.cpp" />
<ClCompile Include="Image.cpp" />
<ClCompile Include="IndexDataManager.cpp" />
<ClCompile Include="libGLES_CM.cpp" />
<ClCompile Include="main.cpp" />
- <ClCompile Include="Program.cpp" />
- <ClCompile Include="Query.cpp" />
<ClCompile Include="RefCountObject.cpp" />
<ClCompile Include="Renderbuffer.cpp" />
<ClCompile Include="ResourceManager.cpp" />
- <ClCompile Include="Shader.cpp" />
<ClCompile Include="Texture.cpp" />
<ClCompile Include="utilities.cpp" />
<ClCompile Include="VertexDataManager.cpp" />
@@ -189,20 +185,16 @@
<ClInclude Include="Buffer.h" />
<ClInclude Include="Context.h" />
<ClInclude Include="Device.hpp" />
- <ClInclude Include="Fence.h" />
<ClInclude Include="Framebuffer.h" />
<ClInclude Include="HandleAllocator.h" />
<ClInclude Include="Image.hpp" />
<ClInclude Include="IndexDataManager.h" />
<ClInclude Include="main.h" />
<ClInclude Include="mathutil.h" />
- <ClInclude Include="Program.h" />
- <ClInclude Include="Query.h" />
<ClInclude Include="RefCountObject.h" />
<ClInclude Include="Renderbuffer.h" />
<ClInclude Include="resource.h" />
<ClInclude Include="ResourceManager.h" />
- <ClInclude Include="Shader.h" />
<ClInclude Include="Texture.h" />
<ClInclude Include="utilities.h" />
<ClInclude Include="VertexDataManager.h" />
diff --git a/src/GLES2/libGLES_CM/libGLES_CM.vcxproj.filters b/src/GLES2/libGLES_CM/libGLES_CM.vcxproj.filters
index 2705cd7..ba143d2 100644
--- a/src/GLES2/libGLES_CM/libGLES_CM.vcxproj.filters
+++ b/src/GLES2/libGLES_CM/libGLES_CM.vcxproj.filters
@@ -20,9 +20,6 @@
<ClCompile Include="..\common\debug.cpp">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="Fence.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
<ClCompile Include="Framebuffer.cpp">
<Filter>Source Files</Filter>
</ClCompile>
@@ -35,9 +32,6 @@
<ClCompile Include="main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="Program.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
<ClCompile Include="RefCountObject.cpp">
<Filter>Source Files</Filter>
</ClCompile>
@@ -47,9 +41,6 @@
<ClCompile Include="ResourceManager.cpp">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="Shader.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
<ClCompile Include="Texture.cpp">
<Filter>Source Files</Filter>
</ClCompile>
@@ -65,9 +56,6 @@
<ClCompile Include="Image.cpp">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="Query.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
<ClCompile Include="libGLES_CM.cpp">
<Filter>Source Files</Filter>
</ClCompile>
@@ -79,9 +67,6 @@
<ClInclude Include="Context.h">
<Filter>Header Files</Filter>
</ClInclude>
- <ClInclude Include="Fence.h">
- <Filter>Header Files</Filter>
- </ClInclude>
<ClInclude Include="Framebuffer.h">
<Filter>Header Files</Filter>
</ClInclude>
@@ -97,9 +82,6 @@
<ClInclude Include="mathutil.h">
<Filter>Header Files</Filter>
</ClInclude>
- <ClInclude Include="Program.h">
- <Filter>Header Files</Filter>
- </ClInclude>
<ClInclude Include="RefCountObject.h">
<Filter>Header Files</Filter>
</ClInclude>
@@ -112,9 +94,6 @@
<ClInclude Include="ResourceManager.h">
<Filter>Header Files</Filter>
</ClInclude>
- <ClInclude Include="Shader.h">
- <Filter>Header Files</Filter>
- </ClInclude>
<ClInclude Include="Texture.h">
<Filter>Header Files</Filter>
</ClInclude>
@@ -139,9 +118,6 @@
<ClInclude Include="..\include\GLES2\gl2platform.h">
<Filter>Header Files</Filter>
</ClInclude>
- <ClInclude Include="Query.h">
- <Filter>Header Files</Filter>
- </ClInclude>
<ClInclude Include="..\common\debug.h">
<Filter>Header Files</Filter>
</ClInclude>
diff --git a/src/GLES2/libGLES_CM/main.cpp b/src/GLES2/libGLES_CM/main.cpp
index 9ddca97..f165e53 100644
--- a/src/GLES2/libGLES_CM/main.cpp
+++ b/src/GLES2/libGLES_CM/main.cpp
@@ -179,7 +179,7 @@
context->recordOutOfMemory();
TRACE("\t! Error generated: out of memory\n");
break;
- case GL_INVALID_FRAMEBUFFER_OPERATION:
+ case GL_INVALID_FRAMEBUFFER_OPERATION_OES:
context->recordInvalidFramebufferOperation();
TRACE("\t! Error generated: invalid framebuffer operation\n");
break;
diff --git a/src/GLES2/libGLES_CM/main.h b/src/GLES2/libGLES_CM/main.h
index fdb0dc0..cc3cfb1 100644
--- a/src/GLES2/libGLES_CM/main.h
+++ b/src/GLES2/libGLES_CM/main.h
@@ -11,17 +11,18 @@
// main.h: Management of thread-local data.
-#ifndef LIBGLESV2_MAIN_H_
-#define LIBGLESV2_MAIN_H_
+#ifndef LIBGLES_CM_MAIN_H_
+#define LIBGLES_CM_MAIN_H_
#include "Context.h"
#include "Device.hpp"
#include "common/debug.h"
#include "libEGL/Display.h"
-#define GL_APICALL
-#include <GLES2/gl2.h>
-#include <GLES2/gl2ext.h>
+#define GL_API
+#include <GLES/gl.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GLES/glext.h>
namespace gl
{
@@ -49,4 +50,4 @@
return returnValue;
}
-#endif // LIBGLESV2_MAIN_H_
+#endif // LIBGLES_CM_MAIN_H_
diff --git a/src/GLES2/libGLES_CM/mathutil.h b/src/GLES2/libGLES_CM/mathutil.h
index 9955fb2..61cbac9 100644
--- a/src/GLES2/libGLES_CM/mathutil.h
+++ b/src/GLES2/libGLES_CM/mathutil.h
@@ -11,8 +11,8 @@
// mathutil.h: Math and bit manipulation functions.
-#ifndef LIBGLESV2_MATHUTIL_H_
-#define LIBGLESV2_MATHUTIL_H_
+#ifndef LIBGLES_CM_MATHUTIL_H_
+#define LIBGLES_CM_MATHUTIL_H_
#include "common/debug.h"
@@ -76,4 +76,4 @@
}
}
-#endif // LIBGLESV2_MATHUTIL_H_
+#endif // LIBGLES_CM_MATHUTIL_H_
diff --git a/src/GLES2/libGLES_CM/resource.h b/src/GLES2/libGLES_CM/resource.h
index 39adaad..ecb2b1f 100644
--- a/src/GLES2/libGLES_CM/resource.h
+++ b/src/GLES2/libGLES_CM/resource.h
@@ -1,6 +1,6 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
-// Used by libGLESv2.rc
+// Used by libGLES_CM.rc
// Next default values for new objects
//
diff --git a/src/GLES2/libGLES_CM/utilities.cpp b/src/GLES2/libGLES_CM/utilities.cpp
index c0004bf..2517a73 100644
--- a/src/GLES2/libGLES_CM/utilities.cpp
+++ b/src/GLES2/libGLES_CM/utilities.cpp
@@ -22,172 +22,6 @@
namespace gl
{
- int UniformComponentCount(GLenum type)
- {
- switch(type)
- {
- case GL_BOOL:
- case GL_FLOAT:
- case GL_INT:
- case GL_SAMPLER_2D:
- case GL_SAMPLER_CUBE:
- case GL_SAMPLER_EXTERNAL_OES:
- return 1;
- case GL_BOOL_VEC2:
- case GL_FLOAT_VEC2:
- case GL_INT_VEC2:
- return 2;
- case GL_INT_VEC3:
- case GL_FLOAT_VEC3:
- case GL_BOOL_VEC3:
- return 3;
- case GL_BOOL_VEC4:
- case GL_FLOAT_VEC4:
- case GL_INT_VEC4:
- case GL_FLOAT_MAT2:
- return 4;
- case GL_FLOAT_MAT3:
- return 9;
- case GL_FLOAT_MAT4:
- return 16;
- default:
- UNREACHABLE();
- }
-
- return 0;
- }
-
- GLenum UniformComponentType(GLenum type)
- {
- switch(type)
- {
- case GL_BOOL:
- case GL_BOOL_VEC2:
- case GL_BOOL_VEC3:
- case GL_BOOL_VEC4:
- return GL_BOOL;
- case GL_FLOAT:
- case GL_FLOAT_VEC2:
- case GL_FLOAT_VEC3:
- case GL_FLOAT_VEC4:
- case GL_FLOAT_MAT2:
- case GL_FLOAT_MAT3:
- case GL_FLOAT_MAT4:
- return GL_FLOAT;
- case GL_INT:
- case GL_SAMPLER_2D:
- case GL_SAMPLER_CUBE:
- case GL_SAMPLER_EXTERNAL_OES:
- case GL_INT_VEC2:
- case GL_INT_VEC3:
- case GL_INT_VEC4:
- return GL_INT;
- default:
- UNREACHABLE();
- }
-
- return GL_NONE;
- }
-
- size_t UniformTypeSize(GLenum type)
- {
- switch(type)
- {
- case GL_BOOL: return sizeof(GLboolean);
- case GL_FLOAT: return sizeof(GLfloat);
- case GL_INT: return sizeof(GLint);
- }
-
- return UniformTypeSize(UniformComponentType(type)) * UniformComponentCount(type);
- }
-
- int VariableRowCount(GLenum type)
- {
- switch(type)
- {
- case GL_NONE:
- return 0;
- case GL_BOOL:
- case GL_FLOAT:
- case GL_INT:
- case GL_BOOL_VEC2:
- case GL_FLOAT_VEC2:
- case GL_INT_VEC2:
- case GL_INT_VEC3:
- case GL_FLOAT_VEC3:
- case GL_BOOL_VEC3:
- case GL_BOOL_VEC4:
- case GL_FLOAT_VEC4:
- case GL_INT_VEC4:
- case GL_SAMPLER_2D:
- case GL_SAMPLER_CUBE:
- case GL_SAMPLER_EXTERNAL_OES:
- return 1;
- case GL_FLOAT_MAT2:
- return 2;
- case GL_FLOAT_MAT3:
- return 3;
- case GL_FLOAT_MAT4:
- return 4;
- default:
- UNREACHABLE();
- }
-
- return 0;
- }
-
- int VariableColumnCount(GLenum type)
- {
- switch(type)
- {
- case GL_NONE:
- return 0;
- case GL_BOOL:
- case GL_FLOAT:
- case GL_INT:
- return 1;
- case GL_BOOL_VEC2:
- case GL_FLOAT_VEC2:
- case GL_INT_VEC2:
- case GL_FLOAT_MAT2:
- return 2;
- case GL_INT_VEC3:
- case GL_FLOAT_VEC3:
- case GL_BOOL_VEC3:
- case GL_FLOAT_MAT3:
- return 3;
- case GL_BOOL_VEC4:
- case GL_FLOAT_VEC4:
- case GL_INT_VEC4:
- case GL_FLOAT_MAT4:
- return 4;
- default:
- UNREACHABLE();
- }
-
- return 0;
- }
-
- int AllocateFirstFreeBits(unsigned int *bits, unsigned int allocationSize, unsigned int bitsSize)
- {
- ASSERT(allocationSize <= bitsSize);
-
- unsigned int mask = std::numeric_limits<unsigned int>::max() >> (std::numeric_limits<unsigned int>::digits - allocationSize);
-
- for(unsigned int i = 0; i < bitsSize - allocationSize + 1; i++)
- {
- if((*bits & mask) == 0)
- {
- *bits |= mask;
- return i;
- }
-
- mask <<= 1;
- }
-
- return -1;
- }
-
GLsizei ComputePitch(GLsizei width, GLenum format, GLenum type, GLint alignment)
{
ASSERT(alignment > 0 && isPow2(alignment));
@@ -208,9 +42,6 @@
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
return 8 * (GLsizei)ceil((float)width / 4.0f) * (GLsizei)ceil((float)height / 4.0f);
- case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
- case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
- return 16 * (GLsizei)ceil((float)width / 4.0f) * (GLsizei)ceil((float)height / 4.0f);
default:
return 0;
}
@@ -219,9 +50,7 @@
bool IsCompressed(GLenum format)
{
if(format == GL_COMPRESSED_RGB_S3TC_DXT1_EXT ||
- format == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT ||
- format == GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE ||
- format == GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE)
+ format == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT)
{
return true;
}
@@ -233,8 +62,7 @@
bool IsDepthTexture(GLenum format)
{
- if(format == GL_DEPTH_COMPONENT ||
- format == GL_DEPTH_STENCIL_OES)
+ if(format == GL_DEPTH_STENCIL_OES)
{
return true;
}
@@ -244,8 +72,7 @@
bool IsStencilTexture(GLenum format)
{
- if(format == GL_STENCIL_INDEX ||
- format == GL_DEPTH_STENCIL_OES)
+ if(format == GL_DEPTH_STENCIL_OES)
{
return true;
}
@@ -289,17 +116,6 @@
default: UNREACHABLE();
}
break;
- case GL_HALF_FLOAT_OES:
- switch(format)
- {
- case GL_ALPHA: return sizeof(unsigned short);
- case GL_LUMINANCE: return sizeof(unsigned short);
- case GL_LUMINANCE_ALPHA: return sizeof(unsigned short) * 2;
- case GL_RGB: return sizeof(unsigned short) * 3;
- case GL_RGBA: return sizeof(unsigned short) * 4;
- default: UNREACHABLE();
- }
- break;
default: UNREACHABLE();
}
@@ -308,27 +124,27 @@
bool IsCubemapTextureTarget(GLenum target)
{
- return (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X && target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z);
+ return (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_OES && target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_OES);
}
int CubeFaceIndex(GLenum cubeFace)
{
switch(cubeFace)
{
- case GL_TEXTURE_CUBE_MAP:
- case GL_TEXTURE_CUBE_MAP_POSITIVE_X: return 0;
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: return 1;
- case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: return 2;
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: return 3;
- case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: return 4;
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: return 5;
+ case GL_TEXTURE_CUBE_MAP_OES:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_X_OES: return 0;
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_OES: return 1;
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_OES: return 2;
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_OES: return 3;
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_OES: return 4;
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_OES: return 5;
default: UNREACHABLE(); return 0;
}
}
bool IsTextureTarget(GLenum target)
{
- return target == GL_TEXTURE_2D || IsCubemapTextureTarget(target);
+ return target == GL_TEXTURE_2D;
}
// Verify that format/type are one of the combinations from table 3.4.
@@ -350,25 +166,11 @@
return false;
}
case GL_FLOAT:
- case GL_HALF_FLOAT_OES:
- switch(format)
- {
- case GL_RGBA:
- case GL_RGB:
- case GL_ALPHA:
- case GL_LUMINANCE:
- case GL_LUMINANCE_ALPHA:
- return true;
- default:
- return false;
- }
case GL_UNSIGNED_SHORT_4_4_4_4:
case GL_UNSIGNED_SHORT_5_5_5_1:
return (format == GL_RGBA);
case GL_UNSIGNED_SHORT_5_6_5:
return (format == GL_RGB);
- case GL_UNSIGNED_INT:
- return (format == GL_DEPTH_COMPONENT);
case GL_UNSIGNED_INT_24_8_OES:
return (format == GL_DEPTH_STENCIL_OES);
default:
@@ -380,14 +182,14 @@
{
switch(internalformat)
{
- case GL_RGBA4:
- case GL_RGB5_A1:
- case GL_RGB565:
+ case GL_RGBA4_OES:
+ case GL_RGB5_A1_OES:
+ case GL_RGB565_OES:
case GL_RGB8_OES:
case GL_RGBA8_OES:
return true;
- case GL_DEPTH_COMPONENT16:
- case GL_STENCIL_INDEX8:
+ case GL_DEPTH_COMPONENT16_OES:
+ case GL_STENCIL_INDEX8_OES:
case GL_DEPTH24_STENCIL8_OES:
return false;
default:
@@ -401,13 +203,13 @@
{
switch(internalformat)
{
- case GL_DEPTH_COMPONENT16:
+ case GL_DEPTH_COMPONENT16_OES:
case GL_DEPTH24_STENCIL8_OES:
return true;
- case GL_STENCIL_INDEX8:
- case GL_RGBA4:
- case GL_RGB5_A1:
- case GL_RGB565:
+ case GL_STENCIL_INDEX8_OES:
+ case GL_RGBA4_OES:
+ case GL_RGB5_A1_OES:
+ case GL_RGB565_OES:
case GL_RGB8_OES:
case GL_RGBA8_OES:
return false;
@@ -422,15 +224,15 @@
{
switch(internalformat)
{
- case GL_STENCIL_INDEX8:
+ case GL_STENCIL_INDEX8_OES:
case GL_DEPTH24_STENCIL8_OES:
return true;
- case GL_RGBA4:
- case GL_RGB5_A1:
- case GL_RGB565:
+ case GL_RGBA4_OES:
+ case GL_RGB5_A1_OES:
+ case GL_RGB565_OES:
case GL_RGB8_OES:
case GL_RGBA8_OES:
- case GL_DEPTH_COMPONENT16:
+ case GL_DEPTH_COMPONENT16_OES:
return false;
default:
UNIMPLEMENTED();
@@ -497,10 +299,6 @@
case GL_ONE_MINUS_SRC_ALPHA: return sw::BLEND_INVSOURCEALPHA;
case GL_DST_ALPHA: return sw::BLEND_DESTALPHA;
case GL_ONE_MINUS_DST_ALPHA: return sw::BLEND_INVDESTALPHA;
- case GL_CONSTANT_COLOR: return sw::BLEND_CONSTANT;
- case GL_ONE_MINUS_CONSTANT_COLOR: return sw::BLEND_INVCONSTANT;
- case GL_CONSTANT_ALPHA: return sw::BLEND_CONSTANTALPHA;
- case GL_ONE_MINUS_CONSTANT_ALPHA: return sw::BLEND_INVCONSTANTALPHA;
case GL_SRC_ALPHA_SATURATE: return sw::BLEND_SRCALPHASAT;
default: UNREACHABLE();
}
@@ -512,11 +310,11 @@
{
switch(blendOp)
{
- case GL_FUNC_ADD: return sw::BLENDOP_ADD;
- case GL_FUNC_SUBTRACT: return sw::BLENDOP_SUB;
- case GL_FUNC_REVERSE_SUBTRACT: return sw::BLENDOP_INVSUB;
- case GL_MIN_EXT: return sw::BLENDOP_MIN;
- case GL_MAX_EXT: return sw::BLENDOP_MAX;
+ case GL_FUNC_ADD_OES: return sw::BLENDOP_ADD;
+ case GL_FUNC_SUBTRACT_OES: return sw::BLENDOP_SUB;
+ case GL_FUNC_REVERSE_SUBTRACT_OES: return sw::BLENDOP_INVSUB;
+ case GL_MIN_EXT: return sw::BLENDOP_MIN;
+ case GL_MAX_EXT: return sw::BLENDOP_MAX;
default: UNREACHABLE();
}
@@ -527,14 +325,14 @@
{
switch(stencilOp)
{
- case GL_ZERO: return sw::OPERATION_ZERO;
- case GL_KEEP: return sw::OPERATION_KEEP;
- case GL_REPLACE: return sw::OPERATION_REPLACE;
- case GL_INCR: return sw::OPERATION_INCRSAT;
- case GL_DECR: return sw::OPERATION_DECRSAT;
- case GL_INVERT: return sw::OPERATION_INVERT;
- case GL_INCR_WRAP: return sw::OPERATION_INCR;
- case GL_DECR_WRAP: return sw::OPERATION_DECR;
+ case GL_ZERO: return sw::OPERATION_ZERO;
+ case GL_KEEP: return sw::OPERATION_KEEP;
+ case GL_REPLACE: return sw::OPERATION_REPLACE;
+ case GL_INCR: return sw::OPERATION_INCRSAT;
+ case GL_DECR: return sw::OPERATION_DECRSAT;
+ case GL_INVERT: return sw::OPERATION_INVERT;
+ case GL_INCR_WRAP_OES: return sw::OPERATION_INCR;
+ case GL_DECR_WRAP_OES: return sw::OPERATION_DECR;
default: UNREACHABLE();
}
@@ -545,9 +343,9 @@
{
switch(wrap)
{
- case GL_REPEAT: return sw::ADDRESSING_WRAP;
- case GL_CLAMP_TO_EDGE: return sw::ADDRESSING_CLAMP;
- case GL_MIRRORED_REPEAT: return sw::ADDRESSING_MIRROR;
+ case GL_REPEAT: return sw::ADDRESSING_WRAP;
+ case GL_CLAMP_TO_EDGE: return sw::ADDRESSING_CLAMP;
+ case GL_MIRRORED_REPEAT_OES: return sw::ADDRESSING_MIRROR;
default: UNREACHABLE();
}
@@ -673,13 +471,13 @@
{
switch(format)
{
- case GL_RGBA4:
- case GL_RGB5_A1:
+ case GL_RGBA4_OES:
+ case GL_RGB5_A1_OES:
case GL_RGBA8_OES: return sw::FORMAT_A8R8G8B8;
- case GL_RGB565: return sw::FORMAT_R5G6B5;
+ case GL_RGB565_OES: return sw::FORMAT_R5G6B5;
case GL_RGB8_OES: return sw::FORMAT_X8R8G8B8;
- case GL_DEPTH_COMPONENT16:
- case GL_STENCIL_INDEX8:
+ case GL_DEPTH_COMPONENT16_OES:
+ case GL_STENCIL_INDEX8_OES:
case GL_DEPTH24_STENCIL8_OES: return sw::FORMAT_D24S8;
default: UNREACHABLE(); return sw::FORMAT_A8R8G8B8;
}
@@ -823,16 +621,16 @@
{
switch(format)
{
- case sw::FORMAT_A4R4G4B4: return GL_RGBA4;
+ case sw::FORMAT_A4R4G4B4: return GL_RGBA4_OES;
case sw::FORMAT_A8R8G8B8: return GL_RGBA8_OES;
- case sw::FORMAT_A1R5G5B5: return GL_RGB5_A1;
- case sw::FORMAT_R5G6B5: return GL_RGB565;
+ case sw::FORMAT_A1R5G5B5: return GL_RGB5_A1_OES;
+ case sw::FORMAT_R5G6B5: return GL_RGB565_OES;
case sw::FORMAT_X8R8G8B8: return GL_RGB8_OES;
default:
UNREACHABLE();
}
- return GL_RGBA4;
+ return GL_RGBA4_OES;
}
GLenum ConvertDepthStencilFormat(sw::Format format)
@@ -842,7 +640,7 @@
case sw::FORMAT_D16:
case sw::FORMAT_D24X8:
case sw::FORMAT_D32:
- return GL_DEPTH_COMPONENT16;
+ return GL_DEPTH_COMPONENT16_OES;
case sw::FORMAT_D24S8:
return GL_DEPTH24_STENCIL8_OES;
default:
diff --git a/src/GLES2/libGLES_CM/utilities.h b/src/GLES2/libGLES_CM/utilities.h
index 8475050..9a52ae3 100644
--- a/src/GLES2/libGLES_CM/utilities.h
+++ b/src/GLES2/libGLES_CM/utilities.h
@@ -11,16 +11,17 @@
// utilities.h: Conversion functions and other utility routines.
-#ifndef LIBGLESV2_UTILITIES_H
-#define LIBGLESV2_UTILITIES_H
+#ifndef LIBGLES_CM_UTILITIES_H
+#define LIBGLES_CM_UTILITIES_H
#include "Device.hpp"
#include "Image.hpp"
#include "Texture.h"
-#define GL_APICALL
-#include <GLES2/gl2.h>
-#include <GLES2/gl2ext.h>
+#define GL_API
+#include <GLES/gl.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GLES/glext.h>
#include <string>
@@ -28,14 +29,6 @@
{
struct Color;
- int UniformComponentCount(GLenum type);
- GLenum UniformComponentType(GLenum type);
- size_t UniformTypeSize(GLenum type);
- int VariableRowCount(GLenum type);
- int VariableColumnCount(GLenum type);
-
- int AllocateFirstFreeBits(unsigned int *bits, unsigned int allocationSize, unsigned int bitsSize);
-
int ComputePixelSize(GLenum format, GLenum type);
GLsizei ComputePitch(GLsizei width, GLenum format, GLenum type, GLint alignment);
GLsizei ComputeCompressedPitch(GLsizei width, GLenum format);
@@ -83,4 +76,4 @@
GLenum ConvertDepthStencilFormat(sw::Format format);
}
-#endif // LIBGLESV2_UTILITIES_H
+#endif // LIBGLES_CM_UTILITIES_H