Add Renderer class and move functionality from Display

Trac #21727 Conflicts: src/libGLESv2/Texture.cpp src/libGLESv2/libGLESv2.vcxproj git-svn-id: https://angleproject.googlecode.com/svn/branches/dx11proto@1329 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 71621a88
...@@ -251,6 +251,8 @@ ...@@ -251,6 +251,8 @@
'libGLESv2/Query.cpp', 'libGLESv2/Query.cpp',
'libGLESv2/Renderbuffer.cpp', 'libGLESv2/Renderbuffer.cpp',
'libGLESv2/Renderbuffer.h', 'libGLESv2/Renderbuffer.h',
'libGLESv2/renderer/Renderer.cpp',
'libGLESv2/renderer/Renderer.h',
'libGLESv2/ResourceManager.cpp', 'libGLESv2/ResourceManager.cpp',
'libGLESv2/ResourceManager.h', 'libGLESv2/ResourceManager.h',
'libGLESv2/Shader.cpp', 'libGLESv2/Shader.cpp',
...@@ -268,6 +270,7 @@ ...@@ -268,6 +270,7 @@
'd3d9.lib', 'd3d9.lib',
'd3dx9.lib', 'd3dx9.lib',
'd3dcompiler.lib', 'd3dcompiler.lib',
'dxguid.lib',
], ],
} }
}, },
...@@ -304,7 +307,6 @@ ...@@ -304,7 +307,6 @@
'AdditionalLibraryDirectories': ['$(DXSDK_DIR)/lib/x86'], 'AdditionalLibraryDirectories': ['$(DXSDK_DIR)/lib/x86'],
'AdditionalDependencies': [ 'AdditionalDependencies': [
'd3d9.lib', 'd3d9.lib',
'dxguid.lib',
'dwmapi.lib', 'dwmapi.lib',
], ],
'DelayLoadDLLs': [ 'DelayLoadDLLs': [
......
...@@ -21,24 +21,12 @@ ...@@ -21,24 +21,12 @@
#include <vector> #include <vector>
#include "libGLESv2/Context.h" #include "libGLESv2/Context.h"
#include "libGLESv2/renderer/Renderer.h"
#include "libEGL/Config.h" #include "libEGL/Config.h"
#include "libEGL/ShaderCache.h" #include "libEGL/ShaderCache.h"
#include "libEGL/Surface.h" #include "libEGL/Surface.h"
const int versionWindowsVista = MAKEWORD(0x00, 0x06);
const int versionWindows7 = MAKEWORD(0x01, 0x06);
// Return the version of the operating system in a format suitable for ordering
// comparison.
inline int getComparableOSVersion()
{
DWORD version = GetVersion();
int majorVersion = LOBYTE(LOWORD(version));
int minorVersion = HIBYTE(LOWORD(version));
return MAKEWORD(minorVersion, majorVersion);
}
namespace egl namespace egl
{ {
class Display class Display
...@@ -49,9 +37,6 @@ class Display ...@@ -49,9 +37,6 @@ class Display
bool initialize(); bool initialize();
void terminate(); void terminate();
virtual void startScene();
virtual void endScene();
static egl::Display *getDisplay(EGLNativeDisplayType displayId); static egl::Display *getDisplay(EGLNativeDisplayType displayId);
bool getConfigs(EGLConfig *configs, const EGLint *attribList, EGLint configSize, EGLint *numConfig); bool getConfigs(EGLConfig *configs, const EGLint *attribList, EGLint configSize, EGLint *numConfig);
...@@ -73,36 +58,13 @@ class Display ...@@ -73,36 +58,13 @@ class Display
EGLint getMinSwapInterval(); EGLint getMinSwapInterval();
EGLint getMaxSwapInterval(); EGLint getMaxSwapInterval();
virtual IDirect3DDevice9 *getDevice(); renderer::Renderer *getRenderer() { return mRenderer; };
virtual D3DCAPS9 getDeviceCaps();
virtual D3DADAPTER_IDENTIFIER9 *getAdapterIdentifier();
virtual bool testDeviceLost();
virtual bool testDeviceResettable();
virtual void sync(bool block); virtual void sync(bool block);
virtual IDirect3DQuery9* allocateEventQuery(); virtual IDirect3DQuery9* allocateEventQuery();
virtual void freeEventQuery(IDirect3DQuery9* query); virtual void freeEventQuery(IDirect3DQuery9* query);
virtual void getMultiSampleSupport(D3DFORMAT format, bool *multiSampleArray);
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 float getTextureFilterAnisotropySupport() const;
virtual D3DPOOL getBufferPool(DWORD usage) const;
virtual D3DPOOL getTexturePool(DWORD usage) const;
virtual void notifyDeviceLost(); virtual void notifyDeviceLost();
bool isDeviceLost();
bool isD3d9ExDevice() const { return mD3d9Ex != NULL; }
const char *getExtensionString() const; const char *getExtensionString() const;
bool shareHandleSupported() const; bool shareHandleSupported() const;
...@@ -114,37 +76,20 @@ class Display ...@@ -114,37 +76,20 @@ class Display
Display(EGLNativeDisplayType displayId, HDC deviceContext, bool software); Display(EGLNativeDisplayType displayId, HDC deviceContext, bool software);
D3DPRESENT_PARAMETERS getDefaultPresentParameters();
bool restoreLostDevice(); bool restoreLostDevice();
EGLNativeDisplayType mDisplayId; EGLNativeDisplayType mDisplayId;
const HDC mDc; const HDC mDc;
HMODULE mD3d9Module;
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.
// A pool of event queries that are currently unused. // A pool of event queries that are currently unused.
std::vector<IDirect3DQuery9*> mEventQueryPool; std::vector<IDirect3DQuery9*> mEventQueryPool;
VertexShaderCache mVertexShaderCache; VertexShaderCache mVertexShaderCache;
PixelShaderCache mPixelShaderCache; PixelShaderCache mPixelShaderCache;
D3DCAPS9 mDeviceCaps;
D3DADAPTER_IDENTIFIER9 mAdapterIdentifier;
HWND mDeviceWindow;
bool mSceneStarted;
EGLint mMaxSwapInterval; EGLint mMaxSwapInterval;
EGLint mMinSwapInterval; EGLint mMinSwapInterval;
bool mSoftwareDevice; bool mSoftwareDevice;
bool mSupportsNonPower2Textures;
typedef std::set<Surface*> SurfaceSet; typedef std::set<Surface*> SurfaceSet;
SurfaceSet mSurfaceSet; SurfaceSet mSurfaceSet;
...@@ -153,11 +98,8 @@ class Display ...@@ -153,11 +98,8 @@ class Display
typedef std::set<gl::Context*> ContextSet; typedef std::set<gl::Context*> ContextSet;
ContextSet mContextSet; ContextSet mContextSet;
bool mDeviceLost;
bool createDevice(); renderer::Renderer *mRenderer;
void initializeDevice();
bool resetDevice();
void initExtensionString(); void initExtensionString();
std::string mExtensionString; std::string mExtensionString;
......
...@@ -159,9 +159,11 @@ bool Surface::resetSwapChain() ...@@ -159,9 +159,11 @@ bool Surface::resetSwapChain()
return resetSwapChain(windowRect.right - windowRect.left, windowRect.bottom - windowRect.top); return resetSwapChain(windowRect.right - windowRect.left, windowRect.bottom - windowRect.top);
} }
// D3D9_REPLACE
bool Surface::resetSwapChain(int backbufferWidth, int backbufferHeight) bool Surface::resetSwapChain(int backbufferWidth, int backbufferHeight)
{ {
IDirect3DDevice9 *device = mDisplay->getDevice(); renderer::Renderer *renderer = mDisplay->getRenderer();
IDirect3DDevice9 *device = renderer->getDevice();
if (device == NULL) if (device == NULL)
{ {
...@@ -248,7 +250,7 @@ bool Surface::resetSwapChain(int backbufferWidth, int backbufferHeight) ...@@ -248,7 +250,7 @@ bool Surface::resetSwapChain(int backbufferWidth, int backbufferHeight)
rect.bottom = backbufferHeight; rect.bottom = backbufferHeight;
} }
mDisplay->endScene(); renderer->endScene();
result = device->StretchRect(oldRenderTarget, &rect, mRenderTarget, &rect, D3DTEXF_NONE); result = device->StretchRect(oldRenderTarget, &rect, mRenderTarget, &rect, D3DTEXF_NONE);
ASSERT(SUCCEEDED(result)); ASSERT(SUCCEEDED(result));
...@@ -281,7 +283,7 @@ bool Surface::resetSwapChain(int backbufferWidth, int backbufferHeight) ...@@ -281,7 +283,7 @@ bool Surface::resetSwapChain(int backbufferWidth, int backbufferHeight)
// //
// Some non-switchable AMD GPUs / drivers do not respect the source rectangle to Present. Therefore, when the vendor ID // Some non-switchable AMD GPUs / drivers do not respect the source rectangle to Present. Therefore, when the vendor ID
// is not Intel, the back buffer width must be exactly the same width as the window or horizontal scaling will occur. // is not Intel, the back buffer width must be exactly the same width as the window or horizontal scaling will occur.
D3DADAPTER_IDENTIFIER9* adapterIdentifier = mDisplay->getAdapterIdentifier(); D3DADAPTER_IDENTIFIER9* adapterIdentifier = renderer->getAdapterIdentifier();
if (adapterIdentifier->VendorId == VENDOR_ID_INTEL) if (adapterIdentifier->VendorId == VENDOR_ID_INTEL)
{ {
presentParameters.BackBufferWidth = (presentParameters.BackBufferWidth + 63) / 64 * 64; presentParameters.BackBufferWidth = (presentParameters.BackBufferWidth + 63) / 64 * 64;
...@@ -364,7 +366,8 @@ bool Surface::swapRect(EGLint x, EGLint y, EGLint width, EGLint height) ...@@ -364,7 +366,8 @@ bool Surface::swapRect(EGLint x, EGLint y, EGLint width, EGLint height)
return true; return true;
} }
IDirect3DDevice9 *device = mDisplay->getDevice(); renderer::Renderer *renderer = mDisplay->getRenderer();
IDirect3DDevice9 *device = renderer->getDevice();
// Disable all pipeline operations // Disable all pipeline operations
device->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE); device->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
...@@ -411,9 +414,9 @@ bool Surface::swapRect(EGLint x, EGLint y, EGLint width, EGLint height) ...@@ -411,9 +414,9 @@ bool Surface::swapRect(EGLint x, EGLint y, EGLint width, EGLint height)
{x2, y2, 0.0f, 1.0f, u2, v1}, {x2, y2, 0.0f, 1.0f, u2, v1},
{x1, y2, 0.0f, 1.0f, u1, v1}}; // x, y, z, rhw, u, v {x1, y2, 0.0f, 1.0f, u1, v1}}; // x, y, z, rhw, u, v
mDisplay->startScene(); renderer->startScene();
device->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, quad, 6 * sizeof(float)); device->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, quad, 6 * sizeof(float));
mDisplay->endScene(); renderer->endScene();
device->SetTexture(0, NULL); device->SetTexture(0, NULL);
......
...@@ -877,22 +877,22 @@ EGLBoolean __stdcall eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface ...@@ -877,22 +877,22 @@ EGLBoolean __stdcall eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface
{ {
egl::Display *display = static_cast<egl::Display*>(dpy); egl::Display *display = static_cast<egl::Display*>(dpy);
gl::Context *context = static_cast<gl::Context*>(ctx); gl::Context *context = static_cast<gl::Context*>(ctx);
IDirect3DDevice9 *device = display->getDevice();
if (!device || display->testDeviceLost()) if (ctx != EGL_NO_CONTEXT && !validateContext(display, context))
{ {
display->notifyDeviceLost();
return EGL_FALSE; return EGL_FALSE;
} }
if (display->isDeviceLost()) renderer::Renderer *renderer = display->getRenderer();
if (renderer->testDeviceLost())
{ {
return error(EGL_CONTEXT_LOST, EGL_FALSE); display->notifyDeviceLost();
return EGL_FALSE;
} }
if (ctx != EGL_NO_CONTEXT && !validateContext(display, context)) if (renderer->isDeviceLost())
{ {
return EGL_FALSE; return error(EGL_CONTEXT_LOST, EGL_FALSE);
} }
if ((draw != EGL_NO_SURFACE && !validateSurface(display, static_cast<egl::Surface*>(draw))) || if ((draw != EGL_NO_SURFACE && !validateSurface(display, static_cast<egl::Surface*>(draw))) ||
...@@ -1050,7 +1050,7 @@ EGLBoolean __stdcall eglSwapBuffers(EGLDisplay dpy, EGLSurface surface) ...@@ -1050,7 +1050,7 @@ EGLBoolean __stdcall eglSwapBuffers(EGLDisplay dpy, EGLSurface surface)
return EGL_FALSE; return EGL_FALSE;
} }
if (display->isDeviceLost()) if (display->getRenderer()->isDeviceLost())
{ {
return error(EGL_CONTEXT_LOST, EGL_FALSE); return error(EGL_CONTEXT_LOST, EGL_FALSE);
} }
...@@ -1087,7 +1087,7 @@ EGLBoolean __stdcall eglCopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNativ ...@@ -1087,7 +1087,7 @@ EGLBoolean __stdcall eglCopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNativ
return EGL_FALSE; return EGL_FALSE;
} }
if (display->isDeviceLost()) if (display->getRenderer()->isDeviceLost())
{ {
return error(EGL_CONTEXT_LOST, EGL_FALSE); return error(EGL_CONTEXT_LOST, EGL_FALSE);
} }
...@@ -1121,7 +1121,7 @@ EGLBoolean __stdcall eglPostSubBufferNV(EGLDisplay dpy, EGLSurface surface, EGLi ...@@ -1121,7 +1121,7 @@ EGLBoolean __stdcall eglPostSubBufferNV(EGLDisplay dpy, EGLSurface surface, EGLi
return EGL_FALSE; return EGL_FALSE;
} }
if (display->isDeviceLost()) if (display->getRenderer()->isDeviceLost())
{ {
return error(EGL_CONTEXT_LOST, EGL_FALSE); return error(EGL_CONTEXT_LOST, EGL_FALSE);
} }
......
...@@ -93,7 +93,7 @@ ...@@ -93,7 +93,7 @@
<DisableSpecificWarnings>4100;4127;4189;4239;4244;4245;4512;4702;%(DisableSpecificWarnings)</DisableSpecificWarnings> <DisableSpecificWarnings>4100;4127;4189;4239;4244;4245;4512;4702;%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile> </ClCompile>
<Link> <Link>
<AdditionalDependencies>d3d9.lib;dxguid.lib;dwmapi.lib;%(AdditionalDependencies)</AdditionalDependencies> <AdditionalDependencies>d3d9.lib;dwmapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ModuleDefinitionFile>libEGL.def</ModuleDefinitionFile> <ModuleDefinitionFile>libEGL.def</ModuleDefinitionFile>
<DelayLoadDLLs>dwmapi.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <DelayLoadDLLs>dwmapi.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
...@@ -127,7 +127,7 @@ copy "$(OutDir)libEGL.lib" "$(ProjectDir)..\..\lib\$(Configuration)\" ...@@ -127,7 +127,7 @@ copy "$(OutDir)libEGL.lib" "$(ProjectDir)..\..\lib\$(Configuration)\"
<DisableSpecificWarnings>4100;4127;4189;4239;4244;4245;4512;4702;%(DisableSpecificWarnings)</DisableSpecificWarnings> <DisableSpecificWarnings>4100;4127;4189;4239;4244;4245;4512;4702;%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile> </ClCompile>
<Link> <Link>
<AdditionalDependencies>d3d9.lib;dxguid.lib;dwmapi.lib;%(AdditionalDependencies)</AdditionalDependencies> <AdditionalDependencies>d3d9.lib;dwmapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ModuleDefinitionFile>libEGL.def</ModuleDefinitionFile> <ModuleDefinitionFile>libEGL.def</ModuleDefinitionFile>
<DelayLoadDLLs>dwmapi.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <DelayLoadDLLs>dwmapi.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
...@@ -167,7 +167,7 @@ copy "$(OutDir)libEGL.lib" "$(ProjectDir)..\..\lib\$(Configuration)\" ...@@ -167,7 +167,7 @@ copy "$(OutDir)libEGL.lib" "$(ProjectDir)..\..\lib\$(Configuration)\"
<TreatWarningAsError>true</TreatWarningAsError> <TreatWarningAsError>true</TreatWarningAsError>
</ClCompile> </ClCompile>
<Link> <Link>
<AdditionalDependencies>d3d9.lib;dxguid.lib;dwmapi.lib;%(AdditionalDependencies)</AdditionalDependencies> <AdditionalDependencies>d3d9.lib;dwmapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ModuleDefinitionFile>libEGL.def</ModuleDefinitionFile> <ModuleDefinitionFile>libEGL.def</ModuleDefinitionFile>
<DelayLoadDLLs>dwmapi.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <DelayLoadDLLs>dwmapi.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
...@@ -204,7 +204,7 @@ copy "$(OutDir)libEGL.lib" "$(ProjectDir)..\..\lib\$(Configuration)\" ...@@ -204,7 +204,7 @@ copy "$(OutDir)libEGL.lib" "$(ProjectDir)..\..\lib\$(Configuration)\"
<TreatWarningAsError>true</TreatWarningAsError> <TreatWarningAsError>true</TreatWarningAsError>
</ClCompile> </ClCompile>
<Link> <Link>
<AdditionalDependencies>d3d9.lib;dxguid.lib;dwmapi.lib;%(AdditionalDependencies)</AdditionalDependencies> <AdditionalDependencies>d3d9.lib;dwmapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ModuleDefinitionFile>libEGL.def</ModuleDefinitionFile> <ModuleDefinitionFile>libEGL.def</ModuleDefinitionFile>
<DelayLoadDLLs>dwmapi.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <DelayLoadDLLs>dwmapi.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
...@@ -254,9 +254,13 @@ copy "$(OutDir)libEGL.lib" "$(ProjectDir)..\..\lib\$(Configuration)\" ...@@ -254,9 +254,13 @@ copy "$(OutDir)libEGL.lib" "$(ProjectDir)..\..\lib\$(Configuration)\"
<ProjectReference Include="..\libGLESv2\libGLESv2.vcxproj"> <ProjectReference Include="..\libGLESv2\libGLESv2.vcxproj">
<Project>{b5871a7a-968c-42e3-a33b-981e6f448e78}</Project> <Project>{b5871a7a-968c-42e3-a33b-981e6f448e78}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly> <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
<Private>true</Private>
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
<LinkLibraryDependencies>true</LinkLibraryDependencies>
<UseLibraryDependencyInputs>true</UseLibraryDependencyInputs>
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<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
...@@ -64,6 +64,7 @@ Blit::~Blit() ...@@ -64,6 +64,7 @@ Blit::~Blit()
} }
} }
// D3D9_REPLACE
void Blit::initGeometry() void Blit::initGeometry()
{ {
static const float quad[] = static const float quad[] =
...@@ -117,7 +118,7 @@ bool Blit::setShader(ShaderId source, const char *profile, ...@@ -117,7 +118,7 @@ bool Blit::setShader(ShaderId source, const char *profile,
HRESULT (WINAPI IDirect3DDevice9::*setShader)(D3DShaderType*)) HRESULT (WINAPI IDirect3DDevice9::*setShader)(D3DShaderType*))
{ {
egl::Display *display = getDisplay(); egl::Display *display = getDisplay();
IDirect3DDevice9 *device = display->getDevice(); IDirect3DDevice9 *device = display->getRenderer()->getDevice(); // D3D9_REPLACE
D3DShaderType *shader; D3DShaderType *shader;
...@@ -183,6 +184,7 @@ bool Blit::boxFilter(IDirect3DSurface9 *source, IDirect3DSurface9 *dest) ...@@ -183,6 +184,7 @@ bool Blit::boxFilter(IDirect3DSurface9 *source, IDirect3DSurface9 *dest)
return false; return false;
} }
// D3D9_REPLACE
IDirect3DDevice9 *device = getDevice(); IDirect3DDevice9 *device = getDevice();
saveState(); saveState();
...@@ -210,6 +212,7 @@ bool Blit::boxFilter(IDirect3DSurface9 *source, IDirect3DSurface9 *dest) ...@@ -210,6 +212,7 @@ bool Blit::boxFilter(IDirect3DSurface9 *source, IDirect3DSurface9 *dest)
bool Blit::copy(IDirect3DSurface9 *source, const RECT &sourceRect, GLenum destFormat, GLint xoffset, GLint yoffset, IDirect3DSurface9 *dest) bool Blit::copy(IDirect3DSurface9 *source, const RECT &sourceRect, GLenum destFormat, GLint xoffset, GLint yoffset, IDirect3DSurface9 *dest)
{ {
// D3D9_REPLACE
IDirect3DDevice9 *device = getDevice(); IDirect3DDevice9 *device = getDevice();
D3DSURFACE_DESC sourceDesc; D3DSURFACE_DESC sourceDesc;
...@@ -245,6 +248,7 @@ bool Blit::formatConvert(IDirect3DSurface9 *source, const RECT &sourceRect, GLen ...@@ -245,6 +248,7 @@ bool Blit::formatConvert(IDirect3DSurface9 *source, const RECT &sourceRect, GLen
return false; return false;
} }
// D3D9_REPLACE
IDirect3DDevice9 *device = getDevice(); IDirect3DDevice9 *device = getDevice();
saveState(); saveState();
...@@ -330,6 +334,7 @@ bool Blit::setFormatConvertShaders(GLenum destFormat) ...@@ -330,6 +334,7 @@ bool Blit::setFormatConvertShaders(GLenum destFormat)
return true; return true;
} }
// D3D9_REPLACE
IDirect3DTexture9 *Blit::copySurfaceToTexture(IDirect3DSurface9 *surface, const RECT &sourceRect) IDirect3DTexture9 *Blit::copySurfaceToTexture(IDirect3DSurface9 *surface, const RECT &sourceRect)
{ {
if (!surface) if (!surface)
...@@ -338,7 +343,8 @@ IDirect3DTexture9 *Blit::copySurfaceToTexture(IDirect3DSurface9 *surface, const ...@@ -338,7 +343,8 @@ IDirect3DTexture9 *Blit::copySurfaceToTexture(IDirect3DSurface9 *surface, const
} }
egl::Display *display = getDisplay(); egl::Display *display = getDisplay();
IDirect3DDevice9 *device = getDevice(); renderer::Renderer *renderer = display->getRenderer();
IDirect3DDevice9 *device = renderer->getDevice(); // D3D9_REPLACE
D3DSURFACE_DESC sourceDesc; D3DSURFACE_DESC sourceDesc;
surface->GetDesc(&sourceDesc); surface->GetDesc(&sourceDesc);
...@@ -363,7 +369,7 @@ IDirect3DTexture9 *Blit::copySurfaceToTexture(IDirect3DSurface9 *surface, const ...@@ -363,7 +369,7 @@ IDirect3DTexture9 *Blit::copySurfaceToTexture(IDirect3DSurface9 *surface, const
return error(GL_OUT_OF_MEMORY, (IDirect3DTexture9*)NULL); return error(GL_OUT_OF_MEMORY, (IDirect3DTexture9*)NULL);
} }
display->endScene(); renderer->endScene();
result = device->StretchRect(surface, &sourceRect, textureSurface, NULL, D3DTEXF_NONE); result = device->StretchRect(surface, &sourceRect, textureSurface, NULL, D3DTEXF_NONE);
textureSurface->Release(); textureSurface->Release();
...@@ -380,7 +386,7 @@ IDirect3DTexture9 *Blit::copySurfaceToTexture(IDirect3DSurface9 *surface, const ...@@ -380,7 +386,7 @@ IDirect3DTexture9 *Blit::copySurfaceToTexture(IDirect3DSurface9 *surface, const
void Blit::setViewport(const RECT &sourceRect, GLint xoffset, GLint yoffset) void Blit::setViewport(const RECT &sourceRect, GLint xoffset, GLint yoffset)
{ {
IDirect3DDevice9 *device = getDevice(); IDirect3DDevice9 *device = getDevice(); // D3D9_REPLACE
D3DVIEWPORT9 vp; D3DVIEWPORT9 vp;
vp.X = xoffset; vp.X = xoffset;
...@@ -395,6 +401,7 @@ void Blit::setViewport(const RECT &sourceRect, GLint xoffset, GLint yoffset) ...@@ -395,6 +401,7 @@ void Blit::setViewport(const RECT &sourceRect, GLint xoffset, GLint yoffset)
device->SetVertexShaderConstantF(0, halfPixelAdjust, 1); device->SetVertexShaderConstantF(0, halfPixelAdjust, 1);
} }
// D3D9_REPLACE
void Blit::setCommonBlitState() void Blit::setCommonBlitState()
{ {
IDirect3DDevice9 *device = getDevice(); IDirect3DDevice9 *device = getDevice();
...@@ -425,18 +432,21 @@ void Blit::setCommonBlitState() ...@@ -425,18 +432,21 @@ void Blit::setCommonBlitState()
} }
} }
// D3D9_REPLACE
void Blit::render() void Blit::render()
{ {
egl::Display *display = getDisplay(); egl::Display *display = getDisplay();
IDirect3DDevice9 *device = getDevice(); renderer::Renderer *renderer = display->getRenderer();
IDirect3DDevice9 *device = renderer->getDevice();
HRESULT hr = device->SetStreamSource(0, mQuadVertexBuffer, 0, 2 * sizeof(float)); HRESULT hr = device->SetStreamSource(0, mQuadVertexBuffer, 0, 2 * sizeof(float));
hr = device->SetVertexDeclaration(mQuadVertexDeclaration); hr = device->SetVertexDeclaration(mQuadVertexDeclaration);
display->startScene(); renderer->startScene();
hr = device->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2); hr = device->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);
} }
// D3D9_REPLACE
void Blit::saveState() void Blit::saveState()
{ {
IDirect3DDevice9 *device = getDevice(); IDirect3DDevice9 *device = getDevice();
...@@ -489,6 +499,7 @@ void Blit::saveState() ...@@ -489,6 +499,7 @@ void Blit::saveState()
} }
} }
// D3D9_REPLACE
void Blit::restoreState() void Blit::restoreState()
{ {
IDirect3DDevice9 *device = getDevice(); IDirect3DDevice9 *device = getDevice();
......
...@@ -255,11 +255,12 @@ Context::~Context() ...@@ -255,11 +255,12 @@ Context::~Context()
void Context::makeCurrent(egl::Display *display, egl::Surface *surface) void Context::makeCurrent(egl::Display *display, egl::Surface *surface)
{ {
mDisplay = display; mDisplay = display;
mDevice = mDisplay->getDevice(); mRenderer = mDisplay->getRenderer();
mDevice = mRenderer->getDevice(); // D3D9_REMOVE
if (!mHasBeenCurrent) if (!mHasBeenCurrent)
{ {
mDeviceCaps = mDisplay->getDeviceCaps(); mDeviceCaps = mRenderer->getDeviceCaps(); // D3D9_REMOVE
mVertexDataManager = new VertexDataManager(this, mDevice); mVertexDataManager = new VertexDataManager(this, mDevice);
mIndexDataManager = new IndexDataManager(this, mDevice); mIndexDataManager = new IndexDataManager(this, mDevice);
...@@ -267,16 +268,16 @@ void Context::makeCurrent(egl::Display *display, egl::Surface *surface) ...@@ -267,16 +268,16 @@ void Context::makeCurrent(egl::Display *display, egl::Surface *surface)
mSupportsShaderModel3 = mDeviceCaps.PixelShaderVersion >= D3DPS_VERSION(3, 0); mSupportsShaderModel3 = mDeviceCaps.PixelShaderVersion >= D3DPS_VERSION(3, 0);
mMaximumPointSize = mDeviceCaps.MaxPointSize; mMaximumPointSize = mDeviceCaps.MaxPointSize;
mSupportsVertexTexture = mDisplay->getVertexTextureSupport(); mSupportsVertexTexture = mRenderer->getVertexTextureSupport();
mSupportsNonPower2Texture = mDisplay->getNonPower2TextureSupport(); mSupportsNonPower2Texture = mRenderer->getNonPower2TextureSupport();
mSupportsInstancing = mDisplay->getInstancingSupport(); mSupportsInstancing = mRenderer->getInstancingSupport();
mMaxTextureDimension = std::min(std::min((int)mDeviceCaps.MaxTextureWidth, (int)mDeviceCaps.MaxTextureHeight), mMaxTextureDimension = std::min(std::min((int)mDeviceCaps.MaxTextureWidth, (int)mDeviceCaps.MaxTextureHeight),
(int)gl::IMPLEMENTATION_MAX_TEXTURE_SIZE); (int)gl::IMPLEMENTATION_MAX_TEXTURE_SIZE);
mMaxCubeTextureDimension = std::min(mMaxTextureDimension, (int)gl::IMPLEMENTATION_MAX_CUBE_MAP_TEXTURE_SIZE); mMaxCubeTextureDimension = std::min(mMaxTextureDimension, (int)gl::IMPLEMENTATION_MAX_CUBE_MAP_TEXTURE_SIZE);
mMaxRenderbufferDimension = mMaxTextureDimension; mMaxRenderbufferDimension = mMaxTextureDimension;
mMaxTextureLevel = log2(mMaxTextureDimension) + 1; mMaxTextureLevel = log2(mMaxTextureDimension) + 1;
mMaxTextureAnisotropy = mDisplay->getTextureFilterAnisotropySupport(); mMaxTextureAnisotropy = mRenderer->getTextureFilterAnisotropySupport();
TRACE("MaxTextureDimension=%d, MaxCubeTextureDimension=%d, MaxRenderbufferDimension=%d, MaxTextureLevel=%d, MaxTextureAnisotropy=%f", TRACE("MaxTextureDimension=%d, MaxCubeTextureDimension=%d, MaxRenderbufferDimension=%d, MaxTextureLevel=%d, MaxTextureAnisotropy=%f",
mMaxTextureDimension, mMaxCubeTextureDimension, mMaxRenderbufferDimension, mMaxTextureLevel, mMaxTextureAnisotropy); mMaxTextureDimension, mMaxCubeTextureDimension, mMaxRenderbufferDimension, mMaxTextureLevel, mMaxTextureAnisotropy);
...@@ -292,7 +293,7 @@ void Context::makeCurrent(egl::Display *display, egl::Surface *surface) ...@@ -292,7 +293,7 @@ void Context::makeCurrent(egl::Display *display, egl::Surface *surface)
for (int i = 0; i < sizeof(renderBufferFormats) / sizeof(D3DFORMAT); ++i) for (int i = 0; i < sizeof(renderBufferFormats) / sizeof(D3DFORMAT); ++i)
{ {
bool *multisampleArray = new bool[D3DMULTISAMPLE_16_SAMPLES + 1]; bool *multisampleArray = new bool[D3DMULTISAMPLE_16_SAMPLES + 1];
mDisplay->getMultiSampleSupport(renderBufferFormats[i], multisampleArray); mRenderer->getMultiSampleSupport(renderBufferFormats[i], multisampleArray);
mMultiSampleSupport[renderBufferFormats[i]] = multisampleArray; mMultiSampleSupport[renderBufferFormats[i]] = multisampleArray;
for (int j = D3DMULTISAMPLE_16_SAMPLES; j >= 0; --j) for (int j = D3DMULTISAMPLE_16_SAMPLES; j >= 0; --j)
...@@ -306,16 +307,16 @@ void Context::makeCurrent(egl::Display *display, egl::Surface *surface) ...@@ -306,16 +307,16 @@ void Context::makeCurrent(egl::Display *display, egl::Surface *surface)
mMaxSupportedSamples = max; mMaxSupportedSamples = max;
mSupportsEventQueries = mDisplay->getEventQuerySupport(); mSupportsEventQueries = mRenderer->getEventQuerySupport();
mSupportsOcclusionQueries = mDisplay->getOcclusionQuerySupport(); mSupportsOcclusionQueries = mRenderer->getOcclusionQuerySupport();
mSupportsDXT1Textures = mDisplay->getDXT1TextureSupport(); mSupportsDXT1Textures = mRenderer->getDXT1TextureSupport();
mSupportsDXT3Textures = mDisplay->getDXT3TextureSupport(); mSupportsDXT3Textures = mRenderer->getDXT3TextureSupport();
mSupportsDXT5Textures = mDisplay->getDXT5TextureSupport(); mSupportsDXT5Textures = mRenderer->getDXT5TextureSupport();
mSupportsFloat32Textures = mDisplay->getFloat32TextureSupport(&mSupportsFloat32LinearFilter, &mSupportsFloat32RenderableTextures); mSupportsFloat32Textures = mRenderer->getFloat32TextureSupport(&mSupportsFloat32LinearFilter, &mSupportsFloat32RenderableTextures);
mSupportsFloat16Textures = mDisplay->getFloat16TextureSupport(&mSupportsFloat16LinearFilter, &mSupportsFloat16RenderableTextures); mSupportsFloat16Textures = mRenderer->getFloat16TextureSupport(&mSupportsFloat16LinearFilter, &mSupportsFloat16RenderableTextures);
mSupportsLuminanceTextures = mDisplay->getLuminanceTextureSupport(); mSupportsLuminanceTextures = mRenderer->getLuminanceTextureSupport();
mSupportsLuminanceAlphaTextures = mDisplay->getLuminanceAlphaTextureSupport(); mSupportsLuminanceAlphaTextures = mRenderer->getLuminanceAlphaTextureSupport();
mSupportsDepthTextures = mDisplay->getDepthTextureSupport(); mSupportsDepthTextures = mRenderer->getDepthTextureSupport();
mSupportsTextureFilterAnisotropy = mMaxTextureAnisotropy >= 2.0f; mSupportsTextureFilterAnisotropy = mMaxTextureAnisotropy >= 2.0f;
mSupports32bitIndices = mDeviceCaps.MaxVertexIndex >= (1 << 16); mSupports32bitIndices = mDeviceCaps.MaxVertexIndex >= (1 << 16);
...@@ -2100,7 +2101,7 @@ void Context::applyState(GLenum drawMode) ...@@ -2100,7 +2101,7 @@ void Context::applyState(GLenum drawMode)
GLint alwaysFront = !isTriangleMode(drawMode); GLint alwaysFront = !isTriangleMode(drawMode);
programBinary->setUniform1iv(pointsOrLines, 1, &alwaysFront); programBinary->setUniform1iv(pointsOrLines, 1, &alwaysFront);
D3DADAPTER_IDENTIFIER9 *identifier = mDisplay->getAdapterIdentifier(); D3DADAPTER_IDENTIFIER9 *identifier = mRenderer->getAdapterIdentifier();
bool zeroColorMaskAllowed = identifier->VendorId != 0x1002; bool zeroColorMaskAllowed = identifier->VendorId != 0x1002;
// Apparently some ATI cards have a bug where a draw with a zero color // Apparently some ATI cards have a bug where a draw with a zero color
// write mask can cause later draws to have incorrect results. Instead, // write mask can cause later draws to have incorrect results. Instead,
...@@ -2536,7 +2537,7 @@ void Context::readPixels(GLint x, GLint y, GLsizei width, GLsizei height, ...@@ -2536,7 +2537,7 @@ void Context::readPixels(GLint x, GLint y, GLsizei width, GLsizei height,
HRESULT result; HRESULT result;
IDirect3DSurface9 *systemSurface = NULL; IDirect3DSurface9 *systemSurface = NULL;
bool directToPixels = !getPackReverseRowOrder() && getPackAlignment() <= 4 && mDisplay->isD3d9ExDevice() && bool directToPixels = !getPackReverseRowOrder() && getPackAlignment() <= 4 && mRenderer->isD3d9ExDevice() &&
x == 0 && y == 0 && UINT(width) == desc.Width && UINT(height) == desc.Height && x == 0 && y == 0 && UINT(width) == desc.Width && UINT(height) == desc.Height &&
desc.Format == D3DFMT_A8R8G8B8 && format == GL_BGRA_EXT && type == GL_UNSIGNED_BYTE; desc.Format == D3DFMT_A8R8G8B8 && format == GL_BGRA_EXT && type == GL_UNSIGNED_BYTE;
if (directToPixels) if (directToPixels)
...@@ -3039,7 +3040,7 @@ void Context::clear(GLbitfield mask) ...@@ -3039,7 +3040,7 @@ void Context::clear(GLbitfield mask)
quad[3][2] = 0.0f; quad[3][2] = 0.0f;
quad[3][3] = 1.0f; quad[3][3] = 1.0f;
mDisplay->startScene(); mRenderer->startScene();
mDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, quad, sizeof(float[4])); mDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, quad, sizeof(float[4]));
if (flags & D3DCLEAR_ZBUFFER) if (flags & D3DCLEAR_ZBUFFER)
...@@ -3102,7 +3103,7 @@ void Context::drawArrays(GLenum mode, GLint first, GLsizei count, GLsizei instan ...@@ -3102,7 +3103,7 @@ void Context::drawArrays(GLenum mode, GLint first, GLsizei count, GLsizei instan
if (!skipDraw(mode)) if (!skipDraw(mode))
{ {
mDisplay->startScene(); mRenderer->startScene();
if (mode == GL_LINE_LOOP) if (mode == GL_LINE_LOOP)
{ {
...@@ -3192,7 +3193,7 @@ void Context::drawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid ...@@ -3192,7 +3193,7 @@ void Context::drawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid
if (!skipDraw(mode)) if (!skipDraw(mode))
{ {
mDisplay->startScene(); mRenderer->startScene();
if (mode == GL_LINE_LOOP) if (mode == GL_LINE_LOOP)
{ {
...@@ -3430,7 +3431,7 @@ GLenum Context::getResetStatus() ...@@ -3430,7 +3431,7 @@ GLenum Context::getResetStatus()
{ {
if (mResetStatus == GL_NO_ERROR) if (mResetStatus == GL_NO_ERROR)
{ {
bool lost = mDisplay->testDeviceLost(); bool lost = mRenderer->testDeviceLost();
if (lost) if (lost)
{ {
...@@ -3442,7 +3443,7 @@ GLenum Context::getResetStatus() ...@@ -3442,7 +3443,7 @@ GLenum Context::getResetStatus()
if (mResetStatus != GL_NO_ERROR) if (mResetStatus != GL_NO_ERROR)
{ {
if (mDisplay->testDeviceResettable()) if (mRenderer->testDeviceResettable())
{ {
mResetStatus = GL_NO_ERROR; mResetStatus = GL_NO_ERROR;
} }
...@@ -3984,7 +3985,7 @@ const char *Context::getExtensionString() const ...@@ -3984,7 +3985,7 @@ const char *Context::getExtensionString() const
void Context::initRendererString() void Context::initRendererString()
{ {
D3DADAPTER_IDENTIFIER9 *identifier = mDisplay->getAdapterIdentifier(); D3DADAPTER_IDENTIFIER9 *identifier = mRenderer->getAdapterIdentifier();
mRendererString = "ANGLE ("; mRendererString = "ANGLE (";
mRendererString += identifier->Description; mRendererString += identifier->Description;
...@@ -4240,7 +4241,7 @@ void Context::blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1 ...@@ -4240,7 +4241,7 @@ void Context::blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1
if (blitRenderTarget || blitDepthStencil) if (blitRenderTarget || blitDepthStencil)
{ {
mDisplay->endScene(); mRenderer->endScene();
if (blitRenderTarget) if (blitRenderTarget)
{ {
...@@ -4498,4 +4499,15 @@ gl::Context *glGetCurrentContext() ...@@ -4498,4 +4499,15 @@ gl::Context *glGetCurrentContext()
{ {
return gl::getContext(); return gl::getContext();
} }
renderer::Renderer *glCreateRenderer(HMODULE hModule, HDC hDc)
{
return new renderer::Renderer(hModule, hDc);
}
void glDestroyRenderer(renderer::Renderer *renderer)
{
delete renderer;
}
} }
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include "common/RefCountObject.h" #include "common/RefCountObject.h"
#include "libGLESv2/ResourceManager.h" #include "libGLESv2/ResourceManager.h"
#include "libGLESv2/HandleAllocator.h" #include "libGLESv2/HandleAllocator.h"
#include "libGLESv2/renderer/Renderer.h"
namespace egl namespace egl
{ {
...@@ -549,6 +550,7 @@ class Context ...@@ -549,6 +550,7 @@ class Context
const egl::Config *const mConfig; const egl::Config *const mConfig;
egl::Display *mDisplay; egl::Display *mDisplay;
IDirect3DDevice9 *mDevice; IDirect3DDevice9 *mDevice;
renderer::Renderer *mRenderer;
State mState; State mState;
...@@ -678,6 +680,9 @@ gl::Context *glCreateContext(const egl::Config *config, const gl::Context *share ...@@ -678,6 +680,9 @@ gl::Context *glCreateContext(const egl::Config *config, const gl::Context *share
void glDestroyContext(gl::Context *context); void glDestroyContext(gl::Context *context);
void glMakeCurrent(gl::Context *context, egl::Display *display, egl::Surface *surface); void glMakeCurrent(gl::Context *context, egl::Display *display, egl::Surface *surface);
gl::Context *glGetCurrentContext(); gl::Context *glGetCurrentContext();
renderer::Renderer *glCreateRenderer(HMODULE hModule, HDC hDc);
void glDestroyRenderer(renderer::Renderer *renderer);
__eglMustCastToProperFunctionPointerType __stdcall glGetProcAddress(const char *procname); __eglMustCastToProperFunctionPointerType __stdcall glGetProcAddress(const char *procname);
bool __stdcall glBindTexImage(egl::Surface *surface); bool __stdcall glBindTexImage(egl::Surface *surface);
} }
......
...@@ -285,7 +285,8 @@ IndexBuffer::IndexBuffer(IDirect3DDevice9 *device, UINT size, D3DFORMAT format) ...@@ -285,7 +285,8 @@ IndexBuffer::IndexBuffer(IDirect3DDevice9 *device, UINT size, D3DFORMAT format)
{ {
if (size > 0) if (size > 0)
{ {
D3DPOOL pool = getDisplay()->getBufferPool(D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY); // D3D9_REPLACE
D3DPOOL pool = getDisplay()->getRenderer()->getBufferPool(D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY);
HRESULT result = device->CreateIndexBuffer(size, D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, format, pool, &mIndexBuffer, NULL); HRESULT result = device->CreateIndexBuffer(size, D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, format, pool, &mIndexBuffer, NULL);
mSerial = issueSerial(); mSerial = issueSerial();
...@@ -369,7 +370,8 @@ void StreamingIndexBuffer::reserveSpace(UINT requiredSpace, GLenum type) ...@@ -369,7 +370,8 @@ void StreamingIndexBuffer::reserveSpace(UINT requiredSpace, GLenum type)
mBufferSize = std::max(requiredSpace, 2 * mBufferSize); mBufferSize = std::max(requiredSpace, 2 * mBufferSize);
D3DPOOL pool = getDisplay()->getBufferPool(D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY); // D3D9_REPLACE
D3DPOOL pool = getDisplay()->getRenderer()->getBufferPool(D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY);
HRESULT result = mDevice->CreateIndexBuffer(mBufferSize, D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, type == GL_UNSIGNED_INT ? D3DFMT_INDEX32 : D3DFMT_INDEX16, pool, &mIndexBuffer, NULL); HRESULT result = mDevice->CreateIndexBuffer(mBufferSize, D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, type == GL_UNSIGNED_INT ? D3DFMT_INDEX32 : D3DFMT_INDEX16, pool, &mIndexBuffer, NULL);
mSerial = issueSerial(); mSerial = issueSerial();
...@@ -423,7 +425,8 @@ void StaticIndexBuffer::reserveSpace(UINT requiredSpace, GLenum type) ...@@ -423,7 +425,8 @@ void StaticIndexBuffer::reserveSpace(UINT requiredSpace, GLenum type)
{ {
if (!mIndexBuffer && mBufferSize == 0) if (!mIndexBuffer && mBufferSize == 0)
{ {
D3DPOOL pool = getDisplay()->getBufferPool(D3DUSAGE_WRITEONLY); // D3D9_REPLACE
D3DPOOL pool = getDisplay()->getRenderer()->getBufferPool(D3DUSAGE_WRITEONLY);
HRESULT result = mDevice->CreateIndexBuffer(requiredSpace, D3DUSAGE_WRITEONLY, type == GL_UNSIGNED_INT ? D3DFMT_INDEX32 : D3DFMT_INDEX16, pool, &mIndexBuffer, NULL); HRESULT result = mDevice->CreateIndexBuffer(requiredSpace, D3DUSAGE_WRITEONLY, type == GL_UNSIGNED_INT ? D3DFMT_INDEX32 : D3DFMT_INDEX16, pool, &mIndexBuffer, NULL);
mSerial = issueSerial(); mSerial = issueSerial();
......
...@@ -64,7 +64,7 @@ unsigned int ProgramBinary::mCurrentSerial = 1; ...@@ -64,7 +64,7 @@ unsigned int ProgramBinary::mCurrentSerial = 1;
ProgramBinary::ProgramBinary() : RefCountObject(0), mSerial(issueSerial()) ProgramBinary::ProgramBinary() : RefCountObject(0), mSerial(issueSerial())
{ {
mDevice = getDevice(); mDevice = getDevice(); // D3D9_REPLACE
mPixelExecutable = NULL; mPixelExecutable = NULL;
mVertexExecutable = NULL; mVertexExecutable = NULL;
...@@ -1745,7 +1745,8 @@ bool ProgramBinary::load(InfoLog &infoLog, const void *binary, GLsizei length) ...@@ -1745,7 +1745,8 @@ bool ProgramBinary::load(InfoLog &infoLog, const void *binary, GLsizei length)
const D3DCAPS9 *binaryIdentifier = (const D3DCAPS9*) ptr; const D3DCAPS9 *binaryIdentifier = (const D3DCAPS9*) ptr;
ptr += sizeof(GUID); ptr += sizeof(GUID);
D3DADAPTER_IDENTIFIER9 *currentIdentifier = getDisplay()->getAdapterIdentifier(); // D3D9_REPLACE
D3DADAPTER_IDENTIFIER9 *currentIdentifier = getDisplay()->getRenderer()->getAdapterIdentifier();
if (memcmp(&currentIdentifier->DeviceIdentifier, binaryIdentifier, sizeof(GUID)) != 0) if (memcmp(&currentIdentifier->DeviceIdentifier, binaryIdentifier, sizeof(GUID)) != 0)
{ {
infoLog.append("Invalid program binary."); infoLog.append("Invalid program binary.");
...@@ -1851,7 +1852,8 @@ bool ProgramBinary::save(void* binary, GLsizei bufSize, GLsizei *length) ...@@ -1851,7 +1852,8 @@ bool ProgramBinary::save(void* binary, GLsizei bufSize, GLsizei *length)
ASSERT(SUCCEEDED(result)); ASSERT(SUCCEEDED(result));
stream.write(vertexShaderSize); stream.write(vertexShaderSize);
D3DADAPTER_IDENTIFIER9 *identifier = getDisplay()->getAdapterIdentifier(); // D3D9_REPLACE
D3DADAPTER_IDENTIFIER9 *identifier = getDisplay()->getRenderer()->getAdapterIdentifier();
GLsizei streamLength = stream.length(); GLsizei streamLength = stream.length();
const void *streamData = stream.data(); const void *streamData = stream.data();
......
...@@ -34,6 +34,7 @@ void Query::begin() ...@@ -34,6 +34,7 @@ void Query::begin()
{ {
if (mQuery == NULL) if (mQuery == NULL)
{ {
// D3D9_REPLACE
if (FAILED(getDevice()->CreateQuery(D3DQUERYTYPE_OCCLUSION, &mQuery))) if (FAILED(getDevice()->CreateQuery(D3DQUERYTYPE_OCCLUSION, &mQuery)))
{ {
return error(GL_OUT_OF_MEMORY); return error(GL_OUT_OF_MEMORY);
...@@ -68,7 +69,7 @@ GLuint Query::getResult() ...@@ -68,7 +69,7 @@ GLuint Query::getResult()
// explicitly check for device loss // explicitly check for device loss
// some drivers seem to return S_FALSE even if the device is lost // some drivers seem to return S_FALSE even if the device is lost
// instead of D3DERR_DEVICELOST like they should // instead of D3DERR_DEVICELOST like they should
if (gl::getDisplay()->testDeviceLost()) if (gl::getDisplay()->getRenderer()->testDeviceLost()) // D3D9_REPLACE
{ {
gl::getDisplay()->notifyDeviceLost(); gl::getDisplay()->notifyDeviceLost();
return error(GL_OUT_OF_MEMORY, 0); return error(GL_OUT_OF_MEMORY, 0);
......
...@@ -230,6 +230,7 @@ void Image::createSurface() ...@@ -230,6 +230,7 @@ void Image::createSurface()
GLsizei requestHeight = mHeight; GLsizei requestHeight = mHeight;
MakeValidSize(true, IsCompressed(mInternalFormat), &requestWidth, &requestHeight, &levelToFetch); MakeValidSize(true, IsCompressed(mInternalFormat), &requestWidth, &requestHeight, &levelToFetch);
// D3D9_REPLACE
HRESULT result = getDevice()->CreateTexture(requestWidth, requestHeight, levelToFetch + 1, NULL, d3dFormat, HRESULT result = getDevice()->CreateTexture(requestWidth, requestHeight, levelToFetch + 1, NULL, d3dFormat,
poolToUse, &newTexture, NULL); poolToUse, &newTexture, NULL);
...@@ -348,6 +349,7 @@ void Image::updateSurface(IDirect3DSurface9 *destSurface, GLint xoffset, GLint y ...@@ -348,6 +349,7 @@ void Image::updateSurface(IDirect3DSurface9 *destSurface, GLint xoffset, GLint y
else else
{ {
// UpdateSurface: source must be SYSTEMMEM, dest must be DEFAULT pools // UpdateSurface: source must be SYSTEMMEM, dest must be DEFAULT pools
// D3D9_REPLACE
HRESULT result = getDevice()->UpdateSurface(sourceSurface, &rect, destSurface, &point); HRESULT result = getDevice()->UpdateSurface(sourceSurface, &rect, destSurface, &point);
ASSERT(SUCCEEDED(result)); ASSERT(SUCCEEDED(result));
} }
...@@ -865,7 +867,7 @@ void Image::loadCompressedData(GLint xoffset, GLint yoffset, GLsizei width, GLsi ...@@ -865,7 +867,7 @@ void Image::loadCompressedData(GLint xoffset, GLint yoffset, GLsizei width, GLsi
// This implements glCopyTex[Sub]Image2D for non-renderable internal texture formats and incomplete textures // This implements glCopyTex[Sub]Image2D for non-renderable internal texture formats and incomplete textures
void Image::copy(GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height, IDirect3DSurface9 *renderTarget) void Image::copy(GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height, IDirect3DSurface9 *renderTarget)
{ {
IDirect3DDevice9 *device = getDevice(); IDirect3DDevice9 *device = getDevice(); // D3D9_REPLACE
IDirect3DSurface9 *renderTargetData = NULL; IDirect3DSurface9 *renderTargetData = NULL;
D3DSURFACE_DESC description; D3DSURFACE_DESC description;
renderTarget->GetDesc(&description); renderTarget->GetDesc(&description);
...@@ -1266,7 +1268,7 @@ void GenerateMip(IDirect3DSurface9 *destSurface, IDirect3DSurface9 *sourceSurfac ...@@ -1266,7 +1268,7 @@ void GenerateMip(IDirect3DSurface9 *destSurface, IDirect3DSurface9 *sourceSurfac
TextureStorage::TextureStorage(DWORD usage) TextureStorage::TextureStorage(DWORD usage)
: mD3DUsage(usage), : mD3DUsage(usage),
mD3DPool(getDisplay()->getTexturePool(usage)), mD3DPool(getDisplay()->getRenderer()->getTexturePool(usage)), // D3D9_REPLACE
mTextureSerial(issueTextureSerial()), mTextureSerial(issueTextureSerial()),
mLodOffset(0) mLodOffset(0)
{ {
...@@ -1643,9 +1645,10 @@ bool Texture::copyToRenderTarget(IDirect3DSurface9 *dest, IDirect3DSurface9 *sou ...@@ -1643,9 +1645,10 @@ bool Texture::copyToRenderTarget(IDirect3DSurface9 *dest, IDirect3DSurface9 *sou
else else
{ {
egl::Display *display = getDisplay(); egl::Display *display = getDisplay();
IDirect3DDevice9 *device = display->getDevice(); renderer::Renderer *renderer = display->getRenderer();
IDirect3DDevice9 *device = renderer->getDevice(); // D3D9_REPLACE
display->endScene(); renderer->endScene();
result = device->StretchRect(source, NULL, dest, NULL, D3DTEXF_NONE); result = device->StretchRect(source, NULL, dest, NULL, D3DTEXF_NONE);
} }
...@@ -1672,7 +1675,7 @@ TextureStorage2D::TextureStorage2D(int levels, D3DFORMAT format, DWORD usage, in ...@@ -1672,7 +1675,7 @@ TextureStorage2D::TextureStorage2D(int levels, D3DFORMAT format, DWORD usage, in
// we handle that here by skipping the d3d texture creation // we handle that here by skipping the d3d texture creation
if (width > 0 && height > 0) if (width > 0 && height > 0)
{ {
IDirect3DDevice9 *device = getDevice(); IDirect3DDevice9 *device = getDevice(); // D3D9_REPLACE
MakeValidSize(false, dx::IsCompressedFormat(format), &width, &height, &mLodOffset); MakeValidSize(false, dx::IsCompressedFormat(format), &width, &height, &mLodOffset);
HRESULT result = device->CreateTexture(width, height, levels ? levels + mLodOffset : 0, getUsage(), format, getPool(), &mTexture, NULL); HRESULT result = device->CreateTexture(width, height, levels ? levels + mLodOffset : 0, getUsage(), format, getPool(), &mTexture, NULL);
...@@ -2383,7 +2386,7 @@ TextureStorageCubeMap::TextureStorageCubeMap(int levels, D3DFORMAT format, DWORD ...@@ -2383,7 +2386,7 @@ TextureStorageCubeMap::TextureStorageCubeMap(int levels, D3DFORMAT format, DWORD
// we handle that here by skipping the d3d texture creation // we handle that here by skipping the d3d texture creation
if (size > 0) if (size > 0)
{ {
IDirect3DDevice9 *device = getDevice(); IDirect3DDevice9 *device = getDevice(); // D3D9_REPLACE
int height = size; int height = size;
MakeValidSize(false, dx::IsCompressedFormat(format), &size, &height, &mLodOffset); MakeValidSize(false, dx::IsCompressedFormat(format), &size, &height, &mLodOffset);
HRESULT result = device->CreateCubeTexture(size, levels ? levels + mLodOffset : 0, getUsage(), format, getPool(), &mTexture, NULL); HRESULT result = device->CreateCubeTexture(size, levels ? levels + mLodOffset : 0, getUsage(), format, getPool(), &mTexture, NULL);
......
...@@ -45,6 +45,7 @@ VertexDataManager::VertexDataManager(Context *context, IDirect3DDevice9 *device) ...@@ -45,6 +45,7 @@ VertexDataManager::VertexDataManager(Context *context, IDirect3DDevice9 *device)
mCurrentValueOffsets[i] = 0; mCurrentValueOffsets[i] = 0;
} }
// D3D9_REPLACE
const D3DCAPS9 &caps = context->getDeviceCaps(); const D3DCAPS9 &caps = context->getDeviceCaps();
checkVertexCaps(caps.DeclTypes); checkVertexCaps(caps.DeclTypes);
...@@ -575,7 +576,8 @@ VertexBuffer::VertexBuffer(IDirect3DDevice9 *device, std::size_t size, DWORD usa ...@@ -575,7 +576,8 @@ VertexBuffer::VertexBuffer(IDirect3DDevice9 *device, std::size_t size, DWORD usa
{ {
if (size > 0) if (size > 0)
{ {
D3DPOOL pool = getDisplay()->getBufferPool(usageFlags); // D3D9_REPLACE
D3DPOOL pool = getDisplay()->getRenderer()->getBufferPool(usageFlags);
HRESULT result = device->CreateVertexBuffer(size, usageFlags, 0, pool, &mVertexBuffer, NULL); HRESULT result = device->CreateVertexBuffer(size, usageFlags, 0, pool, &mVertexBuffer, NULL);
mSerial = issueSerial(); mSerial = issueSerial();
...@@ -674,7 +676,8 @@ void StreamingVertexBuffer::reserveRequiredSpace() ...@@ -674,7 +676,8 @@ void StreamingVertexBuffer::reserveRequiredSpace()
mBufferSize = std::max(mRequiredSpace, 3 * mBufferSize / 2); // 1.5 x mBufferSize is arbitrary and should be checked to see we don't have too many reallocations. mBufferSize = std::max(mRequiredSpace, 3 * mBufferSize / 2); // 1.5 x mBufferSize is arbitrary and should be checked to see we don't have too many reallocations.
D3DPOOL pool = getDisplay()->getBufferPool(D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY); // D3D9_REPLACE
D3DPOOL pool = getDisplay()->getRenderer()->getBufferPool(D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY);
HRESULT result = mDevice->CreateVertexBuffer(mBufferSize, D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, 0, pool, &mVertexBuffer, NULL); HRESULT result = mDevice->CreateVertexBuffer(mBufferSize, D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, 0, pool, &mVertexBuffer, NULL);
mSerial = issueSerial(); mSerial = issueSerial();
...@@ -737,7 +740,8 @@ void StaticVertexBuffer::reserveRequiredSpace() ...@@ -737,7 +740,8 @@ void StaticVertexBuffer::reserveRequiredSpace()
{ {
if (!mVertexBuffer && mBufferSize == 0) if (!mVertexBuffer && mBufferSize == 0)
{ {
D3DPOOL pool = getDisplay()->getBufferPool(D3DUSAGE_WRITEONLY); // D3D9_REPLACE
D3DPOOL pool = getDisplay()->getRenderer()->getBufferPool(D3DUSAGE_WRITEONLY);
HRESULT result = mDevice->CreateVertexBuffer(mRequiredSpace, D3DUSAGE_WRITEONLY, 0, pool, &mVertexBuffer, NULL); HRESULT result = mDevice->CreateVertexBuffer(mRequiredSpace, D3DUSAGE_WRITEONLY, 0, pool, &mVertexBuffer, NULL);
mSerial = issueSerial(); mSerial = issueSerial();
......
...@@ -180,3 +180,5 @@ EXPORTS ...@@ -180,3 +180,5 @@ EXPORTS
glGetCurrentContext @147 NONAME glGetCurrentContext @147 NONAME
glGetProcAddress @148 NONAME glGetProcAddress @148 NONAME
glBindTexImage @158 NONAME glBindTexImage @158 NONAME
glCreateRenderer @177 NONAME
glDestroyRenderer @178 NONAME
...@@ -97,7 +97,7 @@ ...@@ -97,7 +97,7 @@
<DisableSpecificWarnings>4100;4127;4189;4239;4244;4245;4512;4702;%(DisableSpecificWarnings)</DisableSpecificWarnings> <DisableSpecificWarnings>4100;4127;4189;4239;4244;4245;4512;4702;%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile> </ClCompile>
<Link> <Link>
<AdditionalDependencies>d3d9.lib;d3dcompiler.lib;%(AdditionalDependencies)</AdditionalDependencies> <AdditionalDependencies>d3d9.lib;d3dcompiler.lib;dxguid.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ModuleDefinitionFile>libGLESv2.def</ModuleDefinitionFile> <ModuleDefinitionFile>libGLESv2.def</ModuleDefinitionFile>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
...@@ -130,7 +130,7 @@ copy "$(OutDir)libGLESv2.lib" "$(ProjectDir)..\..\lib\$(Configuration)\" ...@@ -130,7 +130,7 @@ copy "$(OutDir)libGLESv2.lib" "$(ProjectDir)..\..\lib\$(Configuration)\"
<DisableSpecificWarnings>4100;4127;4189;4239;4244;4245;4512;4702;4718;%(DisableSpecificWarnings)</DisableSpecificWarnings> <DisableSpecificWarnings>4100;4127;4189;4239;4244;4245;4512;4702;4718;%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile> </ClCompile>
<Link> <Link>
<AdditionalDependencies>d3d9.lib;d3dcompiler.lib;%(AdditionalDependencies)</AdditionalDependencies> <AdditionalDependencies>d3d9.lib;d3dcompiler.lib;dxguid.lib;%(AdditionalDependencies)</AdditionalDependencies>
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
<ModuleDefinitionFile>libGLESv2.def</ModuleDefinitionFile> <ModuleDefinitionFile>libGLESv2.def</ModuleDefinitionFile>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
...@@ -170,7 +170,7 @@ copy "$(OutDir)libGLESv2.lib" "$(ProjectDir)..\..\lib\$(Configuration)\" ...@@ -170,7 +170,7 @@ copy "$(OutDir)libGLESv2.lib" "$(ProjectDir)..\..\lib\$(Configuration)\"
<TreatWarningAsError>true</TreatWarningAsError> <TreatWarningAsError>true</TreatWarningAsError>
</ClCompile> </ClCompile>
<Link> <Link>
<AdditionalDependencies>d3d9.lib;d3dcompiler.lib;%(AdditionalDependencies)</AdditionalDependencies> <AdditionalDependencies>d3d9.lib;d3dcompiler.lib;dxguid.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ModuleDefinitionFile>libGLESv2.def</ModuleDefinitionFile> <ModuleDefinitionFile>libGLESv2.def</ModuleDefinitionFile>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
...@@ -206,7 +206,7 @@ copy "$(OutDir)libGLESv2.lib" "$(ProjectDir)..\..\lib\$(Configuration)\" ...@@ -206,7 +206,7 @@ copy "$(OutDir)libGLESv2.lib" "$(ProjectDir)..\..\lib\$(Configuration)\"
<TreatWarningAsError>true</TreatWarningAsError> <TreatWarningAsError>true</TreatWarningAsError>
</ClCompile> </ClCompile>
<Link> <Link>
<AdditionalDependencies>d3d9.lib;d3dcompiler.lib;%(AdditionalDependencies)</AdditionalDependencies> <AdditionalDependencies>d3d9.lib;d3dcompiler.lib;dxguid.lib;%(AdditionalDependencies)</AdditionalDependencies>
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
<ModuleDefinitionFile>libGLESv2.def</ModuleDefinitionFile> <ModuleDefinitionFile>libGLESv2.def</ModuleDefinitionFile>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
...@@ -245,6 +245,7 @@ copy "$(OutDir)libGLESv2.lib" "$(ProjectDir)..\..\lib\$(Configuration)\" ...@@ -245,6 +245,7 @@ copy "$(OutDir)libGLESv2.lib" "$(ProjectDir)..\..\lib\$(Configuration)\"
<ClCompile Include="Query.cpp" /> <ClCompile Include="Query.cpp" />
<ClCompile Include="..\common\RefCountObject.cpp" /> <ClCompile Include="..\common\RefCountObject.cpp" />
<ClCompile Include="Renderbuffer.cpp" /> <ClCompile Include="Renderbuffer.cpp" />
<ClCompile Include="renderer\Renderer.cpp" />
<ClCompile Include="ResourceManager.cpp" /> <ClCompile Include="ResourceManager.cpp" />
<ClCompile Include="Shader.cpp" /> <ClCompile Include="Shader.cpp" />
<ClCompile Include="Texture.cpp" /> <ClCompile Include="Texture.cpp" />
...@@ -272,6 +273,7 @@ copy "$(OutDir)libGLESv2.lib" "$(ProjectDir)..\..\lib\$(Configuration)\" ...@@ -272,6 +273,7 @@ copy "$(OutDir)libGLESv2.lib" "$(ProjectDir)..\..\lib\$(Configuration)\"
<ClInclude Include="Query.h" /> <ClInclude Include="Query.h" />
<ClInclude Include="..\common\RefCountObject.h" /> <ClInclude Include="..\common\RefCountObject.h" />
<ClInclude Include="Renderbuffer.h" /> <ClInclude Include="Renderbuffer.h" />
<ClInclude Include="renderer\Renderer.h" />
<ClInclude Include="resource.h" /> <ClInclude Include="resource.h" />
<ClInclude Include="ResourceManager.h" /> <ClInclude Include="ResourceManager.h" />
<ClInclude Include="Shader.h" /> <ClInclude Include="Shader.h" />
...@@ -300,4 +302,4 @@ copy "$(OutDir)libGLESv2.lib" "$(ProjectDir)..\..\lib\$(Configuration)\" ...@@ -300,4 +302,4 @@ copy "$(OutDir)libGLESv2.lib" "$(ProjectDir)..\..\lib\$(Configuration)\"
<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
...@@ -80,7 +80,7 @@ ...@@ -80,7 +80,7 @@
<ClCompile Include="VertexDataManager.cpp"> <ClCompile Include="VertexDataManager.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="Renderer.cpp"> <ClCompile Include="renderer\Renderer.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
</ItemGroup> </ItemGroup>
...@@ -166,10 +166,7 @@ ...@@ -166,10 +166,7 @@
<ClInclude Include="VertexDataManager.h"> <ClInclude Include="VertexDataManager.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="Renderer.h"> <ClInclude Include="renderer\Renderer.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="EnumTypes.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
</ItemGroup> </ItemGroup>
......
...@@ -120,11 +120,12 @@ egl::Display *getDisplay() ...@@ -120,11 +120,12 @@ egl::Display *getDisplay()
return current->display; return current->display;
} }
// D3D9_REPLACE
IDirect3DDevice9 *getDevice() IDirect3DDevice9 *getDevice()
{ {
egl::Display *display = getDisplay(); egl::Display *display = getDisplay();
return display->getDevice(); return display->getRenderer()->getDevice();
} }
bool checkDeviceLost(HRESULT errorCode) bool checkDeviceLost(HRESULT errorCode)
......
//
// 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_RENDERER_H_
#define LIBGLESV2_RENDERER_RENDERER_H_
#include "common/angleutils.h"
#define GL_APICALL
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#define EGLAPI
#include <EGL/egl.h>
#include <d3d9.h> // D3D9_REPLACE
const int versionWindowsVista = MAKEWORD(0x00, 0x06);
const int versionWindows7 = MAKEWORD(0x01, 0x06);
// Return the version of the operating system in a format suitable for ordering
// comparison.
inline int getComparableOSVersion()
{
DWORD version = GetVersion();
int majorVersion = LOBYTE(LOWORD(version));
int minorVersion = HIBYTE(LOWORD(version));
return MAKEWORD(minorVersion, majorVersion);
}
namespace renderer
{
class Renderer
{
public:
Renderer(HMODULE hModule, HDC hDc);
virtual ~Renderer();
virtual EGLint initialize();
virtual bool resetDevice();
virtual void startScene();
virtual void endScene();
#if 0
// resource creation
virtual void *createVertexShader(const DWORD *function, size_t length);
virtual void *createPixelShader(const DWORD *function, size_t length);
virtual void *createTexture2D();
virtual void *createTextureCube();
virtual void *createQuery();;
virtual void *createIndexBuffer();
virtual void *createVertexbuffer();
// state setup
virtual void applyTexture();
virtual void applyShaders();
virtual void applyConstants();
virtual void applyRenderTargets();
virtual void applyState();
#endif
// lost device
virtual void markDeviceLost();
virtual bool isDeviceLost();
virtual bool testDeviceLost();
virtual bool testDeviceResettable();
// Renderer capabilities
virtual IDirect3DDevice9 *getDevice() {return mDevice;}; // D3D9_REPLACE
virtual D3DADAPTER_IDENTIFIER9 *getAdapterIdentifier() {return &mAdapterIdentifier;}; // D3D9_REPLACE
virtual D3DCAPS9 getDeviceCaps() {return mDeviceCaps;}; // D3D9_REMOVE
virtual IDirect3D9 *getD3D() {return mD3d9;}; // D3D9_REMOVE
virtual UINT getAdapter() {return mAdapter;}; // D3D9_REMOVE
virtual D3DDEVTYPE getDeviceType() {return mDeviceType;}; // D3D9_REMOVE
virtual bool isD3d9ExDevice() const { return mD3d9Ex != NULL; } // D3D9_REMOVE
virtual void getMultiSampleSupport(D3DFORMAT format, bool *multiSampleArray); // D3D9_REPLACE
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 float getTextureFilterAnisotropySupport() const;
virtual D3DPOOL getBufferPool(DWORD usage) const;
virtual D3DPOOL getTexturePool(DWORD usage) const;
private:
DISALLOW_COPY_AND_ASSIGN(Renderer);
const HDC mDc;
HMODULE mD3d9Module;
void initializeDevice();
D3DPRESENT_PARAMETERS getDefaultPresentParameters();
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;
};
}
#endif // LIBGLESV2_RENDERER_RENDERER_H_
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment