Commit ae17152b by Nicolas Capens Committed by Nicolas Capens

Implement a Radiance prototype.

Bug 18591036 Change-Id: Ic9b58dd38073b32a8507842d5da8af3d8b260f43 Reviewed-on: https://swiftshader-review.googlesource.com/1325Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Tested-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent 3914bb4a
...@@ -47,32 +47,32 @@ namespace sw ...@@ -47,32 +47,32 @@ namespace sw
} }
} }
} }
#include "FrameBufferDD.hpp" #include "FrameBufferDD.hpp"
#include "FrameBufferGDI.hpp" #include "FrameBufferGDI.hpp"
#include "Common/Configurator.hpp" #include "Common/Configurator.hpp"
extern "C" extern "C"
{ {
sw::FrameBufferWin *createFrameBufferWin(HWND windowHandle, int width, int height, bool fullscreen, bool topLeftOrigin) sw::FrameBufferWin *createFrameBufferWin(HWND windowHandle, int width, int height, bool fullscreen, bool topLeftOrigin)
{ {
sw::Configurator ini("SwiftShader.ini"); sw::Configurator ini("SwiftShader.ini");
int api = ini.getInteger("Testing", "FrameBufferAPI", 0); int api = ini.getInteger("Testing", "FrameBufferAPI", 0);
if(api == 0 && topLeftOrigin) if(api == 0 && topLeftOrigin)
{ {
return new sw::FrameBufferDD(windowHandle, width, height, fullscreen, topLeftOrigin); return new sw::FrameBufferDD(windowHandle, width, height, fullscreen, topLeftOrigin);
} }
else else
{ {
return new sw::FrameBufferGDI(windowHandle, width, height, fullscreen, topLeftOrigin); return new sw::FrameBufferGDI(windowHandle, width, height, fullscreen, topLeftOrigin);
} }
return 0; return 0;
} }
sw::FrameBuffer *createFrameBuffer(HDC display, HWND window, int width, int height) sw::FrameBuffer *createFrameBuffer(HDC display, HWND window, int width, int height)
{ {
return createFrameBufferWin(window, width, height, false, false); return createFrameBufferWin(window, width, height, false, false);
} }
} }
...@@ -99,7 +99,7 @@ namespace sh ...@@ -99,7 +99,7 @@ namespace sh
this->registerIndex = registerIndex; this->registerIndex = registerIndex;
} }
OutputASM::OutputASM(TParseContext &context, rad::Shader *shaderObject) : TIntermTraverser(true, true, true), mContext(context), shaderObject(shaderObject) OutputASM::OutputASM(TParseContext &context, es2::Shader *shaderObject) : TIntermTraverser(true, true, true), mContext(context), shaderObject(shaderObject)
{ {
shader = 0; shader = 0;
pixelShader = 0; pixelShader = 0;
...@@ -2044,10 +2044,10 @@ namespace sh ...@@ -2044,10 +2044,10 @@ namespace sh
{ {
const TType &type = varying->getType(); const TType &type = varying->getType();
const char *name = varying->getAsSymbolNode()->getSymbol().c_str(); const char *name = varying->getAsSymbolNode()->getSymbol().c_str();
rad::VaryingList &activeVaryings = shaderObject->varyings; es2::VaryingList &activeVaryings = shaderObject->varyings;
// Check if this varying has been declared before without having a register assigned // Check if this varying has been declared before without having a register assigned
for(rad::VaryingList::iterator v = activeVaryings.begin(); v != activeVaryings.end(); v++) for(es2::VaryingList::iterator v = activeVaryings.begin(); v != activeVaryings.end(); v++)
{ {
if(v->name == name) if(v->name == name)
{ {
...@@ -2061,7 +2061,7 @@ namespace sh ...@@ -2061,7 +2061,7 @@ namespace sh
} }
} }
activeVaryings.push_back(rad::Varying(glVariableType(type), name, varying->getArraySize(), reg, 0)); activeVaryings.push_back(es2::Varying(glVariableType(type), name, varying->getArraySize(), reg, 0));
} }
} }
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#include <set> #include <set>
#include <map> #include <map>
namespace rad namespace es2
{ {
class Shader; class Shader;
} }
...@@ -81,7 +81,7 @@ namespace sh ...@@ -81,7 +81,7 @@ namespace sh
class OutputASM : public TIntermTraverser class OutputASM : public TIntermTraverser
{ {
public: public:
explicit OutputASM(TParseContext &context, rad::Shader *shaderObject); explicit OutputASM(TParseContext &context, es2::Shader *shaderObject);
~OutputASM(); ~OutputASM();
void output(); void output();
...@@ -145,7 +145,7 @@ namespace sh ...@@ -145,7 +145,7 @@ namespace sh
static unsigned int loopCount(TIntermLoop *node); static unsigned int loopCount(TIntermLoop *node);
static bool isSamplerRegister(TIntermTyped *operand); static bool isSamplerRegister(TIntermTyped *operand);
rad::Shader *const shaderObject; es2::Shader *const shaderObject;
sw::Shader *shader; sw::Shader *shader;
sw::PixelShader *pixelShader; sw::PixelShader *pixelShader;
sw::VertexShader *vertexShader; sw::VertexShader *vertexShader;
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
#include "InitializeParseContext.h" #include "InitializeParseContext.h"
TranslatorASM::TranslatorASM(rad::Shader *shaderObject, ShShaderType type, ShShaderSpec spec) : TCompiler(type, spec), shaderObject(shaderObject) TranslatorASM::TranslatorASM(es2::Shader *shaderObject, ShShaderType type, ShShaderSpec spec) : TCompiler(type, spec), shaderObject(shaderObject)
{ {
} }
......
...@@ -25,13 +25,13 @@ namespace rad ...@@ -25,13 +25,13 @@ namespace rad
class TranslatorASM : public TCompiler class TranslatorASM : public TCompiler
{ {
public: public:
TranslatorASM(rad::Shader *shaderObject, ShShaderType type, ShShaderSpec spec); TranslatorASM(es2::Shader *shaderObject, ShShaderType type, ShShaderSpec spec);
protected: protected:
virtual bool translate(TIntermNode* root); virtual bool translate(TIntermNode* root);
private: private:
rad::Shader *const shaderObject; es2::Shader *const shaderObject;
}; };
#endif // COMPILER_TRANSLATORASM_H_ #endif // COMPILER_TRANSLATORASM_H_
...@@ -137,6 +137,7 @@ typedef enum { ...@@ -137,6 +137,7 @@ typedef enum {
} RADtextureTarget; } RADtextureTarget;
typedef enum { typedef enum {
RAD_FORMAT_NONE = 0x000,
RAD_RGBA8 = 0x8058, RAD_RGBA8 = 0x8058,
RAD_DEPTH24_STENCIL8 = 0x88F0, RAD_DEPTH24_STENCIL8 = 0x88F0,
} RADinternalFormat; } RADinternalFormat;
...@@ -321,6 +322,7 @@ typedef enum { ...@@ -321,6 +322,7 @@ typedef enum {
} RADpolygonMode; } RADpolygonMode;
typedef enum { typedef enum {
RAD_POLYGON_OFFSET_NONE = 0x0000,
RAD_POLYGON_OFFSET_POINT = 0x0001, RAD_POLYGON_OFFSET_POINT = 0x0001,
RAD_POLYGON_OFFSET_LINE = 0x0002, RAD_POLYGON_OFFSET_LINE = 0x0002,
RAD_POLYGON_OFFSET_FILL = 0x0004, RAD_POLYGON_OFFSET_FILL = 0x0004,
......
...@@ -390,9 +390,9 @@ EGLContext Display::createContext(EGLConfig configHandle, const egl::Context *sh ...@@ -390,9 +390,9 @@ EGLContext Display::createContext(EGLConfig configHandle, const egl::Context *sh
if(clientVersion == 2 && config->mRenderableType & EGL_OPENGL_ES2_BIT) if(clientVersion == 2 && config->mRenderableType & EGL_OPENGL_ES2_BIT)
{ {
if(rad::createContext != 0) if(es2::createContext != 0)
{ {
context = rad::createContext(config, shareContext); context = es2::createContext(config, shareContext);
} }
} }
else else
......
...@@ -58,7 +58,7 @@ namespace egl ...@@ -58,7 +58,7 @@ namespace egl
EGLNativeDisplayType getNativeDisplay() const; EGLNativeDisplayType getNativeDisplay() const;
const char *getExtensionString() const; const char *getExtensionString() const;
private: public:
Display(EGLNativeDisplayType displayId); Display(EGLNativeDisplayType displayId);
DisplayMode getDisplayMode() const; DisplayMode getDisplayMode() const;
......
...@@ -132,7 +132,7 @@ bool Surface::reset(int backBufferWidth, int backBufferHeight) ...@@ -132,7 +132,7 @@ bool Surface::reset(int backBufferWidth, int backBufferHeight)
if(mWindow) if(mWindow)
{ {
frameBuffer = rad::createFrameBuffer(mDisplay->getNativeDisplay(), mWindow, backBufferWidth, backBufferHeight); frameBuffer = es2::createFrameBuffer(mDisplay->getNativeDisplay(), mWindow, backBufferWidth, backBufferHeight);
if(!frameBuffer) if(!frameBuffer)
{ {
...@@ -142,7 +142,7 @@ bool Surface::reset(int backBufferWidth, int backBufferHeight) ...@@ -142,7 +142,7 @@ bool Surface::reset(int backBufferWidth, int backBufferHeight)
} }
} }
backBuffer = rad::createBackBuffer(backBufferWidth, backBufferHeight, mConfig); backBuffer = es2::createBackBuffer(backBufferWidth, backBufferHeight, mConfig);
if(!backBuffer) if(!backBuffer)
{ {
...@@ -153,7 +153,7 @@ bool Surface::reset(int backBufferWidth, int backBufferHeight) ...@@ -153,7 +153,7 @@ bool Surface::reset(int backBufferWidth, int backBufferHeight)
if(mConfig->mDepthStencilFormat != sw::FORMAT_NULL) if(mConfig->mDepthStencilFormat != sw::FORMAT_NULL)
{ {
mDepthStencil = rad::createDepthStencil(backBufferWidth, backBufferHeight, mConfig->mDepthStencilFormat, 1, false); mDepthStencil = es2::createDepthStencil(backBufferWidth, backBufferHeight, mConfig->mDepthStencilFormat, 1, false);
if(!mDepthStencil) if(!mDepthStencil)
{ {
......
...@@ -61,7 +61,7 @@ public: ...@@ -61,7 +61,7 @@ public:
bool checkForResize(); // Returns true if surface changed due to resize bool checkForResize(); // Returns true if surface changed due to resize
private: public:
void release(); void release();
bool reset(); bool reset();
......
...@@ -90,11 +90,11 @@ CONSTRUCTOR static bool eglAttachProcess() ...@@ -90,11 +90,11 @@ CONSTRUCTOR static bool eglAttachProcess()
#endif #endif
libRAD = loadLibrary(libRAD_lib); libRAD = loadLibrary(libRAD_lib);
rad::createContext = (egl::Context *(*)(const egl::Config*, const egl::Context*))getProcAddress(libRAD, "glCreateContext"); es2::createContext = (egl::Context *(*)(const egl::Config*, const egl::Context*))getProcAddress(libRAD, "glCreateContext");
rad::getProcAddress = (__eglMustCastToProperFunctionPointerType (RADAPIENTRY *)(const char*))getProcAddress(libRAD, "radGetProcAddress"); rad::getProcAddress = (__eglMustCastToProperFunctionPointerType (RADAPIENTRY *)(const char*))getProcAddress(libRAD, "radGetProcAddress");
rad::createBackBuffer = (egl::Image *(*)(int, int, const egl::Config*))getProcAddress(libRAD, "createBackBuffer"); es2::createBackBuffer = (egl::Image *(*)(int, int, const egl::Config*))getProcAddress(libRAD, "createBackBuffer");
rad::createDepthStencil = (egl::Image *(*)(unsigned int, unsigned int, sw::Format, int, bool))getProcAddress(libRAD, "createDepthStencil"); es2::createDepthStencil = (egl::Image *(*)(unsigned int, unsigned int, sw::Format, int, bool))getProcAddress(libRAD, "createDepthStencil");
rad::createFrameBuffer = (sw::FrameBuffer *(*)(EGLNativeDisplayType, EGLNativeWindowType, int, int))getProcAddress(libRAD, "createFrameBuffer"); es2::createFrameBuffer = (sw::FrameBuffer *(*)(EGLNativeDisplayType, EGLNativeWindowType, int, int))getProcAddress(libRAD, "createFrameBuffer");
return libRAD != 0; return libRAD != 0;
} }
...@@ -313,14 +313,18 @@ EGLContext clientGetCurrentDisplay() ...@@ -313,14 +313,18 @@ EGLContext clientGetCurrentDisplay()
} }
} }
namespace rad namespace es2
{ {
egl::Context *(*createContext)(const egl::Config *config, const egl::Context *shareContext) = 0; egl::Context *(*createContext)(const egl::Config *config, const egl::Context *shareContext) = 0;
__eglMustCastToProperFunctionPointerType (RADAPIENTRY *getProcAddress)(const char *procname) = 0;
egl::Image *(*createBackBuffer)(int width, int height, const egl::Config *config) = 0; egl::Image *(*createBackBuffer)(int width, int height, const egl::Config *config) = 0;
egl::Image *(*createDepthStencil)(unsigned int width, unsigned int height, sw::Format format, int multiSampleDepth, bool discard) = 0; egl::Image *(*createDepthStencil)(unsigned int width, unsigned int height, sw::Format format, int multiSampleDepth, bool discard) = 0;
sw::FrameBuffer *(*createFrameBuffer)(EGLNativeDisplayType display, EGLNativeWindowType window, int width, int height) = 0; sw::FrameBuffer *(*createFrameBuffer)(EGLNativeDisplayType display, EGLNativeWindowType window, int width, int height) = 0;
} }
namespace rad
{
__eglMustCastToProperFunctionPointerType (RADAPIENTRY *getProcAddress)(const char *procname) = 0;
}
void *libRAD = 0; // Handle to the libRAD module void *libRAD = 0; // Handle to the libRAD module
...@@ -84,16 +84,20 @@ namespace sw ...@@ -84,16 +84,20 @@ namespace sw
} }
// libRAD dependencies // libRAD dependencies
namespace rad namespace es2
{ {
extern egl::Context *(*createContext)(const egl::Config *config, const egl::Context *shareContext); extern egl::Context *(*createContext)(const egl::Config *config, const egl::Context *shareContext);
extern __eglMustCastToProperFunctionPointerType (RADAPIENTRY *getProcAddress)(const char *procname);
extern egl::Image *(*createBackBuffer)(int width, int height, const egl::Config *config); extern egl::Image *(*createBackBuffer)(int width, int height, const egl::Config *config);
extern egl::Image *(*createDepthStencil)(unsigned int width, unsigned int height, sw::Format format, int multiSampleDepth, bool discard); extern egl::Image *(*createDepthStencil)(unsigned int width, unsigned int height, sw::Format format, int multiSampleDepth, bool discard);
extern sw::FrameBuffer *(*createFrameBuffer)(EGLNativeDisplayType display, EGLNativeWindowType window, int width, int height); extern sw::FrameBuffer *(*createFrameBuffer)(EGLNativeDisplayType display, EGLNativeWindowType window, int width, int height);
} }
namespace rad
{
extern __eglMustCastToProperFunctionPointerType (RADAPIENTRY *getProcAddress)(const char *procname);
}
extern void *libRAD; // Handle to the libRAD module extern void *libRAD; // Handle to the libRAD module
#endif // LIBEGL_MAIN_H_ #endif // LIBEGL_MAIN_H_
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
#include "VertexDataManager.h" #include "VertexDataManager.h"
#include "IndexDataManager.h" #include "IndexDataManager.h"
namespace rad namespace es2
{ {
Buffer::Buffer(GLuint id) : RefCountObject(id) Buffer::Buffer(GLuint id) : RefCountObject(id)
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#include <cstddef> #include <cstddef>
#include <vector> #include <vector>
namespace rad namespace es2
{ {
class Buffer : public RefCountObject class Buffer : public RefCountObject
{ {
...@@ -43,7 +43,7 @@ class Buffer : public RefCountObject ...@@ -43,7 +43,7 @@ class Buffer : public RefCountObject
sw::Resource *getResource(); sw::Resource *getResource();
private: public:
sw::Resource *mContents; sw::Resource *mContents;
size_t mSize; size_t mSize;
GLenum mUsage; GLenum mUsage;
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
// or implied, including but not limited to any patent rights, are granted to you. // or implied, including but not limited to any patent rights, are granted to you.
// //
// Context.cpp: Implements the rad::Context class, managing all GL state and performing // Context.cpp: Implements the es2::Context class, managing all GL state and performing
// rendering operations. It is the GLES2 specific implementation of EGLContext. // rendering operations. It is the GLES2 specific implementation of EGLContext.
#include "Context.h" #include "Context.h"
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
#undef near #undef near
#undef far #undef far
namespace rad namespace es2
{ {
Device *Context::device = 0; Device *Context::device = 0;
...@@ -1157,7 +1157,8 @@ Buffer *Context::getElementArrayBuffer() ...@@ -1157,7 +1157,8 @@ Buffer *Context::getElementArrayBuffer()
Program *Context::getCurrentProgram() Program *Context::getCurrentProgram()
{ {
return mResourceManager->getProgram(mState.currentProgram); return mState.program;
//return mResourceManager->getProgram(mState.currentProgram);
} }
Texture2D *Context::getTexture2D() Texture2D *Context::getTexture2D()
...@@ -1678,13 +1679,13 @@ bool Context::applyRenderTarget() ...@@ -1678,13 +1679,13 @@ bool Context::applyRenderTarget()
return error(GL_INVALID_FRAMEBUFFER_OPERATION, false); return error(GL_INVALID_FRAMEBUFFER_OPERATION, false);
} }
egl::Image *renderTarget = framebuffer->getRenderTarget(); egl::Image *renderTarget = mState.colorBuffer;//framebuffer->getRenderTarget();
device->setRenderTarget(renderTarget); device->setRenderTarget(renderTarget);
if(renderTarget) renderTarget->release(); //if(renderTarget) renderTarget->release();
egl::Image *depthStencil = framebuffer->getDepthStencil(); egl::Image *depthStencil = mState.depthBuffer;//framebuffer->getDepthStencil();
device->setDepthStencilSurface(depthStencil); device->setDepthStencilSurface(depthStencil);
if(depthStencil) depthStencil->release(); //if(depthStencil) depthStencil->release();
Viewport viewport; Viewport viewport;
float zNear = clamp01(mState.zNear); float zNear = clamp01(mState.zNear);
...@@ -2069,19 +2070,38 @@ void Context::applyTextures(sw::SamplerType samplerType) ...@@ -2069,19 +2070,38 @@ void Context::applyTextures(sw::SamplerType samplerType)
void Context::applyTexture(sw::SamplerType type, int index, Texture *baseTexture) void Context::applyTexture(sw::SamplerType type, int index, Texture *baseTexture)
{ {
Program *program = getCurrentProgram(); //Program *program = getCurrentProgram();
int sampler = (type == sw::SAMPLER_PIXEL) ? index : 16 + index; int sampler = (type == sw::SAMPLER_PIXEL) ? index : 16 + index;
bool textureUsed = false; bool textureUsed = true;
//if(type == sw::SAMPLER_PIXEL)
//{
// textureUsed = program->getPixelShader()->usesSampler(index);
//}
//else if(type == sw::SAMPLER_VERTEX)
//{
// textureUsed = program->getVertexShader()->usesSampler(index);
//}
//else UNREACHABLE();
// GLenum wrapS = baseTexture->getWrapS();
// GLenum wrapT = baseTexture->getWrapT();
// GLenum texFilter = baseTexture->getMinFilter();
// GLenum magFilter = baseTexture->getMagFilter();
// GLenum maxAnisotropy = baseTexture->getMaxAnisotropy();
//
// device->setAddressingModeU(type, index, rad2sw::ConvertTextureWrap(wrapS));
// device->setAddressingModeV(type, index, rad2sw::ConvertTextureWrap(wrapT));
//
// sw::FilterType minFilter;
// sw::MipmapType mipFilter;
// rad2sw::ConvertMinFilter(texFilter, &minFilter, &mipFilter, maxAnisotropy);
//// ASSERT(minFilter == rad2sw::ConvertMagFilter(magFilter));
if(type == sw::SAMPLER_PIXEL) device->setTextureFilter(type, index, sw::FILTER_LINEAR);
{ // device->setTextureFilter(type, index, rad2sw::ConvertMagFilter(magFilter));
textureUsed = program->getPixelShader()->usesSampler(index); device->setMipmapFilter(type, index, sw::MIPMAP_NONE);
} device->setMaxAnisotropy(type, index, 1.0f);
else if(type == sw::SAMPLER_VERTEX)
{
textureUsed = program->getVertexShader()->usesSampler(index);
}
else UNREACHABLE();
sw::Resource *resource = 0; sw::Resource *resource = 0;
...@@ -2457,7 +2477,7 @@ void Context::drawArrays(GLenum mode, GLint first, GLsizei count) ...@@ -2457,7 +2477,7 @@ void Context::drawArrays(GLenum mode, GLint first, GLsizei count)
void Context::drawElements(GLenum mode, GLsizei count, GLenum type, const void *indices) void Context::drawElements(GLenum mode, GLsizei count, GLenum type, const void *indices)
{ {
if(!mState.currentProgram) if(!mState.currentProgram && !mState.program)
{ {
return error(GL_INVALID_OPERATION); return error(GL_INVALID_OPERATION);
} }
...@@ -2500,7 +2520,7 @@ void Context::drawElements(GLenum mode, GLsizei count, GLenum type, const void * ...@@ -2500,7 +2520,7 @@ void Context::drawElements(GLenum mode, GLsizei count, GLenum type, const void *
} }
applyShaders(); applyShaders();
applyTextures(); //applyTextures();
if(!getCurrentProgram()->validateSamplers(false)) if(!getCurrentProgram()->validateSamplers(false))
{ {
...@@ -3020,7 +3040,7 @@ void Context::blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1 ...@@ -3020,7 +3040,7 @@ void Context::blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1
void Context::bindTexImage(egl::Surface *surface) void Context::bindTexImage(egl::Surface *surface)
{ {
rad::Texture2D *textureObject = getTexture2D(); es2::Texture2D *textureObject = getTexture2D();
if(textureObject) if(textureObject)
{ {
...@@ -3051,14 +3071,14 @@ EGLenum Context::validateSharedImage(EGLenum target, GLuint name, GLuint texture ...@@ -3051,14 +3071,14 @@ EGLenum Context::validateSharedImage(EGLenum target, GLuint name, GLuint texture
return EGL_BAD_PARAMETER; return EGL_BAD_PARAMETER;
} }
if(textureLevel >= rad::IMPLEMENTATION_MAX_TEXTURE_LEVELS) if(textureLevel >= es2::IMPLEMENTATION_MAX_TEXTURE_LEVELS)
{ {
return EGL_BAD_MATCH; return EGL_BAD_MATCH;
} }
if(textureTarget != GL_NONE) if(textureTarget != GL_NONE)
{ {
rad::Texture *texture = getTexture(name); es2::Texture *texture = getTexture(name);
if(!texture || texture->getTarget() != textureTarget) if(!texture || texture->getTarget() != textureTarget)
{ {
...@@ -3082,7 +3102,7 @@ EGLenum Context::validateSharedImage(EGLenum target, GLuint name, GLuint texture ...@@ -3082,7 +3102,7 @@ EGLenum Context::validateSharedImage(EGLenum target, GLuint name, GLuint texture
} }
else if(target == EGL_GL_RENDERBUFFER_KHR) else if(target == EGL_GL_RENDERBUFFER_KHR)
{ {
rad::Renderbuffer *renderbuffer = getRenderbuffer(name); es2::Renderbuffer *renderbuffer = getRenderbuffer(name);
if(!renderbuffer) if(!renderbuffer)
{ {
...@@ -3116,13 +3136,13 @@ egl::Image *Context::createSharedImage(EGLenum target, GLuint name, GLuint textu ...@@ -3116,13 +3136,13 @@ egl::Image *Context::createSharedImage(EGLenum target, GLuint name, GLuint textu
if(textureTarget != GL_NONE) if(textureTarget != GL_NONE)
{ {
rad::Texture *texture = getTexture(name); es2::Texture *texture = getTexture(name);
return texture->createSharedImage(textureTarget, textureLevel); return texture->createSharedImage(textureTarget, textureLevel);
} }
else if(target == EGL_GL_RENDERBUFFER_KHR) else if(target == EGL_GL_RENDERBUFFER_KHR)
{ {
rad::Renderbuffer *renderbuffer = getRenderbuffer(name); es2::Renderbuffer *renderbuffer = getRenderbuffer(name);
return renderbuffer->createSharedImage(); return renderbuffer->createSharedImage();
} }
...@@ -3136,7 +3156,7 @@ Device *Context::getDevice() ...@@ -3136,7 +3156,7 @@ Device *Context::getDevice()
if(!device) if(!device)
{ {
sw::Context *context = new sw::Context(); sw::Context *context = new sw::Context();
device = new rad::Device(context); device = new es2::Device(context);
} }
return device; return device;
...@@ -3147,8 +3167,8 @@ Device *Context::getDevice() ...@@ -3147,8 +3167,8 @@ Device *Context::getDevice()
// Exported functions for use by EGL // Exported functions for use by EGL
extern "C" extern "C"
{ {
rad::Context *glCreateContext(const egl::Config *config, const rad::Context *shareContext) es2::Context *glCreateContext(const egl::Config *config, const es2::Context *shareContext)
{ {
return new rad::Context(config, shareContext); return new es2::Context(config, shareContext);
} }
} }
...@@ -38,7 +38,7 @@ class Surface; ...@@ -38,7 +38,7 @@ class Surface;
class Config; class Config;
} }
namespace rad namespace es2
{ {
struct TranslatedAttribute; struct TranslatedAttribute;
struct TranslatedIndexData; struct TranslatedIndexData;
...@@ -228,6 +228,10 @@ struct State ...@@ -228,6 +228,10 @@ struct State
GLuint drawFramebuffer; GLuint drawFramebuffer;
BindingPointer<Renderbuffer> renderbuffer; BindingPointer<Renderbuffer> renderbuffer;
GLuint currentProgram; GLuint currentProgram;
Program *program;
egl::Image *colorBuffer;
egl::Image *depthBuffer;
VertexAttribute vertexAttribute[MAX_VERTEX_ATTRIBS]; VertexAttribute vertexAttribute[MAX_VERTEX_ATTRIBS];
BindingPointer<Texture> samplerTexture[TEXTURE_TYPE_COUNT][MAX_COMBINED_TEXTURE_IMAGE_UNITS]; BindingPointer<Texture> samplerTexture[TEXTURE_TYPE_COUNT][MAX_COMBINED_TEXTURE_IMAGE_UNITS];
...@@ -426,7 +430,7 @@ public: ...@@ -426,7 +430,7 @@ public:
Device *getDevice(); Device *getDevice();
private: public:
virtual ~Context(); virtual ~Context();
bool applyRenderTarget(); bool applyRenderTarget();
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
bool localShaderConstants = false; bool localShaderConstants = false;
namespace rad namespace es2
{ {
using namespace sw; using namespace sw;
......
...@@ -19,7 +19,7 @@ namespace egl ...@@ -19,7 +19,7 @@ namespace egl
class Image; class Image;
} }
namespace rad namespace es2
{ {
class Texture; class Texture;
class Image; class Image;
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
#include "main.h" #include "main.h"
#include "Common/Thread.hpp" #include "Common/Thread.hpp"
namespace rad namespace es2
{ {
Fence::Fence() Fence::Fence()
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
#define GL_APICALL #define GL_APICALL
#include <GLES2/gl2.h> #include <GLES2/gl2.h>
namespace rad namespace es2
{ {
class Fence class Fence
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
#include "Texture.h" #include "Texture.h"
#include "utilities.h" #include "utilities.h"
namespace rad namespace es2
{ {
Framebuffer::Framebuffer() Framebuffer::Framebuffer()
...@@ -245,7 +245,7 @@ GLenum Framebuffer::completeness(int &width, int &height, int &samples) ...@@ -245,7 +245,7 @@ GLenum Framebuffer::completeness(int &width, int &height, int &samples)
if(mColorbufferType == GL_RENDERBUFFER) if(mColorbufferType == GL_RENDERBUFFER)
{ {
if(!rad::IsColorRenderable(colorbuffer->getFormat())) if(!es2::IsColorRenderable(colorbuffer->getFormat()))
{ {
return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
} }
...@@ -262,7 +262,7 @@ GLenum Framebuffer::completeness(int &width, int &height, int &samples) ...@@ -262,7 +262,7 @@ GLenum Framebuffer::completeness(int &width, int &height, int &samples)
return GL_FRAMEBUFFER_UNSUPPORTED; return GL_FRAMEBUFFER_UNSUPPORTED;
} }
if(rad::IsDepthTexture(format) || rad::IsStencilTexture(format)) if(es2::IsDepthTexture(format) || es2::IsStencilTexture(format))
{ {
return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
} }
...@@ -297,14 +297,14 @@ GLenum Framebuffer::completeness(int &width, int &height, int &samples) ...@@ -297,14 +297,14 @@ GLenum Framebuffer::completeness(int &width, int &height, int &samples)
if(mDepthbufferType == GL_RENDERBUFFER) if(mDepthbufferType == GL_RENDERBUFFER)
{ {
if(!rad::IsDepthRenderable(depthbuffer->getFormat())) if(!es2::IsDepthRenderable(depthbuffer->getFormat()))
{ {
return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
} }
} }
else if(IsTextureTarget(mDepthbufferType)) else if(IsTextureTarget(mDepthbufferType))
{ {
if(!rad::IsDepthTexture(depthbuffer->getFormat())) if(!es2::IsDepthTexture(depthbuffer->getFormat()))
{ {
return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
} }
...@@ -347,7 +347,7 @@ GLenum Framebuffer::completeness(int &width, int &height, int &samples) ...@@ -347,7 +347,7 @@ GLenum Framebuffer::completeness(int &width, int &height, int &samples)
if(mStencilbufferType == GL_RENDERBUFFER) if(mStencilbufferType == GL_RENDERBUFFER)
{ {
if(!rad::IsStencilRenderable(stencilbuffer->getFormat())) if(!es2::IsStencilRenderable(stencilbuffer->getFormat()))
{ {
return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
} }
...@@ -356,7 +356,7 @@ GLenum Framebuffer::completeness(int &width, int &height, int &samples) ...@@ -356,7 +356,7 @@ GLenum Framebuffer::completeness(int &width, int &height, int &samples)
{ {
GLenum internalformat = stencilbuffer->getFormat(); GLenum internalformat = stencilbuffer->getFormat();
if(!rad::IsStencilTexture(internalformat)) if(!es2::IsStencilTexture(internalformat))
{ {
return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
} }
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
#define GL_APICALL #define GL_APICALL
#include <GLES2/gl2.h> #include <GLES2/gl2.h>
namespace rad namespace es2
{ {
class Renderbuffer; class Renderbuffer;
class Colorbuffer; class Colorbuffer;
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
#include "main.h" #include "main.h"
namespace rad namespace es2
{ {
HandleAllocator::HandleAllocator() : mBaseValue(1), mNextValue(1) HandleAllocator::HandleAllocator() : mBaseValue(1), mNextValue(1)
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#include <vector> #include <vector>
namespace rad namespace es2
{ {
class HandleAllocator class HandleAllocator
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
#include <GLES2/gl2ext.h> #include <GLES2/gl2ext.h>
namespace rad namespace es2
{ {
static sw::Resource *getParentResource(Texture *texture) static sw::Resource *getParentResource(Texture *texture)
{ {
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
#define GL_APICALL #define GL_APICALL
#include <GLES2/gl2.h> #include <GLES2/gl2.h>
namespace rad namespace es2
{ {
class Texture; class Texture;
......
...@@ -25,7 +25,7 @@ namespace ...@@ -25,7 +25,7 @@ namespace
enum { INITIAL_INDEX_BUFFER_SIZE = 4096 * sizeof(GLuint) }; enum { INITIAL_INDEX_BUFFER_SIZE = 4096 * sizeof(GLuint) };
} }
namespace rad namespace es2
{ {
IndexDataManager::IndexDataManager() IndexDataManager::IndexDataManager()
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#define GL_APICALL #define GL_APICALL
#include <GLES2/gl2.h> #include <GLES2/gl2.h>
namespace rad namespace es2
{ {
struct TranslatedIndexData struct TranslatedIndexData
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#include <string> #include <string>
#include <stdlib.h> #include <stdlib.h>
namespace rad namespace es2
{ {
unsigned int Program::currentSerial = 1; unsigned int Program::currentSerial = 1;
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#include <vector> #include <vector>
#include <set> #include <set>
namespace rad namespace es2
{ {
class Device; class Device;
class ResourceManager; class ResourceManager;
...@@ -163,7 +163,7 @@ namespace rad ...@@ -163,7 +163,7 @@ namespace rad
static unsigned int issueSerial(); static unsigned int issueSerial();
private: private:
rad::Device *device; es2::Device *device;
FragmentShader *fragmentShader; FragmentShader *fragmentShader;
VertexShader *vertexShader; VertexShader *vertexShader;
......
...@@ -9,14 +9,14 @@ ...@@ -9,14 +9,14 @@
// or implied, including but not limited to any patent rights, are granted to you. // or implied, including but not limited to any patent rights, are granted to you.
// //
// Query.cpp: Implements the rad::Query class // Query.cpp: Implements the es2::Query class
#include "Query.h" #include "Query.h"
#include "main.h" #include "main.h"
#include "Common/Thread.hpp" #include "Common/Thread.hpp"
namespace rad namespace es2
{ {
Query::Query(GLuint id, GLenum type) : RefCountObject(id) Query::Query(GLuint id, GLenum type) : RefCountObject(id)
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
// or implied, including but not limited to any patent rights, are granted to you. // or implied, including but not limited to any patent rights, are granted to you.
// //
// Query.h: Defines the rad::Query class // Query.h: Defines the es2::Query class
#ifndef LIBGLESV2_QUERY_H_ #ifndef LIBGLESV2_QUERY_H_
#define LIBGLESV2_QUERY_H_ #define LIBGLESV2_QUERY_H_
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#define GL_APICALL #define GL_APICALL
#include <GLES2/gl2.h> #include <GLES2/gl2.h>
namespace rad namespace es2
{ {
class Query : public RefCountObject class Query : public RefCountObject
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
#include "Common/Thread.hpp" #include "Common/Thread.hpp"
namespace rad namespace es2
{ {
RefCountObject::RefCountObject(GLuint id) RefCountObject::RefCountObject(GLuint id)
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#include <cstddef> #include <cstddef>
namespace rad namespace es2
{ {
class RefCountObject class RefCountObject
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
#include "Texture.h" #include "Texture.h"
#include "utilities.h" #include "utilities.h"
namespace rad namespace es2
{ {
RenderbufferInterface::RenderbufferInterface() RenderbufferInterface::RenderbufferInterface()
{ {
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#define GL_APICALL #define GL_APICALL
#include <GLES2/gl2.h> #include <GLES2/gl2.h>
namespace rad namespace es2
{ {
class Texture2D; class Texture2D;
class TextureCubeMap; class TextureCubeMap;
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#include "Shader.h" #include "Shader.h"
#include "Texture.h" #include "Texture.h"
namespace rad namespace es2
{ {
ResourceManager::ResourceManager() ResourceManager::ResourceManager()
{ {
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#include <map> #include <map>
namespace rad namespace es2
{ {
class Buffer; class Buffer;
class Shader; class Shader;
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#include <string> #include <string>
namespace rad namespace es2
{ {
bool Shader::compilerInitialized = false; bool Shader::compilerInitialized = false;
......
...@@ -32,7 +32,7 @@ namespace sh ...@@ -32,7 +32,7 @@ namespace sh
class OutputASM; class OutputASM;
} }
namespace rad namespace es2
{ {
struct Varying struct Varying
{ {
...@@ -46,7 +46,7 @@ struct Varying ...@@ -46,7 +46,7 @@ struct Varying
return arraySize >= 1; return arraySize >= 1;
} }
int size() const // Unify with rad::Uniform? int size() const // Unify with es2::Uniform?
{ {
return arraySize > 0 ? arraySize : 1; return arraySize > 0 ? arraySize : 1;
} }
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#include <algorithm> #include <algorithm>
namespace rad namespace es2
{ {
Texture::Texture(GLuint id) : RefCountObject(id) Texture::Texture(GLuint id) : RefCountObject(id)
...@@ -376,7 +376,7 @@ sw::Format Texture2D::getInternalFormat(GLenum target, GLint level) const ...@@ -376,7 +376,7 @@ sw::Format Texture2D::getInternalFormat(GLenum target, GLint level) const
int Texture2D::getLevelCount() const int Texture2D::getLevelCount() const
{ {
ASSERT(isSamplerComplete()); //ASSERT(isSamplerComplete());
int levels = 0; int levels = 0;
while(levels < MIPMAP_LEVELS && image[levels]) while(levels < MIPMAP_LEVELS && image[levels])
...@@ -1156,17 +1156,17 @@ void TextureExternal::setImage(Image *sharedImage) ...@@ -1156,17 +1156,17 @@ void TextureExternal::setImage(Image *sharedImage)
// Exported functions for use by EGL // Exported functions for use by EGL
extern "C" extern "C"
{ {
rad::Image *createBackBuffer(int width, int height, const egl::Config *config) es2::Image *createBackBuffer(int width, int height, const egl::Config *config)
{ {
if(config) if(config)
{ {
return new rad::Image(0, width, height, config->mAlphaSize ? GL_RGBA : GL_RGB, GL_UNSIGNED_BYTE); return new es2::Image(0, width, height, config->mAlphaSize ? GL_RGBA : GL_RGB, GL_UNSIGNED_BYTE);
} }
return 0; return 0;
} }
rad::Image *createDepthStencil(unsigned int width, unsigned int height, sw::Format format, int multiSampleDepth, bool discard) es2::Image *createDepthStencil(unsigned int width, unsigned int height, sw::Format format, int multiSampleDepth, bool discard)
{ {
if(width == 0 || height == 0 || height > OUTLINE_RESOLUTION) if(width == 0 || height == 0 || height > OUTLINE_RESOLUTION)
{ {
...@@ -1199,7 +1199,7 @@ extern "C" ...@@ -1199,7 +1199,7 @@ extern "C"
UNREACHABLE(); UNREACHABLE();
} }
rad::Image *surface = new rad::Image(0, width, height, format, multiSampleDepth, lockable, true); es2::Image *surface = new es2::Image(0, width, height, format, multiSampleDepth, lockable, true);
if(!surface) if(!surface)
{ {
......
...@@ -33,7 +33,7 @@ class Surface; ...@@ -33,7 +33,7 @@ class Surface;
class Config; class Config;
} }
namespace rad namespace es2
{ {
class Framebuffer; class Framebuffer;
......
...@@ -24,7 +24,7 @@ namespace ...@@ -24,7 +24,7 @@ namespace
enum {INITIAL_STREAM_BUFFER_SIZE = 1024 * 1024}; enum {INITIAL_STREAM_BUFFER_SIZE = 1024 * 1024};
} }
namespace rad namespace es2
{ {
VertexDataManager::VertexDataManager(Context *context) : mContext(context) VertexDataManager::VertexDataManager(Context *context) : mContext(context)
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
#define GL_APICALL #define GL_APICALL
#include <GLES2/gl2.h> #include <GLES2/gl2.h>
namespace rad namespace es2
{ {
struct TranslatedAttribute struct TranslatedAttribute
......
This source diff could not be displayed because it is too large. You can view the blob instead.
LIBRARY libRAD LIBRARY libRAD
EXPORTS 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
radGetProcAddress radGetProcAddress
; EGL dependencies ; EGL dependencies
glCreateContext glCreateContext
glGetProcAddress
createFrameBuffer createFrameBuffer
createBackBuffer createBackBuffer
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations"> <ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32"> <ProjectConfiguration Include="Debug|Win32">
...@@ -196,6 +196,7 @@ copy "$(OutDir)libRAD.dll" "$(ProjectDir)..\..\..\lib\$(Configuration)\"</Comman ...@@ -196,6 +196,7 @@ copy "$(OutDir)libRAD.dll" "$(ProjectDir)..\..\..\lib\$(Configuration)\"</Comman
<ClInclude Include="IndexDataManager.h" /> <ClInclude Include="IndexDataManager.h" />
<ClInclude Include="main.h" /> <ClInclude Include="main.h" />
<ClInclude Include="mathutil.h" /> <ClInclude Include="mathutil.h" />
<ClInclude Include="Object.hpp" />
<ClInclude Include="Program.h" /> <ClInclude Include="Program.h" />
<ClInclude Include="Query.h" /> <ClInclude Include="Query.h" />
<ClInclude Include="RefCountObject.h" /> <ClInclude Include="RefCountObject.h" />
...@@ -229,4 +230,4 @@ copy "$(OutDir)libRAD.dll" "$(ProjectDir)..\..\..\lib\$(Configuration)\"</Comman ...@@ -229,4 +230,4 @@ copy "$(OutDir)libRAD.dll" "$(ProjectDir)..\..\..\lib\$(Configuration)\"</Comman
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">
</ImportGroup> </ImportGroup>
</Project> </Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup> <ItemGroup>
<Filter Include="Source Files"> <Filter Include="Source Files">
...@@ -145,6 +145,9 @@ ...@@ -145,6 +145,9 @@
<ClInclude Include="..\common\debug.h"> <ClInclude Include="..\common\debug.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="Object.hpp">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ResourceCompile Include="libRAD.rc" /> <ResourceCompile Include="libRAD.rc" />
...@@ -152,4 +155,4 @@ ...@@ -152,4 +155,4 @@
<ItemGroup> <ItemGroup>
<None Include="libRAD.def" /> <None Include="libRAD.def" />
</ItemGroup> </ItemGroup>
</Project> </Project>
\ No newline at end of file
...@@ -89,15 +89,15 @@ extern "C" BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved ...@@ -89,15 +89,15 @@ extern "C" BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved
} }
#endif #endif
namespace rad namespace es2
{ {
rad::Context *getContext() es2::Context *getContext()
{ {
egl::Context *context = egl::getCurrentContext(); egl::Context *context = egl::getCurrentContext();
if(context && context->getClientVersion() == 2) if(context && context->getClientVersion() == 2)
{ {
return static_cast<rad::Context*>(context); return static_cast<es2::Context*>(context);
} }
return 0; return 0;
...@@ -129,7 +129,7 @@ GLint getClientVersion() ...@@ -129,7 +129,7 @@ GLint getClientVersion()
// Records an error code // Records an error code
void error(GLenum errorCode) void error(GLenum errorCode)
{ {
rad::Context *context = rad::getContext(); es2::Context *context = es2::getContext();
if(context) if(context)
{ {
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#include <GLES2/gl2.h> #include <GLES2/gl2.h>
#include <GLES2/gl2ext.h> #include <GLES2/gl2ext.h>
namespace rad namespace es2
{ {
Context *getContext(); Context *getContext();
egl::Display *getDisplay(); egl::Display *getDisplay();
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
#include <math.h> #include <math.h>
namespace rad namespace es2
{ {
inline bool isPow2(int x) inline bool isPow2(int x)
{ {
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#include <limits> #include <limits>
#include <stdio.h> #include <stdio.h>
namespace rad namespace es2
{ {
int UniformComponentCount(GLenum type) int UniformComponentCount(GLenum type)
{ {
...@@ -478,7 +478,7 @@ namespace rad2sw ...@@ -478,7 +478,7 @@ namespace rad2sw
return sw::STENCIL_ALWAYS; return sw::STENCIL_ALWAYS;
} }
sw::Color<float> ConvertColor(rad::Color color) sw::Color<float> ConvertColor(es2::Color color)
{ {
return sw::Color<float>(color.red, color.green, color.blue, color.alpha); return sw::Color<float>(color.red, color.green, color.blue, color.alpha);
} }
...@@ -630,36 +630,36 @@ namespace rad2sw ...@@ -630,36 +630,36 @@ namespace rad2sw
} }
} }
bool ConvertPrimitiveType(GLenum primitiveType, GLsizei elementCount, rad::PrimitiveType &swPrimitiveType, int &primitiveCount) bool ConvertPrimitiveType(GLenum primitiveType, GLsizei elementCount, es2::PrimitiveType &swPrimitiveType, int &primitiveCount)
{ {
switch(primitiveType) switch(primitiveType)
{ {
case GL_POINTS: case GL_POINTS:
swPrimitiveType = rad::DRAW_POINTLIST; swPrimitiveType = es2::DRAW_POINTLIST;
primitiveCount = elementCount; primitiveCount = elementCount;
break; break;
case GL_LINES: case GL_LINES:
swPrimitiveType = rad::DRAW_LINELIST; swPrimitiveType = es2::DRAW_LINELIST;
primitiveCount = elementCount / 2; primitiveCount = elementCount / 2;
break; break;
case GL_LINE_LOOP: case GL_LINE_LOOP:
swPrimitiveType = rad::DRAW_LINELOOP; swPrimitiveType = es2::DRAW_LINELOOP;
primitiveCount = elementCount; primitiveCount = elementCount;
break; break;
case GL_LINE_STRIP: case GL_LINE_STRIP:
swPrimitiveType = rad::DRAW_LINESTRIP; swPrimitiveType = es2::DRAW_LINESTRIP;
primitiveCount = elementCount - 1; primitiveCount = elementCount - 1;
break; break;
case GL_TRIANGLES: case GL_TRIANGLES:
swPrimitiveType = rad::DRAW_TRIANGLELIST; swPrimitiveType = es2::DRAW_TRIANGLELIST;
primitiveCount = elementCount / 3; primitiveCount = elementCount / 3;
break; break;
case GL_TRIANGLE_STRIP: case GL_TRIANGLE_STRIP:
swPrimitiveType = rad::DRAW_TRIANGLESTRIP; swPrimitiveType = es2::DRAW_TRIANGLESTRIP;
primitiveCount = elementCount - 2; primitiveCount = elementCount - 2;
break; break;
case GL_TRIANGLE_FAN: case GL_TRIANGLE_FAN:
swPrimitiveType = rad::DRAW_TRIANGLEFAN; swPrimitiveType = es2::DRAW_TRIANGLEFAN;
primitiveCount = elementCount - 2; primitiveCount = elementCount - 2;
break; break;
default: default:
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#include <string> #include <string>
namespace rad namespace es2
{ {
struct Color; struct Color;
...@@ -57,7 +57,7 @@ namespace rad2sw ...@@ -57,7 +57,7 @@ namespace rad2sw
{ {
sw::DepthCompareMode ConvertDepthComparison(GLenum comparison); sw::DepthCompareMode ConvertDepthComparison(GLenum comparison);
sw::StencilCompareMode ConvertStencilComparison(GLenum comparison); sw::StencilCompareMode ConvertStencilComparison(GLenum comparison);
sw::Color<float> ConvertColor(rad::Color color); sw::Color<float> ConvertColor(es2::Color color);
sw::BlendFactor ConvertBlendFunc(GLenum blend); sw::BlendFactor ConvertBlendFunc(GLenum blend);
sw::BlendOperation ConvertBlendOp(GLenum blendOp); sw::BlendOperation ConvertBlendOp(GLenum blendOp);
sw::StencilOperation ConvertStencilOp(GLenum stencilOp); sw::StencilOperation ConvertStencilOp(GLenum stencilOp);
...@@ -66,7 +66,7 @@ namespace rad2sw ...@@ -66,7 +66,7 @@ namespace rad2sw
unsigned int ConvertColorMask(bool red, bool green, bool blue, bool alpha); unsigned int ConvertColorMask(bool red, bool green, bool blue, bool alpha);
sw::FilterType ConvertMagFilter(GLenum magFilter); sw::FilterType ConvertMagFilter(GLenum magFilter);
void ConvertMinFilter(GLenum texFilter, sw::FilterType *minFilter, sw::MipmapType *mipFilter, float maxAnisotropy); void ConvertMinFilter(GLenum texFilter, sw::FilterType *minFilter, sw::MipmapType *mipFilter, float maxAnisotropy);
bool ConvertPrimitiveType(GLenum primitiveType, GLsizei elementCount, rad::PrimitiveType &swPrimitiveType, int &primitiveCount); bool ConvertPrimitiveType(GLenum primitiveType, GLsizei elementCount, es2::PrimitiveType &swPrimitiveType, int &primitiveCount);
sw::Format ConvertRenderbufferFormat(GLenum format); sw::Format ConvertRenderbufferFormat(GLenum format);
} }
......
...@@ -28,8 +28,8 @@ ...@@ -28,8 +28,8 @@
#define WINDOW_CLASS _T("PVRShellClass") #define WINDOW_CLASS _T("PVRShellClass")
// Width and height of the window // Width and height of the window
#define WINDOW_WIDTH 640 #define WINDOW_WIDTH 500
#define WINDOW_HEIGHT 480 #define WINDOW_HEIGHT 500
// Index to bind the attributes to vertex shaders // Index to bind the attributes to vertex shaders
#define VERTEX_ARRAY 0 #define VERTEX_ARRAY 0
...@@ -158,10 +158,10 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, TCHAR *lpCmdLin ...@@ -158,10 +158,10 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, TCHAR *lpCmdLin
// Create the eglWindow // Create the eglWindow
RECT sRect; RECT sRect;
SetRect(&sRect, 0, 0, nWidth, nHeight); SetRect(&sRect, 100, 100, 100 + nWidth, 100 + nHeight);
AdjustWindowRectEx(&sRect, WS_CAPTION | WS_SYSMENU, false, 0); AdjustWindowRect(&sRect, WS_CAPTION | WS_SYSMENU, false);
hWnd = CreateWindow( WINDOW_CLASS, _T("HelloAPI"), WS_VISIBLE | WS_SYSMENU, hWnd = CreateWindow( WINDOW_CLASS, _T("RAD Test App"), WS_VISIBLE | WS_CAPTION | WS_SYSMENU,
0, 0, nWidth, nHeight, NULL, NULL, hInstance, NULL); sRect.left, sRect.top, sRect.right - sRect.left, sRect.bottom - sRect.top, NULL, NULL, hInstance, NULL);
eglWindow = hWnd; eglWindow = hWnd;
// Get the associated device context // Get the associated device context
...@@ -311,11 +311,11 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, TCHAR *lpCmdLin ...@@ -311,11 +311,11 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, TCHAR *lpCmdLin
Swap Buffers. Swap Buffers.
Brings to the native display the current render surface. Brings to the native display the current render surface.
*/ */
eglSwapBuffers(eglDisplay, eglSurface); //eglSwapBuffers(eglDisplay, eglSurface);
if (!TestEGLError(hWnd, "eglSwapBuffers")) //if (!TestEGLError(hWnd, "eglSwapBuffers"))
{ //{
goto cleanup; // goto cleanup;
} //}
// Managing the window messages // Managing the window messages
MSG msg; MSG msg;
...@@ -327,6 +327,9 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, TCHAR *lpCmdLin ...@@ -327,6 +327,9 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, TCHAR *lpCmdLin
cleanup: cleanup:
void CleanRAD();
CleanRAD();
eglMakeCurrent(eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); eglMakeCurrent(eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
eglTerminate(eglDisplay); eglTerminate(eglDisplay);
......
...@@ -16,30 +16,41 @@ ...@@ -16,30 +16,41 @@
RADdevice device; RADdevice device;
RADqueue queue; RADqueue queue;
bool useCopyQueue = true; bool useCopyQueue = false /*true*/;
RADqueue copyQueue; RADqueue copyQueue;
#define SHADER_SOURCE(source) #source
static const char *vsstring = static const char *vsstring =
"#version 440 core\n" //"#version 440 core\n"
"#define BINDGROUP(GROUP,INDEX) layout(binding = ((INDEX) | ((GROUP) << 4)))\n" //"#define BINDGROUP(GROUP,INDEX) layout(binding = ((INDEX) | ((GROUP) << 4)))\n"
"layout(location = 1) in vec4 tc;\n" //"layout(location = 1) in vec4 tc;\n"
"layout(location = 0) in vec4 position;\n" //"layout(location = 0) in vec4 position;\n"
"BINDGROUP(0, 2) uniform Block {\n" //"BINDGROUP(0, 2) uniform Block {\n"
" vec4 scale;\n" //" vec4 scale;\n"
"};\n" //"};\n"
"out vec4 ftc;\n" //"out vec4 ftc;\n"
"void main() {\n" //"void main() {\n"
" gl_Position = position*scale;\n" //" gl_Position = position*scale;\n"
// This line exists to trick the compiler into putting a value in the compiler //// This line exists to trick the compiler into putting a value in the compiler
// constant bank, so we can exercise binding that bank //// constant bank, so we can exercise binding that bank
" if (scale.z != 1.0 + 1.0/65536.0) {\n" //" if (scale.z != 1.0 + 1.0/65536.0) {\n"
" gl_Position = vec4(0,0,0,0);\n" //" gl_Position = vec4(0,0,0,0);\n"
" }\n" //" }\n"
" ftc = tc;\n" //" ftc = tc;\n"
"}\n"; //"}\n";
SHADER_SOURCE(attribute highp vec4 position;
attribute highp vec4 tc;
varying highp vec4 ftc;
uniform highp vec4 scale;
void main(void)
{
gl_Position = position * scale;
ftc = tc;
});
static const char *fsstring = static const char *fsstring =
"#version 440 core\n" /* "#version 440 core\n"
"#define BINDGROUP(GROUP,INDEX) layout(binding = ((INDEX) | ((GROUP) << 4)))\n" "#define BINDGROUP(GROUP,INDEX) layout(binding = ((INDEX) | ((GROUP) << 4)))\n"
"BINDGROUP(0, 3) uniform sampler2D tex;\n" "BINDGROUP(0, 3) uniform sampler2D tex;\n"
"BINDGROUP(0, 2) uniform Block {\n" "BINDGROUP(0, 2) uniform Block {\n"
...@@ -52,7 +63,14 @@ static const char *fsstring = ...@@ -52,7 +63,14 @@ static const char *fsstring =
" if (scale.z != 1.0 + 1.0/65536.0) {\n" " if (scale.z != 1.0 + 1.0/65536.0) {\n"
" color = vec4(0,0,0,0);\n" " color = vec4(0,0,0,0);\n"
" }\n" " }\n"
"}\n"; "}\n";*/
SHADER_SOURCE(
varying highp vec4 ftc;
uniform sampler2D tex;
void main (void)
{
gl_FragColor = texture2D(tex, ftc.xy);\n
});
// Two triangles that intersect // Two triangles that intersect
...@@ -74,7 +92,7 @@ static RADubyte texcoordData[] = {0, 0, 0xFF, 0xFF, ...@@ -74,7 +92,7 @@ static RADubyte texcoordData[] = {0, 0, 0xFF, 0xFF,
0, 0xFF, 0, 0xFF}; 0, 0xFF, 0, 0xFF};
int windowWidth = 500, windowHeight = 500; int windowWidth = 500, windowHeight = 500;
int offscreenWidth = 100, offscreenHeight = 100; int offscreenWidth = 500, offscreenHeight = 500;
typedef enum { typedef enum {
QUEUE, QUEUE,
...@@ -82,7 +100,7 @@ typedef enum { ...@@ -82,7 +100,7 @@ typedef enum {
COMMAND, COMMAND,
} DrawMode; } DrawMode;
DrawMode drawMode = COMMAND; DrawMode drawMode = QUEUE /* COMMAND */;
bool benchmark = false; bool benchmark = false;
void InitRAD() void InitRAD()
...@@ -99,7 +117,16 @@ void InitRAD() ...@@ -99,7 +117,16 @@ void InitRAD()
} }
} }
#define USE_MULTISAMPLE 1 void CleanRAD()
{
if (useCopyQueue) {
radReleaseQueue(copyQueue);
}
radReleaseQueue(queue);
radReleaseDevice(device);
}
#define USE_MULTISAMPLE 0
RADbuffer AllocAndFillBuffer(RADdevice device, void *data, int sizeofdata, RADbitfield access, bool useCopy) RADbuffer AllocAndFillBuffer(RADdevice device, void *data, int sizeofdata, RADbitfield access, bool useCopy)
{ {
...@@ -211,7 +238,7 @@ void TestRAD() ...@@ -211,7 +238,7 @@ void TestRAD()
// Create an index buffer and fill it with data // Create an index buffer and fill it with data
unsigned short indexData[6] = {0, 1, 2, 3, 4, 5}; unsigned short indexData[6] = {0, 1, 2, 3, 4, 5};
RADbuffer ibo = AllocAndFillBuffer(device, indexData, sizeof(indexData), RAD_INDEX_ACCESS_BIT, true); RADbuffer ibo = AllocAndFillBuffer(device, indexData, sizeof(indexData), RAD_INDEX_ACCESS_BIT, false /*true*/);
// Get a handle to be used for setting the buffer as an index buffer // Get a handle to be used for setting the buffer as an index buffer
RADvertexHandle iboHandle = radGetVertexHandle(ibo); RADvertexHandle iboHandle = radGetVertexHandle(ibo);
......
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