Add a Renderer11 class for the d3d11 backend.

Trac #21925 Signed-off-by: Nicolas Capens git-svn-id: https://angleproject.googlecode.com/svn/branches/dx11proto@1396 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 3f526967
...@@ -255,6 +255,8 @@ ...@@ -255,6 +255,8 @@
'libGLESv2/renderer/Image.cpp', 'libGLESv2/renderer/Image.cpp',
'libGLESv2/renderer/Image.h', 'libGLESv2/renderer/Image.h',
'libGLESv2/renderer/Renderer.h', 'libGLESv2/renderer/Renderer.h',
'libGLESv2/renderer/Renderer11.cpp',
'libGLESv2/renderer/Renderer11.h',
'libGLESv2/renderer/Renderer9.cpp', 'libGLESv2/renderer/Renderer9.cpp',
'libGLESv2/renderer/Renderer9.h', 'libGLESv2/renderer/Renderer9.h',
'libGLESv2/renderer/renderer9_utils.cpp', 'libGLESv2/renderer/renderer9_utils.cpp',
......
...@@ -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\Renderer11.cpp" />
<ClCompile Include="renderer\Renderer9.cpp" /> <ClCompile Include="renderer\Renderer9.cpp" />
<ClCompile Include="renderer\Image.cpp" /> <ClCompile Include="renderer\Image.cpp" />
<ClCompile Include="renderer\renderer9_utils.cpp" /> <ClCompile Include="renderer\renderer9_utils.cpp" />
...@@ -280,6 +281,7 @@ copy "$(OutDir)libGLESv2.lib" "$(ProjectDir)..\..\lib\$(Configuration)\" ...@@ -280,6 +281,7 @@ copy "$(OutDir)libGLESv2.lib" "$(ProjectDir)..\..\lib\$(Configuration)\"
<ClInclude Include="Renderbuffer.h" /> <ClInclude Include="Renderbuffer.h" />
<ClInclude Include="renderer\Image.h" /> <ClInclude Include="renderer\Image.h" />
<ClInclude Include="renderer\Renderer.h" /> <ClInclude Include="renderer\Renderer.h" />
<ClInclude Include="renderer\Renderer11.h" />
<ClInclude Include="renderer\Renderer9.h" /> <ClInclude Include="renderer\Renderer9.h" />
<ClInclude Include="renderer\renderer9_utils.h" /> <ClInclude Include="renderer\renderer9_utils.h" />
<ClInclude Include="renderer\ShaderCache.h" /> <ClInclude Include="renderer\ShaderCache.h" />
......
...@@ -98,6 +98,9 @@ ...@@ -98,6 +98,9 @@
<ClCompile Include="renderer\renderer9_utils.cpp"> <ClCompile Include="renderer\renderer9_utils.cpp">
<Filter>Renderer</Filter> <Filter>Renderer</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="renderer\Renderer11.cpp">
<Filter>Renderer</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="BinaryStream.h"> <ClInclude Include="BinaryStream.h">
...@@ -205,6 +208,9 @@ ...@@ -205,6 +208,9 @@
<ClInclude Include="renderer\renderer9_utils.h"> <ClInclude Include="renderer\renderer9_utils.h">
<Filter>Renderer</Filter> <Filter>Renderer</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="renderer\Renderer11.h">
<Filter>Renderer</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="libGLESv2.def"> <None Include="libGLESv2.def">
......
//
// 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.
//
// Renderer11.cpp: Implements a back-end specific class for the D3D11 renderer.
#include "common/debug.h"
#include "libGLESv2/utilities.h"
#include "libGLESv2/renderer/Renderer11.h"
#include "libEGL/Config.h"
#include "libEGL/Display.h"
namespace rx
{
Renderer11::Renderer11(egl::Display *display, HDC hDc) : Renderer(display), mDc(hDc)
{
mD3d11Module = NULL;
mDxgiModule = NULL;
mD3d11 = NULL;
mDeviceContext = NULL;
}
Renderer11::~Renderer11()
{
releaseDeviceResources();
if (mDeviceContext)
{
mDeviceContext->Release();
mDeviceContext = NULL;
}
if (mD3d11)
{
mD3d11->Release();
mD3d11 = NULL;
}
if (mD3d11Module)
{
mD3d11Module = NULL;
}
if (mDxgiModule)
{
mDxgiModule = NULL;
}
}
EGLint Renderer11::initialize()
{
mDxgiModule = GetModuleHandle(TEXT("dxgi.dll"));
mD3d11Module = GetModuleHandle(TEXT("d3d11.dll"));
if (mD3d11Module == NULL || mDxgiModule == NULL)
{
ERR("No D3D11 or DXGI module found - aborting!\n");
return EGL_NOT_INITIALIZED;
}
// TODO: device creation, any one-time setup.
UNIMPLEMENTED();
initializeDevice();
return EGL_SUCCESS;
}
// 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 Renderer11::initializeDevice()
{
// Permanent non-default states
// TODO
UNIMPLEMENTED();
}
int Renderer11::generateConfigs(ConfigDesc **configDescList)
{
// TODO
UNIMPLEMENTED();
return 0;
}
void Renderer11::deleteConfigs(ConfigDesc *configDescList)
{
delete [] (configDescList);
}
void Renderer11::startScene()
{
// TODO: nop in d3d11?
}
void Renderer11::endScene()
{
// TODO: nop in d3d11?
}
void Renderer11::sync(bool block)
{
// TODO
UNIMPLEMENTED();
}
void Renderer11::setSamplerState(gl::SamplerType type, int index, const gl::SamplerState &samplerState)
{
// TODO
UNIMPLEMENTED();
}
void Renderer11::setTexture(gl::SamplerType type, int index, gl::Texture *texture)
{
// TODO
UNIMPLEMENTED();
}
void Renderer11::releaseDeviceResources()
{
// TODO
UNIMPLEMENTED();
}
void Renderer11::markDeviceLost()
{
mDeviceLost = true;
}
bool Renderer11::isDeviceLost()
{
return mDeviceLost;
}
// set notify to true to broadcast a message to all contexts of the device loss
bool Renderer11::testDeviceLost(bool notify)
{
bool isLost = false;
// TODO
UNIMPLEMENTED();
if (isLost)
{
// ensure we note the device loss --
// we'll probably get this done again by markDeviceLost
// but best to remember it!
// Note that we don't want to clear the device loss status here
// -- this needs to be done by resetDevice
mDeviceLost = true;
if (notify)
{
mDisplay->notifyDeviceLost();
}
}
return isLost;
}
bool Renderer11::testDeviceResettable()
{
HRESULT status = D3D_OK;
// TODO
UNIMPLEMENTED();
switch (status)
{
case D3DERR_DEVICENOTRESET:
case D3DERR_DEVICEHUNG:
return true;
default:
return false;
}
}
bool Renderer11::resetDevice()
{
releaseDeviceResources();
// TODO
UNIMPLEMENTED();
// reset device defaults
initializeDevice();
mDeviceLost = false;
return true;
}
DWORD Renderer11::getAdapterVendor() const
{
// TODO
UNIMPLEMENTED();
return 0;
}
const char *Renderer11::getAdapterDescription() const
{
// TODO
UNIMPLEMENTED();
return "UNIMPLEMENTED";
}
GUID Renderer11::getAdapterIdentifier() const
{
// TODO
UNIMPLEMENTED();
GUID foo = {};
return foo;
}
bool Renderer11::getDXT1TextureSupport()
{
// TODO
UNIMPLEMENTED();
return false;
}
bool Renderer11::getDXT3TextureSupport()
{
// TODO
UNIMPLEMENTED();
return false;
}
bool Renderer11::getDXT5TextureSupport()
{
// TODO
UNIMPLEMENTED();
return false;
}
bool Renderer11::getDepthTextureSupport() const
{
// TODO
UNIMPLEMENTED();
return false;
}
bool Renderer11::getFloat32TextureSupport(bool *filtering, bool *renderable)
{
// TODO
UNIMPLEMENTED();
*filtering = false;
*renderable = false;
return false;
}
bool Renderer11::getFloat16TextureSupport(bool *filtering, bool *renderable)
{
// TODO
UNIMPLEMENTED();
*filtering = false;
*renderable = false;
return false;
}
bool Renderer11::getLuminanceTextureSupport()
{
// TODO
UNIMPLEMENTED();
return false;
}
bool Renderer11::getLuminanceAlphaTextureSupport()
{
// TODO
UNIMPLEMENTED();
return false;
}
bool Renderer11::getTextureFilterAnisotropySupport() const
{
// TODO
UNIMPLEMENTED();
return false;
}
float Renderer11::getTextureMaxAnisotropy() const
{
// TODO
UNIMPLEMENTED();
return 1.0f;
}
bool Renderer11::getEventQuerySupport()
{
// TODO
UNIMPLEMENTED();
return false;
}
bool Renderer11::getVertexTextureSupport() const
{
// TODO
UNIMPLEMENTED();
return false;
}
bool Renderer11::getNonPower2TextureSupport() const
{
// TODO
UNIMPLEMENTED();
return false;
}
bool Renderer11::getOcclusionQuerySupport() const
{
// TODO
UNIMPLEMENTED();
return false;
}
bool Renderer11::getInstancingSupport() const
{
// TODO
UNIMPLEMENTED();
return false;
}
bool Renderer11::getShareHandleSupport() const
{
// TODO
UNIMPLEMENTED();
// PIX doesn't seem to support using share handles, so disable them.
return false && !gl::perfActive();
}
bool Renderer11::getShaderModel3Support() const
{
// TODO
UNIMPLEMENTED();
return true;
}
float Renderer11::getMaxPointSize() const
{
// TODO
UNIMPLEMENTED();
return 1.0f;
}
int Renderer11::getMaxTextureWidth() const
{
// TODO
UNIMPLEMENTED();
return 1024;
}
int Renderer11::getMaxTextureHeight() const
{
// TODO
UNIMPLEMENTED();
return 1024;
}
bool Renderer11::get32BitIndexSupport() const
{
// TODO
UNIMPLEMENTED();
return true;
}
int Renderer11::getMinSwapInterval() const
{
// TODO
UNIMPLEMENTED();
return 1;
}
int Renderer11::getMaxSwapInterval() const
{
// TODO
UNIMPLEMENTED();
return 1;
}
int Renderer11::getMaxSupportedSamples() const
{
// TODO
UNIMPLEMENTED();
return 1;
}
}
\ No newline at end of file
//
// 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.
//
// Renderer11.h: Defines a back-end specific class for the D3D11 renderer.
#ifndef LIBGLESV2_RENDERER_RENDERER11_H_
#define LIBGLESV2_RENDERER_RENDERER11_H_
#define GL_APICALL
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#define EGLAPI
#include <EGL/egl.h>
#include <dxgi.h>
#include <d3d11.h>
#include "common/angleutils.h"
#include "libGLESv2/renderer/Renderer.h"
namespace rx
{
class Renderer11 : public Renderer
{
public:
Renderer11(egl::Display *display, HDC hDc);
virtual ~Renderer11();
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 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
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 int getMinSwapInterval() const;
virtual int getMaxSwapInterval() const;
virtual GLsizei getMaxSupportedSamples() const;
// D3D11-renderer specific methods
ID3D11Device *getDevice() { return mD3d11; }
ID3D11DeviceContext *getDeviceContext() { return mDeviceContext; };
private:
DISALLOW_COPY_AND_ASSIGN(Renderer11);
HMODULE mD3d11Module;
HMODULE mDxgiModule;
HDC mDc;
bool mDeviceLost;
void initializeDevice();
void releaseDeviceResources();
ID3D11Device *mD3d11;
ID3D11DeviceContext *mDeviceContext;
};
}
#endif // LIBGLESV2_RENDERER_RENDERER11_H_
...@@ -4,8 +4,7 @@ ...@@ -4,8 +4,7 @@
// found in the LICENSE file. // found in the LICENSE file.
// //
// Renderer.cpp: Implements a back-end specific class that hides the details of the // Renderer9.cpp: Implements a back-end specific class for the D3D9 renderer.
// implementation-specific renderer.
#include "common/debug.h" #include "common/debug.h"
#include "libGLESv2/utilities.h" #include "libGLESv2/utilities.h"
......
...@@ -4,8 +4,7 @@ ...@@ -4,8 +4,7 @@
// found in the LICENSE file. // found in the LICENSE file.
// //
// Renderer.h: Defines a back-end specific class that hides the details of the // Renderer9.h: Defines a back-end specific class for the D3D9 renderer.
// implementation-specific renderer.
#ifndef LIBGLESV2_RENDERER_RENDERER9_H_ #ifndef LIBGLESV2_RENDERER_RENDERER9_H_
#define LIBGLESV2_RENDERER_RENDERER9_H_ #define LIBGLESV2_RENDERER_RENDERER9_H_
...@@ -20,7 +19,7 @@ ...@@ -20,7 +19,7 @@
#define EGLAPI #define EGLAPI
#include <EGL/egl.h> #include <EGL/egl.h>
#include <d3d9.h> // D3D9_REPLACE #include <d3d9.h>
#include "common/angleutils.h" #include "common/angleutils.h"
#include "libGLESv2/renderer/ShaderCache.h" #include "libGLESv2/renderer/ShaderCache.h"
...@@ -76,7 +75,7 @@ class Renderer9 : public Renderer ...@@ -76,7 +75,7 @@ class Renderer9 : public Renderer
virtual bool testDeviceResettable(); virtual bool testDeviceResettable();
// Renderer capabilities // Renderer capabilities
IDirect3DDevice9 *getDevice() {return mDevice;}; // D3D9_REPLACE IDirect3DDevice9 *getDevice() { return mDevice; }
virtual DWORD getAdapterVendor() const; virtual DWORD getAdapterVendor() const;
virtual const char *getAdapterDescription() const; virtual const char *getAdapterDescription() const;
virtual GUID getAdapterIdentifier() const; virtual GUID getAdapterIdentifier() const;
......
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