Implemented Renderer11::setBlendState using the new RenderStateCache.

TRAC #22042 Signed-off-by: Nicolas Capens Signed-off-by: Daniel Koch Author: Geoff Lang git-svn-id: https://angleproject.googlecode.com/svn/branches/dx11proto@1433 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 0673d79e
...@@ -37,6 +37,8 @@ Renderer11::Renderer11(egl::Display *display, HDC hDc) : Renderer(display), mDc( ...@@ -37,6 +37,8 @@ Renderer11::Renderer11(egl::Display *display, HDC hDc) : Renderer(display), mDc(
mDeviceContext = NULL; mDeviceContext = NULL;
mDxgiAdapter = NULL; mDxgiAdapter = NULL;
mDxgiFactory = NULL; mDxgiFactory = NULL;
mForceSetBlendState = true;
} }
Renderer11::~Renderer11() Renderer11::~Renderer11()
...@@ -160,6 +162,8 @@ EGLint Renderer11::initialize() ...@@ -160,6 +162,8 @@ EGLint Renderer11::initialize()
// to reset the scene status and ensure the default states are reset. // to reset the scene status and ensure the default states are reset.
void Renderer11::initializeDevice() void Renderer11::initializeDevice()
{ {
mStateCache.initialize(mDevice);
// Permanent non-default states // Permanent non-default states
// TODO // TODO
// UNIMPLEMENTED(); // UNIMPLEMENTED();
...@@ -257,8 +261,31 @@ void Renderer11::setRasterizerState(const gl::RasterizerState &rasterState, unsi ...@@ -257,8 +261,31 @@ void Renderer11::setRasterizerState(const gl::RasterizerState &rasterState, unsi
void Renderer11::setBlendState(const gl::BlendState &blendState, const gl::Color &blendColor, void Renderer11::setBlendState(const gl::BlendState &blendState, const gl::Color &blendColor,
unsigned int sampleMask) unsigned int sampleMask)
{ {
// TODO if (mForceSetBlendState ||
UNIMPLEMENTED(); memcmp(&blendState, &mCurBlendState, sizeof(gl::BlendState)) != 0 ||
memcmp(&blendColor, &mCurBlendColor, sizeof(gl::Color)) != 0 ||
sampleMask != mCurSampleMask)
{
ID3D11BlendState *dxBlendState = mStateCache.getBlendState(blendState);
if (!dxBlendState)
{
ERR("NULL blend state returned by RenderStateCache::getBlendState, setting the default "
"blend state.");
}
const float blendColors[] = { blendColor.red, blendColor.green, blendColor.blue, blendColor.alpha };
mDeviceContext->OMSetBlendState(dxBlendState, blendColors, sampleMask);
if (dxBlendState)
{
dxBlendState->Release();
}
mCurBlendState = blendState;
mCurBlendColor = blendColor;
mCurSampleMask = sampleMask;
}
mForceSetBlendState = false;
} }
void Renderer11::setDepthStencilState(const gl::DepthStencilState &depthStencilState, bool frontFaceCCW, void Renderer11::setDepthStencilState(const gl::DepthStencilState &depthStencilState, bool frontFaceCCW,
...@@ -292,6 +319,7 @@ void Renderer11::releaseDeviceResources() ...@@ -292,6 +319,7 @@ void Renderer11::releaseDeviceResources()
{ {
// TODO // TODO
// UNIMPLEMENTED(); // UNIMPLEMENTED();
mStateCache.clear();
} }
void Renderer11::markDeviceLost() void Renderer11::markDeviceLost()
...@@ -357,6 +385,8 @@ bool Renderer11::resetDevice() ...@@ -357,6 +385,8 @@ bool Renderer11::resetDevice()
initializeDevice(); initializeDevice();
mDeviceLost = false; mDeviceLost = false;
mForceSetBlendState = true;
return true; return true;
} }
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "common/angleutils.h" #include "common/angleutils.h"
#include "libGLESv2/renderer/Renderer.h" #include "libGLESv2/renderer/Renderer.h"
#include "libGLESv2/renderer/RenderStateCache.h"
namespace rx namespace rx
{ {
...@@ -123,6 +124,14 @@ class Renderer11 : public Renderer ...@@ -123,6 +124,14 @@ class Renderer11 : public Renderer
void initializeDevice(); void initializeDevice();
void releaseDeviceResources(); void releaseDeviceResources();
RenderStateCache mStateCache;
// Currently applied blend state
bool mForceSetBlendState;
gl::BlendState mCurBlendState;
gl::Color mCurBlendColor;
unsigned int mCurSampleMask;
ID3D11Device *mDevice; ID3D11Device *mDevice;
D3D_FEATURE_LEVEL mFeatureLevel; D3D_FEATURE_LEVEL mFeatureLevel;
ID3D11DeviceContext *mDeviceContext; ID3D11DeviceContext *mDeviceContext;
......
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