Split Renderer into version independent interface and Renderer9 implementation.

TRAC #21963 Signed-off-by: Daniel Koch Author: Nicolas Capens git-svn-id: https://angleproject.googlecode.com/svn/branches/dx11proto@1358 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 7cb796e7
......@@ -21,7 +21,7 @@
#include <vector>
#include "libGLESv2/Context.h"
#include "libGLESv2/renderer/Renderer.h"
#include "libGLESv2/renderer/Renderer9.h"
#include "libEGL/Config.h"
#include "libEGL/Surface.h"
......@@ -54,7 +54,7 @@ class Display
bool isValidSurface(egl::Surface *surface);
bool hasExistingWindowSurface(HWND window);
renderer::Renderer *getRenderer() { return mRenderer; };
renderer::Renderer9 *getRenderer() { return mRenderer; };
virtual void notifyDeviceLost();
......@@ -80,7 +80,7 @@ class Display
typedef std::set<gl::Context*> ContextSet;
ContextSet mContextSet;
renderer::Renderer *mRenderer;
renderer::Renderer9 *mRenderer; // D3D9_REPLACE
void initExtensionString();
std::string mExtensionString;
......
......@@ -22,7 +22,7 @@ class Texture2D;
}
namespace renderer
{
class Renderer;
class Renderer9;
class SwapChain;
}
......@@ -68,7 +68,7 @@ private:
DISALLOW_COPY_AND_ASSIGN(Surface);
Display *const mDisplay;
renderer::Renderer *mRenderer;
renderer::Renderer9 *mRenderer; // D3D9_REPLACE
HANDLE mShareHandle;
renderer::SwapChain *mSwapChain;
......
......@@ -42,7 +42,7 @@ const size_t g_shaderSize[] =
namespace gl
{
Blit::Blit(renderer::Renderer *renderer)
Blit::Blit(renderer::Renderer9 *renderer)
: mRenderer(renderer), mQuadVertexBuffer(NULL), mQuadVertexDeclaration(NULL), mSavedRenderTarget(NULL), mSavedDepthStencil(NULL), mSavedStateBlock(NULL)
{
initGeometry();
......@@ -114,7 +114,7 @@ void Blit::initGeometry()
template <class D3DShaderType>
bool Blit::setShader(ShaderId source, const char *profile,
D3DShaderType *(renderer::Renderer::*createShader)(const DWORD *, size_t length),
D3DShaderType *(renderer::Renderer9::*createShader)(const DWORD *, size_t length),
HRESULT (WINAPI IDirect3DDevice9::*setShader)(D3DShaderType*))
{
IDirect3DDevice9 *device = mRenderer->getDevice(); // D3D9_REPLACE
......@@ -153,12 +153,12 @@ bool Blit::setShader(ShaderId source, const char *profile,
bool Blit::setVertexShader(ShaderId shader)
{
return setShader<IDirect3DVertexShader9>(shader, "vs_2_0", &renderer::Renderer::createVertexShader, &IDirect3DDevice9::SetVertexShader);
return setShader<IDirect3DVertexShader9>(shader, "vs_2_0", &renderer::Renderer9::createVertexShader, &IDirect3DDevice9::SetVertexShader);
}
bool Blit::setPixelShader(ShaderId shader)
{
return setShader<IDirect3DPixelShader9>(shader, "ps_2_0", &renderer::Renderer::createPixelShader, &IDirect3DDevice9::SetPixelShader);
return setShader<IDirect3DPixelShader9>(shader, "ps_2_0", &renderer::Renderer9::createPixelShader, &IDirect3DDevice9::SetPixelShader);
}
RECT Blit::getSurfaceRect(IDirect3DSurface9 *surface) const
......
......@@ -27,7 +27,7 @@ class Context;
class Blit
{
public:
explicit Blit(renderer::Renderer *renderer);
explicit Blit(renderer::Renderer9 *renderer);
~Blit();
// Copy from source surface to dest surface.
......@@ -44,7 +44,7 @@ class Blit
bool boxFilter(IDirect3DSurface9 *source, IDirect3DSurface9 *dest);
private:
renderer::Renderer *mRenderer;
renderer::Renderer9 *mRenderer;
IDirect3DVertexBuffer9 *mQuadVertexBuffer;
IDirect3DVertexDeclaration9 *mQuadVertexDeclaration;
......@@ -74,7 +74,7 @@ class Blit
template <class D3DShaderType>
bool setShader(ShaderId source, const char *profile,
D3DShaderType *(renderer::Renderer::*createShader)(const DWORD *, size_t length),
D3DShaderType *(renderer::Renderer9::*createShader)(const DWORD *, size_t length),
HRESULT (WINAPI IDirect3DDevice9::*setShader)(D3DShaderType*));
bool setVertexShader(ShaderId shader);
......
......@@ -19,7 +19,7 @@
#include "common/angleutils.h"
#include "common/RefCountObject.h"
#include "libGLESv2/renderer/Renderer.h"
#include "libGLESv2/renderer/Renderer9.h"
namespace gl
{
......@@ -48,7 +48,7 @@ class Buffer : public RefCountObject
private:
DISALLOW_COPY_AND_ASSIGN(Buffer);
renderer::Renderer *mRenderer;
renderer::Renderer9 *mRenderer; // D3D9_REPLACE
GLubyte *mContents;
GLsizeiptr mSize;
GLenum mUsage;
......
......@@ -4405,9 +4405,9 @@ gl::Context *glGetCurrentContext()
return gl::getContext();
}
renderer::Renderer *glCreateRenderer(egl::Display *display, HMODULE hModule, HDC hDc)
renderer::Renderer9 *glCreateRenderer(egl::Display *display, HMODULE hModule, HDC hDc)
{
return new renderer::Renderer(display, hModule, hDc);
return new renderer::Renderer9(display, hModule, hDc); // D3D9_REPLACE
}
void glDestroyRenderer(renderer::Renderer *renderer)
......@@ -4415,7 +4415,7 @@ void glDestroyRenderer(renderer::Renderer *renderer)
delete renderer;
}
renderer::SwapChain *glCreateSwapChain(renderer::Renderer *renderer, HWND window, HANDLE shareHandle,
renderer::SwapChain *glCreateSwapChain(renderer::Renderer9 *renderer, HWND window, HANDLE shareHandle,
GLenum backBufferFormat, GLenum depthBufferFormat)
{
return new renderer::SwapChain(renderer, window, shareHandle, backBufferFormat, depthBufferFormat);
......
......@@ -543,7 +543,7 @@ class Context
egl::Display *mDisplay;
IDirect3DDevice9 *mDevice;
renderer::Renderer *mRenderer;
renderer::Renderer9 *mRenderer; // D3D9_REPLACE
State mState;
......@@ -669,10 +669,10 @@ gl::Context *glCreateContext(const gl::Context *shareContext, bool notifyResets,
void glDestroyContext(gl::Context *context);
void glMakeCurrent(gl::Context *context, egl::Display *display, egl::Surface *surface);
gl::Context *glGetCurrentContext();
renderer::Renderer *glCreateRenderer(egl::Display *display, HMODULE hModule, HDC hDc);
renderer::Renderer9 *glCreateRenderer(egl::Display *display, HMODULE hModule, HDC hDc); // D3D9_REPLACE
void glDestroyRenderer(renderer::Renderer *renderer);
renderer::SwapChain *glCreateSwapChain(renderer::Renderer *renderer, HWND window, HANDLE shareHandle,
GLenum backBufferFormat, GLenum depthBufferFormat);
renderer::SwapChain *glCreateSwapChain(renderer::Renderer9 *renderer, HWND window, HANDLE shareHandle,
GLenum backBufferFormat, GLenum depthBufferFormat); // D3D9_REPLACE
void glDestroySwapChain(renderer::SwapChain *swapChain);
__eglMustCastToProperFunctionPointerType __stdcall glGetProcAddress(const char *procname);
......
......@@ -13,7 +13,7 @@
namespace gl
{
Fence::Fence(renderer::Renderer *renderer)
Fence::Fence(renderer::Renderer9 *renderer)
{
mRenderer = renderer;
mQuery = NULL;
......
......@@ -14,7 +14,7 @@
#include <d3d9.h>
#include "common/angleutils.h"
#include "libGLESv2/renderer/Renderer.h"
#include "libGLESv2/renderer/Renderer9.h"
namespace gl
{
......@@ -22,7 +22,7 @@ namespace gl
class Fence
{
public:
explicit Fence(renderer::Renderer *renderer);
explicit Fence(renderer::Renderer9 *renderer);
virtual ~Fence();
GLboolean isFence();
......@@ -34,7 +34,7 @@ class Fence
private:
DISALLOW_COPY_AND_ASSIGN(Fence);
renderer::Renderer *mRenderer;
renderer::Renderer9 *mRenderer; // D3D9_REPLACE
IDirect3DQuery9* mQuery; // D3D9_REPLACE
GLenum mCondition;
GLboolean mStatus;
......
......@@ -19,7 +19,7 @@ namespace gl
{
unsigned int IndexBuffer::mCurrentSerial = 1;
IndexDataManager::IndexDataManager(Context *context, renderer::Renderer *renderer) : mRenderer(renderer)
IndexDataManager::IndexDataManager(Context *context, renderer::Renderer9 *renderer) : mRenderer(renderer)
{
mStreamingBufferShort = new StreamingIndexBuffer(mRenderer, INITIAL_INDEX_BUFFER_SIZE, D3DFMT_INDEX16);
......@@ -281,7 +281,7 @@ StaticIndexBuffer *IndexDataManager::getCountingIndices(GLsizei count)
return mCountingBuffer;
}
IndexBuffer::IndexBuffer(renderer::Renderer *renderer, UINT size, D3DFORMAT format) : mRenderer(renderer), mBufferSize(size), mIndexBuffer(NULL)
IndexBuffer::IndexBuffer(renderer::Renderer9 *renderer, UINT size, D3DFORMAT format) : mRenderer(renderer), mBufferSize(size), mIndexBuffer(NULL)
{
if (size > 0)
{
......@@ -328,7 +328,7 @@ void IndexBuffer::unmap()
}
}
StreamingIndexBuffer::StreamingIndexBuffer(renderer::Renderer *renderer, UINT initialSize, D3DFORMAT format) : IndexBuffer(renderer, initialSize, format)
StreamingIndexBuffer::StreamingIndexBuffer(renderer::Renderer9 *renderer, UINT initialSize, D3DFORMAT format) : IndexBuffer(renderer, initialSize, format)
{
mWritePosition = 0;
}
......@@ -392,7 +392,7 @@ void StreamingIndexBuffer::reserveSpace(UINT requiredSpace, GLenum type)
}
}
StaticIndexBuffer::StaticIndexBuffer(renderer::Renderer *renderer) : IndexBuffer(renderer, 0, D3DFMT_UNKNOWN)
StaticIndexBuffer::StaticIndexBuffer(renderer::Renderer9 *renderer) : IndexBuffer(renderer, 0, D3DFMT_UNKNOWN)
{
mCacheType = GL_NONE;
}
......
......@@ -39,7 +39,7 @@ struct TranslatedIndexData
class IndexBuffer
{
public:
IndexBuffer(renderer::Renderer *renderer, UINT size, D3DFORMAT format);
IndexBuffer(renderer::Renderer9 *renderer, UINT size, D3DFORMAT format);
virtual ~IndexBuffer();
UINT size() const { return mBufferSize; }
......@@ -51,7 +51,7 @@ class IndexBuffer
unsigned int getSerial() const;
protected:
renderer::Renderer *const mRenderer;
renderer::Renderer9 *const mRenderer; // D3D9_REPLACE
IDirect3DIndexBuffer9 *mIndexBuffer;
UINT mBufferSize;
......@@ -67,7 +67,7 @@ class IndexBuffer
class StreamingIndexBuffer : public IndexBuffer
{
public:
StreamingIndexBuffer(renderer::Renderer *renderer, UINT initialSize, D3DFORMAT format);
StreamingIndexBuffer(renderer::Renderer9 *renderer, UINT initialSize, D3DFORMAT format);
~StreamingIndexBuffer();
virtual void *map(UINT requiredSpace, UINT *offset);
......@@ -80,7 +80,7 @@ class StreamingIndexBuffer : public IndexBuffer
class StaticIndexBuffer : public IndexBuffer
{
public:
explicit StaticIndexBuffer(renderer::Renderer *renderer);
explicit StaticIndexBuffer(renderer::Renderer9 *renderer);
~StaticIndexBuffer();
virtual void *map(UINT requiredSpace, UINT *offset);
......@@ -125,7 +125,7 @@ class StaticIndexBuffer : public IndexBuffer
class IndexDataManager
{
public:
IndexDataManager(Context *context, renderer::Renderer *renderer);
IndexDataManager(Context *context, renderer::Renderer9 *renderer);
virtual ~IndexDataManager();
GLenum prepareIndexData(GLenum type, GLsizei count, Buffer *arrayElementBuffer, const GLvoid *indices, TranslatedIndexData *translated);
......@@ -137,7 +137,7 @@ class IndexDataManager
std::size_t typeSize(GLenum type) const;
std::size_t indexSize(D3DFORMAT format) const;
renderer::Renderer *const mRenderer;
renderer::Renderer9 *const mRenderer; // D3D9_REPLACE
StreamingIndexBuffer *mStreamingBufferShort;
StreamingIndexBuffer *mStreamingBufferInt;
......
......@@ -184,7 +184,7 @@ class ProgramBinary : public RefCountObject
void applyUniformniv(Uniform *targetUniform, GLsizei count, const Vector4 *vector);
void applyUniformnbv(Uniform *targetUniform, GLsizei count, int width, const GLboolean *v);
renderer::Renderer *mRenderer;
renderer::Renderer9 *mRenderer; // D3D9_REPLACE
IDirect3DDevice9 *mDevice; // D3D9_REPLACE
IDirect3DPixelShader9 *mPixelExecutable; // D3D9_REPLACE
......
......@@ -13,7 +13,7 @@
namespace gl
{
Query::Query(renderer::Renderer *renderer, GLuint id, GLenum type) : RefCountObject(id)
Query::Query(renderer::Renderer9 *renderer, GLuint id, GLenum type) : RefCountObject(id)
{
mRenderer = renderer;
mQuery = NULL;
......
......@@ -15,7 +15,7 @@
#include "common/angleutils.h"
#include "common/RefCountObject.h"
#include "libGLESv2/renderer/Renderer.h"
#include "libGLESv2/renderer/Renderer9.h"
namespace gl
{
......@@ -23,7 +23,7 @@ namespace gl
class Query : public RefCountObject
{
public:
Query(renderer::Renderer *renderer, GLuint id, GLenum type);
Query(renderer::Renderer9 *renderer, GLuint id, GLenum type);
virtual ~Query();
void begin();
......@@ -36,7 +36,7 @@ class Query : public RefCountObject
private:
DISALLOW_COPY_AND_ASSIGN(Query);
renderer::Renderer *mRenderer;
renderer::Renderer9 *mRenderer; // D3D9_REPLACE
GLboolean testQuery();
......
......@@ -397,7 +397,7 @@ Colorbuffer::Colorbuffer(renderer::SwapChain *swapChain)
Colorbuffer::Colorbuffer(int width, int height, GLenum format, GLsizei samples) : mRenderTarget(NULL)
{
renderer::Renderer *renderer = getDisplay()->getRenderer();
renderer::Renderer9 *renderer = getDisplay()->getRenderer();
IDirect3DDevice9 *device = renderer->getDevice(); // D3D9_REPLACE
D3DFORMAT requestedFormat = es2dx::ConvertRenderbufferFormat(format);
......@@ -470,7 +470,7 @@ DepthStencilbuffer::DepthStencilbuffer(renderer::SwapChain *swapChain)
DepthStencilbuffer::DepthStencilbuffer(int width, int height, GLsizei samples)
{
renderer::Renderer *renderer = getDisplay()->getRenderer();
renderer::Renderer9 *renderer = getDisplay()->getRenderer();
IDirect3DDevice9 *device = renderer->getDevice(); // D3D9_REPLACE
mDepthStencil = NULL;
......
......@@ -1630,7 +1630,7 @@ bool Texture::copyToRenderTarget(IDirect3DSurface9 *dest, IDirect3DSurface9 *sou
if (source && dest)
{
HRESULT result = D3DERR_OUTOFVIDEOMEMORY;
renderer::Renderer *renderer = getDisplay()->getRenderer();
renderer::Renderer9 *renderer = getDisplay()->getRenderer();
IDirect3DDevice9 *device = renderer->getDevice(); // D3D9_REPLACE
if (fromManaged)
......
......@@ -11,6 +11,7 @@
#include "common/debug.h"
#include "libGLESv2/renderer/Renderer9.h"
#include "libGLESv2/Buffer.h"
#include "libGLESv2/Program.h"
#include "libGLESv2/ProgramBinary.h"
......@@ -36,7 +37,7 @@ int elementsInBuffer(const VertexAttribute &attribute, int size)
return (size - attribute.mOffset % stride + (stride - attribute.typeSize())) / stride;
}
VertexDataManager::VertexDataManager(Context *context, renderer::Renderer *renderer) : mContext(context), mRenderer(renderer)
VertexDataManager::VertexDataManager(Context *context, renderer::Renderer9 *renderer) : mContext(context), mRenderer(renderer)
{
for (int i = 0; i < MAX_VERTEX_ATTRIBS; i++)
{
......@@ -571,7 +572,7 @@ unsigned int VertexDataManager::typeIndex(GLenum type) const
}
}
VertexBuffer::VertexBuffer(renderer::Renderer *renderer, std::size_t size, DWORD usageFlags) : mRenderer(renderer), mVertexBuffer(NULL)
VertexBuffer::VertexBuffer(renderer::Renderer9 *renderer, std::size_t size, DWORD usageFlags) : mRenderer(renderer), mVertexBuffer(NULL)
{
if (size > 0)
{
......@@ -618,7 +619,7 @@ unsigned int VertexBuffer::issueSerial()
return mCurrentSerial++;
}
ArrayVertexBuffer::ArrayVertexBuffer(renderer::Renderer *renderer, std::size_t size, DWORD usageFlags) : VertexBuffer(renderer, size, usageFlags)
ArrayVertexBuffer::ArrayVertexBuffer(renderer::Renderer9 *renderer, std::size_t size, DWORD usageFlags) : VertexBuffer(renderer, size, usageFlags)
{
mBufferSize = size;
mWritePosition = 0;
......@@ -634,7 +635,7 @@ void ArrayVertexBuffer::addRequiredSpace(UINT requiredSpace)
mRequiredSpace += requiredSpace;
}
StreamingVertexBuffer::StreamingVertexBuffer(renderer::Renderer *renderer, std::size_t initialSize) : ArrayVertexBuffer(renderer, initialSize, D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY)
StreamingVertexBuffer::StreamingVertexBuffer(renderer::Renderer9 *renderer, std::size_t initialSize) : ArrayVertexBuffer(renderer, initialSize, D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY)
{
}
......@@ -702,7 +703,7 @@ void StreamingVertexBuffer::reserveRequiredSpace()
mRequiredSpace = 0;
}
StaticVertexBuffer::StaticVertexBuffer(renderer::Renderer *renderer) : ArrayVertexBuffer(renderer, 0, D3DUSAGE_WRITEONLY)
StaticVertexBuffer::StaticVertexBuffer(renderer::Renderer9 *renderer) : ArrayVertexBuffer(renderer, 0, D3DUSAGE_WRITEONLY)
{
}
......
......@@ -37,7 +37,7 @@ struct TranslatedAttribute
class VertexBuffer
{
public:
VertexBuffer(renderer::Renderer *renderer, std::size_t size, DWORD usageFlags);
VertexBuffer(renderer::Renderer9 *renderer, std::size_t size, DWORD usageFlags);
virtual ~VertexBuffer();
void unmap();
......@@ -46,7 +46,7 @@ class VertexBuffer
unsigned int getSerial() const;
protected:
renderer::Renderer *const mRenderer;
renderer::Renderer9 *const mRenderer; // D3D9_REPLACE
IDirect3DVertexBuffer9 *mVertexBuffer;
unsigned int mSerial;
......@@ -60,7 +60,7 @@ class VertexBuffer
class ArrayVertexBuffer : public VertexBuffer
{
public:
ArrayVertexBuffer(renderer::Renderer *renderer, std::size_t size, DWORD usageFlags);
ArrayVertexBuffer(renderer::Renderer9 *renderer, std::size_t size, DWORD usageFlags);
~ArrayVertexBuffer();
std::size_t size() const { return mBufferSize; }
......@@ -77,7 +77,7 @@ class ArrayVertexBuffer : public VertexBuffer
class StreamingVertexBuffer : public ArrayVertexBuffer
{
public:
StreamingVertexBuffer(renderer::Renderer *renderer, std::size_t initialSize);
StreamingVertexBuffer(renderer::Renderer9 *renderer, std::size_t initialSize);
~StreamingVertexBuffer();
void *map(const VertexAttribute &attribute, std::size_t requiredSpace, std::size_t *streamOffset);
......@@ -87,7 +87,7 @@ class StreamingVertexBuffer : public ArrayVertexBuffer
class StaticVertexBuffer : public ArrayVertexBuffer
{
public:
explicit StaticVertexBuffer(renderer::Renderer *renderer);
explicit StaticVertexBuffer(renderer::Renderer9 *renderer);
~StaticVertexBuffer();
void *map(const VertexAttribute &attribute, std::size_t requiredSpace, std::size_t *streamOffset);
......@@ -113,7 +113,7 @@ class StaticVertexBuffer : public ArrayVertexBuffer
class VertexDataManager
{
public:
VertexDataManager(Context *context, renderer::Renderer *renderer);
VertexDataManager(Context *context, renderer::Renderer9 *renderer);
virtual ~VertexDataManager();
void dirtyCurrentValue(int index) { mDirtyCurrentValue[index] = true; }
......@@ -127,7 +127,7 @@ class VertexDataManager
std::size_t writeAttributeData(ArrayVertexBuffer *vertexBuffer, GLint start, GLsizei count, const VertexAttribute &attribute, GLsizei instances);
Context *const mContext;
renderer::Renderer *const mRenderer;
renderer::Renderer9 *const mRenderer; // D3D9_REPLACE
StreamingVertexBuffer *mStreamingBuffer;
......
......@@ -245,7 +245,7 @@ copy "$(OutDir)libGLESv2.lib" "$(ProjectDir)..\..\lib\$(Configuration)\"
<ClCompile Include="Query.cpp" />
<ClCompile Include="..\common\RefCountObject.cpp" />
<ClCompile Include="Renderbuffer.cpp" />
<ClCompile Include="renderer\Renderer.cpp" />
<ClCompile Include="renderer\Renderer9.cpp" />
<ClCompile Include="renderer\SwapChain.cpp" />
<ClCompile Include="ResourceManager.cpp" />
<ClCompile Include="Shader.cpp" />
......@@ -276,6 +276,7 @@ copy "$(OutDir)libGLESv2.lib" "$(ProjectDir)..\..\lib\$(Configuration)\"
<ClInclude Include="..\common\RefCountObject.h" />
<ClInclude Include="Renderbuffer.h" />
<ClInclude Include="renderer\Renderer.h" />
<ClInclude Include="renderer\Renderer9.h" />
<ClInclude Include="renderer\ShaderCache.h" />
<ClInclude Include="renderer\SwapChain.h" />
<ClInclude Include="resource.h" />
......@@ -306,4 +307,4 @@ copy "$(OutDir)libGLESv2.lib" "$(ProjectDir)..\..\lib\$(Configuration)\"
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>
\ No newline at end of file
......@@ -83,10 +83,10 @@
<ClCompile Include="VertexDataManager.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="renderer\Renderer.cpp">
<ClCompile Include="renderer\SwapChain.cpp">
<Filter>Renderer</Filter>
</ClCompile>
<ClCompile Include="renderer\SwapChain.cpp">
<ClCompile Include="renderer\Renderer9.cpp">
<Filter>Renderer</Filter>
</ClCompile>
</ItemGroup>
......@@ -184,6 +184,9 @@
<ClInclude Include="renderer\SwapChain.h">
<Filter>Renderer</Filter>
</ClInclude>
<ClInclude Include="renderer\Renderer9.h">
<Filter>Renderer</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="libGLESv2.def">
......
......@@ -10,22 +10,14 @@
#ifndef LIBGLESV2_RENDERER_RENDERER_H_
#define LIBGLESV2_RENDERER_RENDERER_H_
#include <set>
#include <map>
#include <vector>
#define GL_APICALL
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#define EGLAPI
#include <EGL/egl.h>
#include <d3d9.h> // D3D9_REPLACE
#include "common/angleutils.h"
#include "libGLESv2/renderer/ShaderCache.h"
#include "libGLESv2/EnumTypes.h"
#include "libGLESv2/Texture.h"
#include "libGLESv2/EnumTypes.h"
const int versionWindowsVista = MAKEWORD(0x00, 0x06);
const int versionWindows7 = MAKEWORD(0x01, 0x06);
......@@ -59,127 +51,63 @@ struct ConfigDesc
class Renderer
{
public:
Renderer(egl::Display *display, HMODULE hModule, HDC hDc);
virtual ~Renderer();
virtual EGLint initialize();
virtual bool resetDevice();
virtual int generateConfigs(ConfigDesc **configDescList);
virtual void deleteConfigs(ConfigDesc *configDescList);
virtual void startScene();
virtual void endScene();
virtual void sync(bool block);
virtual IDirect3DQuery9* allocateEventQuery();
virtual void freeEventQuery(IDirect3DQuery9* query);
// resource creation
virtual IDirect3DVertexShader9 *createVertexShader(const DWORD *function, size_t length); // D3D9_REPLACE
virtual IDirect3DPixelShader9 *createPixelShader(const DWORD *function, size_t length); // D3D9_REPLACE
#if 0
virtual void *createTexture2D();
virtual void *createTextureCube();
virtual void *createQuery();;
virtual void *createIndexBuffer();
virtual void *createVertexbuffer();
// state setup
virtual void applyShaders();
virtual void applyConstants();
virtual void applyRenderTargets();
virtual void applyState();
#endif
virtual void setSamplerState(gl::SamplerType type, int index, const gl::SamplerState &sampler);
virtual void setTexture(gl::SamplerType type, int index, gl::Texture *texture);
Renderer(egl::Display *display) : mDisplay(display) {};
virtual ~Renderer() {};
virtual EGLint initialize() = 0;
virtual bool resetDevice() = 0;
virtual int generateConfigs(ConfigDesc **configDescList) = 0;
virtual void deleteConfigs(ConfigDesc *configDescList) = 0;
virtual void startScene() = 0;
virtual void endScene() = 0;
virtual void sync(bool block) = 0;
virtual void setSamplerState(gl::SamplerType type, int index, const gl::SamplerState &sampler) = 0;
virtual void setTexture(gl::SamplerType type, int index, gl::Texture *texture) = 0;
// lost device
virtual void markDeviceLost();
virtual bool isDeviceLost();
virtual bool testDeviceLost(bool notify);
virtual bool testDeviceResettable();
virtual void markDeviceLost() = 0;
virtual bool isDeviceLost() = 0;
virtual bool testDeviceLost(bool notify) = 0;
virtual bool testDeviceResettable() = 0;
// Renderer capabilities
virtual IDirect3DDevice9 *getDevice() {return mDevice;}; // D3D9_REPLACE
virtual DWORD getAdapterVendor() const;
virtual const char *getAdapterDescription() const;
virtual GUID getAdapterIdentifier() const;
virtual bool getDXT1TextureSupport();
virtual bool getDXT3TextureSupport();
virtual bool getDXT5TextureSupport();
virtual bool getEventQuerySupport();
virtual bool getFloat32TextureSupport(bool *filtering, bool *renderable);
virtual bool getFloat16TextureSupport(bool *filtering, bool *renderable);
virtual bool getLuminanceTextureSupport();
virtual bool getLuminanceAlphaTextureSupport();
virtual bool getVertexTextureSupport() const;
virtual bool getNonPower2TextureSupport() const;
virtual bool getDepthTextureSupport() const;
virtual bool getOcclusionQuerySupport() const;
virtual bool getInstancingSupport() const;
virtual bool getTextureFilterAnisotropySupport() const;
virtual float getTextureMaxAnisotropy() const;
virtual bool getShareHandleSupport() const;
virtual bool getShaderModel3Support() const;
virtual float getMaxPointSize() const;
virtual int getMaxTextureWidth() const;
virtual int getMaxTextureHeight() const;
virtual bool get32BitIndexSupport() const;
virtual DWORD getCapsDeclTypes() const; // D3D9_REPLACE
virtual int getMinSwapInterval() const;
virtual int getMaxSwapInterval() const;
virtual GLsizei getMaxSupportedSamples() const;
virtual int getNearestSupportedSamples(D3DFORMAT format, int requested) const;
virtual D3DPOOL getBufferPool(DWORD usage) const;
virtual D3DPOOL getTexturePool(DWORD usage) const;
private:
DISALLOW_COPY_AND_ASSIGN(Renderer);
void getMultiSampleSupport(D3DFORMAT format, bool *multiSampleArray); // D3D9_REPLACE
static const D3DFORMAT mRenderTargetFormats[];
static const D3DFORMAT mDepthStencilFormats[];
virtual DWORD getAdapterVendor() const = 0;
virtual const char *getAdapterDescription() const = 0;
virtual GUID getAdapterIdentifier() const = 0;
virtual bool getDXT1TextureSupport() = 0;
virtual bool getDXT3TextureSupport() = 0;
virtual bool getDXT5TextureSupport() = 0;
virtual bool getEventQuerySupport() = 0;
virtual bool getFloat32TextureSupport(bool *filtering, bool *renderable) = 0;
virtual bool getFloat16TextureSupport(bool *filtering, bool *renderable) = 0;
virtual bool getLuminanceTextureSupport() = 0;
virtual bool getLuminanceAlphaTextureSupport() = 0;
virtual bool getVertexTextureSupport() const = 0;
virtual bool getNonPower2TextureSupport() const = 0;
virtual bool getDepthTextureSupport() const = 0;
virtual bool getOcclusionQuerySupport() const = 0;
virtual bool getInstancingSupport() const = 0;
virtual bool getTextureFilterAnisotropySupport() const = 0;
virtual float getTextureMaxAnisotropy() const = 0;
virtual bool getShareHandleSupport() const = 0;
virtual bool getShaderModel3Support() const = 0;
virtual float getMaxPointSize() const = 0;
virtual int getMaxTextureWidth() const = 0;
virtual int getMaxTextureHeight() const = 0;
virtual bool get32BitIndexSupport() const = 0;
virtual int getMinSwapInterval() const = 0;
virtual int getMaxSwapInterval() const = 0;
virtual GLsizei getMaxSupportedSamples() const = 0;
protected:
egl::Display *mDisplay;
const HDC mDc;
HMODULE mD3d9Module;
void initializeDevice();
D3DPRESENT_PARAMETERS getDefaultPresentParameters();
void releaseDeviceResources();
UINT mAdapter;
D3DDEVTYPE mDeviceType;
IDirect3D9 *mD3d9; // Always valid after successful initialization.
IDirect3D9Ex *mD3d9Ex; // Might be null if D3D9Ex is not supported.
IDirect3DDevice9 *mDevice;
IDirect3DDevice9Ex *mDeviceEx; // Might be null if D3D9Ex is not supported.
HWND mDeviceWindow;
bool mDeviceLost;
D3DCAPS9 mDeviceCaps;
D3DADAPTER_IDENTIFIER9 mAdapterIdentifier;
bool mSceneStarted;
bool mSupportsNonPower2Textures;
bool mSupportsTextureFilterAnisotropy;
int mMinSwapInterval;
int mMaxSwapInterval;
std::map<D3DFORMAT, bool *> mMultiSampleSupport;
GLsizei mMaxSupportedSamples;
// A pool of event queries that are currently unused.
std::vector<IDirect3DQuery9*> mEventQueryPool;
VertexShaderCache mVertexShaderCache;
PixelShaderCache mPixelShaderCache;
};
}
......
......@@ -7,9 +7,9 @@
// Renderer.cpp: Implements a back-end specific class that hides the details of the
// implementation-specific renderer.
#include "libGLESv2/renderer/Renderer.h"
#include "common/debug.h"
#include "libGLESv2/utilities.h"
#include "libGLESv2/renderer/Renderer9.h"
#include "libEGL/Config.h"
#include "libEGL/Display.h"
......@@ -27,7 +27,7 @@
namespace renderer
{
const D3DFORMAT Renderer::mRenderTargetFormats[] =
const D3DFORMAT Renderer9::mRenderTargetFormats[] =
{
D3DFMT_A1R5G5B5,
// D3DFMT_A2R10G10B10, // The color_ramp conformance test uses ReadPixels with UNSIGNED_BYTE causing it to think that rendering skipped a colour value.
......@@ -37,7 +37,7 @@ const D3DFORMAT Renderer::mRenderTargetFormats[] =
D3DFMT_X8R8G8B8
};
const D3DFORMAT Renderer::mDepthStencilFormats[] =
const D3DFORMAT Renderer9::mDepthStencilFormats[] =
{
D3DFMT_UNKNOWN,
// D3DFMT_D16_LOCKABLE,
......@@ -51,9 +51,8 @@ const D3DFORMAT Renderer::mDepthStencilFormats[] =
// D3DFMT_D24FS8
};
Renderer::Renderer(egl::Display *display, HMODULE hModule, HDC hDc): mDc(hDc)
Renderer9::Renderer9(egl::Display *display, HMODULE hModule, HDC hDc) : Renderer(display), mDc(hDc)
{
mDisplay = display;
mD3d9Module = hModule;
mD3d9 = NULL;
......@@ -75,7 +74,7 @@ Renderer::Renderer(egl::Display *display, HMODULE hModule, HDC hDc): mDc(hDc)
mMaxSupportedSamples = 0;
}
Renderer::~Renderer()
Renderer9::~Renderer9()
{
releaseDeviceResources();
......@@ -127,7 +126,7 @@ Renderer::~Renderer()
}
}
EGLint Renderer::initialize()
EGLint Renderer9::initialize()
{
typedef HRESULT (WINAPI *Direct3DCreate9ExFunc)(UINT, IDirect3D9Ex**);
Direct3DCreate9ExFunc Direct3DCreate9ExPtr = reinterpret_cast<Direct3DCreate9ExFunc>(GetProcAddress(mD3d9Module, "Direct3DCreate9Ex"));
......@@ -309,7 +308,7 @@ EGLint Renderer::initialize()
// do any one-time device initialization
// NOTE: this is also needed after a device lost/reset
// to reset the scene status and ensure the default states are reset.
void Renderer::initializeDevice()
void Renderer9::initializeDevice()
{
// Permanent non-default states
mDevice->SetRenderState(D3DRS_POINTSPRITEENABLE, TRUE);
......@@ -327,7 +326,7 @@ void Renderer::initializeDevice()
mSceneStarted = false;
}
D3DPRESENT_PARAMETERS Renderer::getDefaultPresentParameters()
D3DPRESENT_PARAMETERS Renderer9::getDefaultPresentParameters()
{
D3DPRESENT_PARAMETERS presentParameters = {0};
......@@ -349,7 +348,7 @@ D3DPRESENT_PARAMETERS Renderer::getDefaultPresentParameters()
return presentParameters;
}
int Renderer::generateConfigs(ConfigDesc **configDescList)
int Renderer9::generateConfigs(ConfigDesc **configDescList)
{
D3DDISPLAYMODE currentDisplayMode;
mD3d9->GetAdapterDisplayMode(mAdapter, &currentDisplayMode);
......@@ -402,12 +401,12 @@ int Renderer::generateConfigs(ConfigDesc **configDescList)
return numConfigs;
}
void Renderer::deleteConfigs(ConfigDesc *configDescList)
void Renderer9::deleteConfigs(ConfigDesc *configDescList)
{
delete [] (configDescList);
}
void Renderer::startScene()
void Renderer9::startScene()
{
if (!mSceneStarted)
{
......@@ -420,7 +419,7 @@ void Renderer::startScene()
}
}
void Renderer::endScene()
void Renderer9::endScene()
{
if (mSceneStarted)
{
......@@ -432,7 +431,7 @@ void Renderer::endScene()
}
// D3D9_REPLACE
void Renderer::sync(bool block)
void Renderer9::sync(bool block)
{
HRESULT result;
......@@ -473,7 +472,7 @@ void Renderer::sync(bool block)
}
// D3D9_REPLACE
IDirect3DQuery9* Renderer::allocateEventQuery()
IDirect3DQuery9* Renderer9::allocateEventQuery()
{
IDirect3DQuery9 *query = NULL;
......@@ -492,7 +491,7 @@ IDirect3DQuery9* Renderer::allocateEventQuery()
}
// D3D9_REPLACE
void Renderer::freeEventQuery(IDirect3DQuery9* query)
void Renderer9::freeEventQuery(IDirect3DQuery9* query)
{
if (mEventQueryPool.size() > 1000)
{
......@@ -504,18 +503,18 @@ void Renderer::freeEventQuery(IDirect3DQuery9* query)
}
}
IDirect3DVertexShader9 *Renderer::createVertexShader(const DWORD *function, size_t length)
IDirect3DVertexShader9 *Renderer9::createVertexShader(const DWORD *function, size_t length)
{
return mVertexShaderCache.create(function, length);
}
IDirect3DPixelShader9 *Renderer::createPixelShader(const DWORD *function, size_t length)
IDirect3DPixelShader9 *Renderer9::createPixelShader(const DWORD *function, size_t length)
{
return mPixelShaderCache.create(function, length);
}
void Renderer::setSamplerState(gl::SamplerType type, int index, const gl::SamplerState &samplerState)
void Renderer9::setSamplerState(gl::SamplerType type, int index, const gl::SamplerState &samplerState)
{
int d3dSamplerOffset = (type == gl::SAMPLER_PIXEL) ? 0 : D3DVERTEXTEXTURESAMPLER0;
int d3dSampler = index + d3dSamplerOffset;
......@@ -535,7 +534,7 @@ void Renderer::setSamplerState(gl::SamplerType type, int index, const gl::Sample
}
}
void Renderer::setTexture(gl::SamplerType type, int index, gl::Texture *texture)
void Renderer9::setTexture(gl::SamplerType type, int index, gl::Texture *texture)
{
int d3dSamplerOffset = (type == gl::SAMPLER_PIXEL) ? 0 : D3DVERTEXTEXTURESAMPLER0;
int d3dSampler = index + d3dSamplerOffset;
......@@ -553,7 +552,7 @@ void Renderer::setTexture(gl::SamplerType type, int index, gl::Texture *texture)
}
void Renderer::releaseDeviceResources()
void Renderer9::releaseDeviceResources()
{
while (!mEventQueryPool.empty())
{
......@@ -566,18 +565,18 @@ void Renderer::releaseDeviceResources()
}
void Renderer::markDeviceLost()
void Renderer9::markDeviceLost()
{
mDeviceLost = true;
}
bool Renderer::isDeviceLost()
bool Renderer9::isDeviceLost()
{
return mDeviceLost;
}
// set notify to true to broadcast a message to all contexts of the device loss
bool Renderer::testDeviceLost(bool notify)
bool Renderer9::testDeviceLost(bool notify)
{
bool isLost = false;
......@@ -611,7 +610,7 @@ bool Renderer::testDeviceLost(bool notify)
return isLost;
}
bool Renderer::testDeviceResettable()
bool Renderer9::testDeviceResettable()
{
HRESULT status = D3D_OK;
......@@ -634,7 +633,7 @@ bool Renderer::testDeviceResettable()
}
}
bool Renderer::resetDevice()
bool Renderer9::resetDevice()
{
releaseDeviceResources();
......@@ -683,22 +682,22 @@ bool Renderer::resetDevice()
return true;
}
DWORD Renderer::getAdapterVendor() const
DWORD Renderer9::getAdapterVendor() const
{
return mAdapterIdentifier.VendorId;
}
const char *Renderer::getAdapterDescription() const
const char *Renderer9::getAdapterDescription() const
{
return mAdapterIdentifier.Description;
}
GUID Renderer::getAdapterIdentifier() const
GUID Renderer9::getAdapterIdentifier() const
{
return mAdapterIdentifier.DeviceIdentifier;
}
void Renderer::getMultiSampleSupport(D3DFORMAT format, bool *multiSampleArray)
void Renderer9::getMultiSampleSupport(D3DFORMAT format, bool *multiSampleArray)
{
for (int multiSampleIndex = 0; multiSampleIndex <= D3DMULTISAMPLE_16_SAMPLES; multiSampleIndex++)
{
......@@ -709,7 +708,7 @@ void Renderer::getMultiSampleSupport(D3DFORMAT format, bool *multiSampleArray)
}
}
bool Renderer::getDXT1TextureSupport()
bool Renderer9::getDXT1TextureSupport()
{
D3DDISPLAYMODE currentDisplayMode;
mD3d9->GetAdapterDisplayMode(mAdapter, &currentDisplayMode);
......@@ -717,7 +716,7 @@ bool Renderer::getDXT1TextureSupport()
return SUCCEEDED(mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, 0, D3DRTYPE_TEXTURE, D3DFMT_DXT1));
}
bool Renderer::getDXT3TextureSupport()
bool Renderer9::getDXT3TextureSupport()
{
D3DDISPLAYMODE currentDisplayMode;
mD3d9->GetAdapterDisplayMode(mAdapter, &currentDisplayMode);
......@@ -725,7 +724,7 @@ bool Renderer::getDXT3TextureSupport()
return SUCCEEDED(mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, 0, D3DRTYPE_TEXTURE, D3DFMT_DXT3));
}
bool Renderer::getDXT5TextureSupport()
bool Renderer9::getDXT5TextureSupport()
{
D3DDISPLAYMODE currentDisplayMode;
mD3d9->GetAdapterDisplayMode(mAdapter, &currentDisplayMode);
......@@ -736,7 +735,7 @@ bool Renderer::getDXT5TextureSupport()
// we use INTZ for depth textures in Direct3D9
// we also want NULL texture support to ensure the we can make depth-only FBOs
// see http://aras-p.info/texts/D3D9GPUHacks.html
bool Renderer::getDepthTextureSupport() const
bool Renderer9::getDepthTextureSupport() const
{
D3DDISPLAYMODE currentDisplayMode;
mD3d9->GetAdapterDisplayMode(mAdapter, &currentDisplayMode);
......@@ -749,7 +748,7 @@ bool Renderer::getDepthTextureSupport() const
return intz && null;
}
bool Renderer::getFloat32TextureSupport(bool *filtering, bool *renderable)
bool Renderer9::getFloat32TextureSupport(bool *filtering, bool *renderable)
{
D3DDISPLAYMODE currentDisplayMode;
mD3d9->GetAdapterDisplayMode(mAdapter, &currentDisplayMode);
......@@ -777,7 +776,7 @@ bool Renderer::getFloat32TextureSupport(bool *filtering, bool *renderable)
}
}
bool Renderer::getFloat16TextureSupport(bool *filtering, bool *renderable)
bool Renderer9::getFloat16TextureSupport(bool *filtering, bool *renderable)
{
D3DDISPLAYMODE currentDisplayMode;
mD3d9->GetAdapterDisplayMode(mAdapter, &currentDisplayMode);
......@@ -805,7 +804,7 @@ bool Renderer::getFloat16TextureSupport(bool *filtering, bool *renderable)
}
}
bool Renderer::getLuminanceTextureSupport()
bool Renderer9::getLuminanceTextureSupport()
{
D3DDISPLAYMODE currentDisplayMode;
mD3d9->GetAdapterDisplayMode(mAdapter, &currentDisplayMode);
......@@ -813,7 +812,7 @@ bool Renderer::getLuminanceTextureSupport()
return SUCCEEDED(mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, 0, D3DRTYPE_TEXTURE, D3DFMT_L8));
}
bool Renderer::getLuminanceAlphaTextureSupport()
bool Renderer9::getLuminanceAlphaTextureSupport()
{
D3DDISPLAYMODE currentDisplayMode;
mD3d9->GetAdapterDisplayMode(mAdapter, &currentDisplayMode);
......@@ -821,12 +820,12 @@ bool Renderer::getLuminanceAlphaTextureSupport()
return SUCCEEDED(mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, 0, D3DRTYPE_TEXTURE, D3DFMT_A8L8));
}
bool Renderer::getTextureFilterAnisotropySupport() const
bool Renderer9::getTextureFilterAnisotropySupport() const
{
return mSupportsTextureFilterAnisotropy;
}
float Renderer::getTextureMaxAnisotropy() const
float Renderer9::getTextureMaxAnisotropy() const
{
if (mSupportsTextureFilterAnisotropy)
{
......@@ -835,7 +834,7 @@ float Renderer::getTextureMaxAnisotropy() const
return 1.0f;
}
bool Renderer::getEventQuerySupport()
bool Renderer9::getEventQuerySupport()
{
IDirect3DQuery9 *query = allocateEventQuery();
if (query)
......@@ -852,7 +851,7 @@ bool Renderer::getEventQuerySupport()
// Only Direct3D 10 ready devices support all the necessary vertex texture formats.
// We test this using D3D9 by checking support for the R16F format.
bool Renderer::getVertexTextureSupport() const
bool Renderer9::getVertexTextureSupport() const
{
if (!mDevice || mDeviceCaps.PixelShaderVersion < D3DPS_VERSION(3, 0))
{
......@@ -867,12 +866,12 @@ bool Renderer::getVertexTextureSupport() const
return SUCCEEDED(result);
}
bool Renderer::getNonPower2TextureSupport() const
bool Renderer9::getNonPower2TextureSupport() const
{
return mSupportsNonPower2Textures;
}
bool Renderer::getOcclusionQuerySupport() const
bool Renderer9::getOcclusionQuerySupport() const
{
if (!mDevice)
{
......@@ -892,64 +891,64 @@ bool Renderer::getOcclusionQuerySupport() const
}
}
bool Renderer::getInstancingSupport() const
bool Renderer9::getInstancingSupport() const
{
return mDeviceCaps.PixelShaderVersion >= D3DPS_VERSION(3, 0);
}
bool Renderer::getShareHandleSupport() const
bool Renderer9::getShareHandleSupport() const
{
// PIX doesn't seem to support using share handles, so disable them.
// D3D9_REPLACE
return (mD3d9Ex != NULL) && !gl::perfActive();
}
bool Renderer::getShaderModel3Support() const
bool Renderer9::getShaderModel3Support() const
{
return mDeviceCaps.PixelShaderVersion >= D3DPS_VERSION(3, 0);
}
float Renderer::getMaxPointSize() const
float Renderer9::getMaxPointSize() const
{
return mDeviceCaps.MaxPointSize;
}
int Renderer::getMaxTextureWidth() const
int Renderer9::getMaxTextureWidth() const
{
return (int)mDeviceCaps.MaxTextureWidth;
}
int Renderer::getMaxTextureHeight() const
int Renderer9::getMaxTextureHeight() const
{
return (int)mDeviceCaps.MaxTextureHeight;
}
bool Renderer::get32BitIndexSupport() const
bool Renderer9::get32BitIndexSupport() const
{
return mDeviceCaps.MaxVertexIndex >= (1 << 16);
}
DWORD Renderer::getCapsDeclTypes() const
DWORD Renderer9::getCapsDeclTypes() const
{
return mDeviceCaps.DeclTypes;
}
int Renderer::getMinSwapInterval() const
int Renderer9::getMinSwapInterval() const
{
return mMinSwapInterval;
}
int Renderer::getMaxSwapInterval() const
int Renderer9::getMaxSwapInterval() const
{
return mMaxSwapInterval;
}
int Renderer::getMaxSupportedSamples() const
int Renderer9::getMaxSupportedSamples() const
{
return mMaxSupportedSamples;
}
int Renderer::getNearestSupportedSamples(D3DFORMAT format, int requested) const
int Renderer9::getNearestSupportedSamples(D3DFORMAT format, int requested) const
{
if (requested == 0)
{
......@@ -975,7 +974,7 @@ int Renderer::getNearestSupportedSamples(D3DFORMAT format, int requested) const
return -1;
}
D3DPOOL Renderer::getBufferPool(DWORD usage) const
D3DPOOL Renderer9::getBufferPool(DWORD usage) const
{
if (mD3d9Ex != NULL)
{
......@@ -992,7 +991,7 @@ D3DPOOL Renderer::getBufferPool(DWORD usage) const
return D3DPOOL_DEFAULT;
}
D3DPOOL Renderer::getTexturePool(DWORD usage) const
D3DPOOL Renderer9::getTexturePool(DWORD usage) const
{
if (mD3d9Ex != NULL)
{
......
//
// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// Renderer.h: Defines a back-end specific class that hides the details of the
// implementation-specific renderer.
#ifndef LIBGLESV2_RENDERER_RENDERER9_H_
#define LIBGLESV2_RENDERER_RENDERER9_H_
#include <set>
#include <map>
#include <vector>
#define GL_APICALL
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#define EGLAPI
#include <EGL/egl.h>
#include <d3d9.h> // D3D9_REPLACE
#include "common/angleutils.h"
#include "libGLESv2/renderer/ShaderCache.h"
#include "libGLESv2/renderer/Renderer.h"
namespace renderer
{
class Renderer9 : public Renderer
{
public:
Renderer9(egl::Display *display, HMODULE hModule, HDC hDc);
virtual ~Renderer9();
virtual EGLint initialize();
virtual bool resetDevice();
virtual int generateConfigs(ConfigDesc **configDescList);
virtual void deleteConfigs(ConfigDesc *configDescList);
virtual void startScene();
virtual void endScene();
virtual void sync(bool block);
IDirect3DQuery9* allocateEventQuery();
void freeEventQuery(IDirect3DQuery9* query);
// resource creation
IDirect3DVertexShader9 *createVertexShader(const DWORD *function, size_t length); // D3D9_REPLACE
IDirect3DPixelShader9 *createPixelShader(const DWORD *function, size_t length); // D3D9_REPLACE
#if 0
void *createTexture2D();
void *createTextureCube();
void *createQuery();;
void *createIndexBuffer();
void *createVertexbuffer();
// state setup
void applyShaders();
void applyConstants();
void applyRenderTargets();
void applyState();
#endif
virtual void setSamplerState(gl::SamplerType type, int index, const gl::SamplerState &sampler);
virtual void setTexture(gl::SamplerType type, int index, gl::Texture *texture);
// lost device
virtual void markDeviceLost();
virtual bool isDeviceLost();
virtual bool testDeviceLost(bool notify);
virtual bool testDeviceResettable();
// Renderer capabilities
IDirect3DDevice9 *getDevice() {return mDevice;}; // D3D9_REPLACE
virtual DWORD getAdapterVendor() const;
virtual const char *getAdapterDescription() const;
virtual GUID getAdapterIdentifier() const;
virtual bool getDXT1TextureSupport();
virtual bool getDXT3TextureSupport();
virtual bool getDXT5TextureSupport();
virtual bool getEventQuerySupport();
virtual bool getFloat32TextureSupport(bool *filtering, bool *renderable);
virtual bool getFloat16TextureSupport(bool *filtering, bool *renderable);
virtual bool getLuminanceTextureSupport();
virtual bool getLuminanceAlphaTextureSupport();
virtual bool getVertexTextureSupport() const;
virtual bool getNonPower2TextureSupport() const;
virtual bool getDepthTextureSupport() const;
virtual bool getOcclusionQuerySupport() const;
virtual bool getInstancingSupport() const;
virtual bool getTextureFilterAnisotropySupport() const;
virtual float getTextureMaxAnisotropy() const;
virtual bool getShareHandleSupport() const;
virtual bool getShaderModel3Support() const;
virtual float getMaxPointSize() const;
virtual int getMaxTextureWidth() const;
virtual int getMaxTextureHeight() const;
virtual bool get32BitIndexSupport() const;
DWORD getCapsDeclTypes() const; // D3D9_REPLACE
virtual int getMinSwapInterval() const;
virtual int getMaxSwapInterval() const;
virtual GLsizei getMaxSupportedSamples() const;
int getNearestSupportedSamples(D3DFORMAT format, int requested) const;
D3DPOOL getBufferPool(DWORD usage) const;
D3DPOOL getTexturePool(DWORD usage) const;
private:
DISALLOW_COPY_AND_ASSIGN(Renderer9);
void getMultiSampleSupport(D3DFORMAT format, bool *multiSampleArray); // D3D9_REPLACE
static const D3DFORMAT mRenderTargetFormats[];
static const D3DFORMAT mDepthStencilFormats[];
HMODULE mD3d9Module;
HDC mDc;
void initializeDevice();
D3DPRESENT_PARAMETERS getDefaultPresentParameters();
void releaseDeviceResources();
UINT mAdapter;
D3DDEVTYPE mDeviceType;
IDirect3D9 *mD3d9; // Always valid after successful initialization.
IDirect3D9Ex *mD3d9Ex; // Might be null if D3D9Ex is not supported.
IDirect3DDevice9 *mDevice;
IDirect3DDevice9Ex *mDeviceEx; // Might be null if D3D9Ex is not supported.
HWND mDeviceWindow;
bool mDeviceLost;
D3DCAPS9 mDeviceCaps;
D3DADAPTER_IDENTIFIER9 mAdapterIdentifier;
bool mSceneStarted;
bool mSupportsNonPower2Textures;
bool mSupportsTextureFilterAnisotropy;
int mMinSwapInterval;
int mMaxSwapInterval;
std::map<D3DFORMAT, bool *> mMultiSampleSupport;
GLsizei mMaxSupportedSamples;
// A pool of event queries that are currently unused.
std::vector<IDirect3DQuery9*> mEventQueryPool;
VertexShaderCache mVertexShaderCache;
PixelShaderCache mPixelShaderCache;
};
}
#endif // LIBGLESV2_RENDERER_RENDERER9_H_
......@@ -11,13 +11,13 @@
#include "common/debug.h"
#include "libGLESv2/utilities.h"
#include "libGLESv2/renderer/Renderer.h"
#include "libGLESv2/renderer/Renderer9.h" // D3D9_REPLACE
#include "libGLESv2/Context.h"
namespace renderer
{
SwapChain::SwapChain(Renderer *renderer, HWND window, HANDLE shareHandle,
SwapChain::SwapChain(Renderer9 *renderer, HWND window, HANDLE shareHandle,
GLenum backBufferFormat, GLenum depthBufferFormat)
: mRenderer(renderer), mWindow(window), mShareHandle(shareHandle),
mBackBufferFormat(backBufferFormat), mDepthBufferFormat(depthBufferFormat)
......
......@@ -16,18 +16,18 @@
#define EGLAPI
#include <EGL/egl.h>
#include "common/angleutils.h"
#include <d3d9.h> // D3D9_REPLACE
#include <d3d9.h> // D3D9_REPLACE
#include "common/angleutils.h"
namespace renderer
{
class Renderer;
class Renderer9; // D3D9_REPLACE
class SwapChain
{
public:
SwapChain(Renderer *renderer, HWND window, HANDLE shareHandle,
SwapChain(Renderer9 *renderer, HWND window, HANDLE shareHandle,
GLenum backBufferFormat, GLenum depthBufferFormat);
virtual ~SwapChain();
......@@ -45,7 +45,7 @@ class SwapChain
void release();
Renderer *mRenderer;
Renderer9 *mRenderer; // D3D9_REPLACE
EGLint mHeight;
EGLint mWidth;
......
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