Commit 11157826 by Nicolas Capens Committed by Nicolas Capens

Add ES1 stubs and remove ES2-only functions.

BUG=18110152 Change-Id: Iecebf951fe708d3f47ca6c821f448d6bbbfe0abc Reviewed-on: https://swiftshader-review.googlesource.com/1235Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Tested-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent d2620712
......@@ -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 @@ class Buffer : public RefCountObject
}
#endif // LIBGLESV2_BUFFER_H_
#endif // LIBGLES_CM_BUFFER_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 TranslatedAttribute;
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 Stencilbuffer;
class DepthStencilbuffer;
class VertexDataManager;
class IndexDataManager;
class Fence;
class Query;
enum
{
......@@ -170,7 +164,6 @@ struct State
GLenum destBlendAlpha;
GLenum blendEquationRGB;
GLenum blendEquationAlpha;
Color blendColor;
bool stencilTest;
GLenum stencilFunc;
GLint stencilRef;
......@@ -179,13 +172,6 @@ struct State
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 @@ struct State
GLfloat lineWidth;
GLenum generateMipmapHint;
GLenum fragmentShaderDerivativeHint;
GLint viewportX;
GLint viewportY;
......@@ -222,14 +207,11 @@ struct State
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 @@ class Context
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 @@ class Context
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 @@ class Context
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 @@ class Context
// 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 @@ class Context
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 @@ class Context
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 @@ class Context
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 @@ class Context
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 @@ class Context
bool mInvalidFramebufferOperation;
bool mHasBeenCurrent;
unsigned int mAppliedProgramSerial;
// state caching flags
bool mDepthStateDirty;
......
......@@ -118,28 +118,6 @@ namespace gl
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 @@ namespace gl
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 @@ namespace gl
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 @@ namespace gl
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 @@ namespace gl
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 @@ namespace gl
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()
{
......
......@@ -59,13 +59,9 @@ namespace gl
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 @@ namespace gl
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 @@ namespace gl
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;
};
......
// 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;
}
}
}
// 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_
......@@ -24,9 +24,9 @@ namespace gl
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 @@ Renderbuffer *Framebuffer::lookupRenderbuffer(GLenum type, GLuint handle) const
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 @@ Renderbuffer *Framebuffer::lookupRenderbuffer(GLenum type, GLuint handle) const
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 @@ void Framebuffer::detachTexture(GLuint texture)
{
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 @@ GLuint Framebuffer::getStencilbufferHandle()
bool Framebuffer::hasStencil()
{
if(mStencilbufferType != GL_NONE)
if(mStencilbufferType != GL_NONE_OES)
{
Renderbuffer *stencilbufferObject = getStencilbuffer();
......@@ -229,25 +229,25 @@ GLenum Framebuffer::completeness(int &width, int &height, int &samples)
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 @@ GLenum Framebuffer::completeness(int &width, int &height, int &samples)
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 @@ GLenum Framebuffer::completeness(int &width, int &height, int &samples)
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 @@ GLenum Framebuffer::completeness(int &width, int &height, int &samples)
}
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 @@ GLenum Framebuffer::completeness(int &width, int &height, int &samples)
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 @@ GLenum Framebuffer::completeness(int &width, int &height, int &samples)
}
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 @@ GLenum Framebuffer::completeness(int &width, int &height, int &samples)
// 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 @@ DefaultFramebuffer::DefaultFramebuffer(Colorbuffer *colorbuffer, DepthStencilbuf
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;
}
}
......@@ -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 @@ public:
}
#endif // LIBGLESV2_FRAMEBUFFER_H_
#endif // LIBGLES_CM_FRAMEBUFFER_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 @@ class HandleAllocator
}
#endif // LIBGLESV2_HANDLEALLOCATOR_H_
#endif // LIBGLES_CM_HANDLEALLOCATOR_H_
......@@ -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 @@ namespace gl
{
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 @@ namespace gl
}
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 @@ namespace gl
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;
......
......@@ -14,8 +14,8 @@
#include "Renderer/Surface.hpp"
#define GL_APICALL
#include <GLES2/gl2.h>
#define GL_API
#include <GLES/gl.h>
namespace gl
{
......
......@@ -49,10 +49,6 @@ void copyIndices(GLenum type, const void *input, GLsizei count, void *output)
{
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 @@ void computeRange(GLenum type, const void *indices, GLsizei count, GLuint *minIn
{
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 @@ GLenum IndexDataManager::prepareIndexData(GLenum type, GLsizei count, Buffer *bu
{
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 @@ std::size_t IndexDataManager::typeSize(GLenum type)
{
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);
......
......@@ -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 @@ class IndexDataManager
}
#endif // LIBGLESV2_INDEXDATAMANAGER_H_
#endif // LIBGLES_CM_INDEXDATAMANAGER_H_
// 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_
// 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
}
}
// 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_
......@@ -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 @@ class BindingPointer : public RefCountObjectBindingPointer
}
#endif // LIBGLESV2_REFCOUNTOBJECT_H_
#endif // LIBGLES_CM_REFCOUNTOBJECT_H_
......@@ -134,74 +134,6 @@ GLsizei RenderbufferTexture2D::getSamples() const
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 @@ RenderbufferStorage::RenderbufferStorage()
{
mWidth = 0;
mHeight = 0;
format = GL_RGBA4;
format = GL_RGBA4_OES;
internalFormat = sw::FORMAT_A8R8G8B8;
mSamples = 0;
}
......@@ -510,9 +442,9 @@ Depthbuffer::Depthbuffer(Image *depthStencil) : DepthStencilbuffer(depthStencil)
{
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 @@ Depthbuffer::Depthbuffer(int width, int height, GLsizei samples) : DepthStencilb
{
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 @@ Stencilbuffer::Stencilbuffer(Image *depthStencil) : DepthStencilbuffer(depthSten
{
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 @@ Stencilbuffer::Stencilbuffer(int width, int height, GLsizei samples) : DepthSten
{
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
}
}
......
......@@ -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 @@ private:
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 @@ public:
};
}
#endif // LIBGLESV2_RENDERBUFFER_H_
#endif // LIBGLES_CM_RENDERBUFFER_H_
......@@ -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 @@ ResourceManager::~ResourceManager()
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 @@ GLuint ResourceManager::createBuffer()
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::deleteBuffer(GLuint buffer)
}
}
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 @@ Buffer *ResourceManager::getBuffer(unsigned int handle)
}
}
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 @@ Texture *ResourceManager::getTexture(unsigned int handle)
}
}
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 @@ void ResourceManager::checkTextureAllocation(GLuint texture, TextureType type)
{
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 @@ void ResourceManager::checkRenderbufferAllocation(GLuint renderbuffer)
{
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();
}
......
......@@ -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 @@ class ResourceManager
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 @@ class ResourceManager
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 @@ class ResourceManager
}
#endif // LIBGLESV2_RESOURCEMANAGER_H_
#endif // LIBGLES_CM_RESOURCEMANAGER_H_
// 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_
......@@ -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 @@ protected:
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 @@ public:
};
}
#endif // LIBGLESV2_TEXTURE_H_
#endif // LIBGLES_CM_TEXTURE_H_
......@@ -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 @@ GLenum VertexDataManager::prepareVertexData(GLint start, GLsizei count, Translat
}
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 @@ GLenum VertexDataManager::prepareVertexData(GLint start, GLsizei count, Translat
// 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)
{
// 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;
if(staticBuffer)
{
translated[i].vertexBuffer = staticBuffer;
translated[i].offset = start * attribs[i].stride() + attribs[i].mOffset;
translated[i].stride = attribs[i].stride();
}
else
{
Buffer *buffer = attribs[i].mBoundBuffer.get();
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;
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)
unsigned int streamOffset = writeAttributeData(mStreamingBuffer, start, count, attribs[i]);
if(streamOffset == -1)
{
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;
return GL_OUT_OF_MEMORY;
}
translated[i].count = attribs[i].mSize;
translated[i].normalized = attribs[i].mNormalized;
translated[i].vertexBuffer = mStreamingBuffer->getResource();
translated[i].offset = streamOffset;
translated[i].stride = attribs[i].typeSize();
}
else
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])
{
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;
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;
}
}
......
......@@ -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 @@ class VertexDataManager
}
#endif // LIBGLESV2_VERTEXDATAMANAGER_H_
#endif // LIBGLES_CM_VERTEXDATAMANAGER_H_
This source diff could not be displayed because it is too large. You can view the blob instead.
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
......
......@@ -70,13 +70,13 @@ BEGIN
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
......
......@@ -164,19 +164,15 @@ copy "$(OutDir)libGLES_CM.dll" "$(ProjectDir)..\..\..\lib\$(Configuration)\"</Co
<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 @@ copy "$(OutDir)libGLES_CM.dll" "$(ProjectDir)..\..\..\lib\$(Configuration)\"</Co
<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" />
......
......@@ -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>
......
......@@ -179,7 +179,7 @@ void error(GLenum errorCode)
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;
......
......@@ -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 @@ const T &error(GLenum errorCode, const T &returnValue)
return returnValue;
}
#endif // LIBGLESV2_MAIN_H_
#endif // LIBGLES_CM_MAIN_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 @@ inline unsigned int unorm(float x)
}
}
#endif // LIBGLESV2_MATHUTIL_H_
#endif // LIBGLES_CM_MATHUTIL_H_
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by libGLESv2.rc
// Used by libGLES_CM.rc
// Next default values for new objects
//
......
......@@ -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 @@ namespace gl
{
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 @@ namespace sw2es
GLenum ConvertDepthStencilFormat(sw::Format format);
}
#endif // LIBGLESV2_UTILITIES_H
#endif // LIBGLES_CM_UTILITIES_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment