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
diff --git a/src/libGLESv2/renderer/Renderer11.cpp b/src/libGLESv2/renderer/Renderer11.cpp
index 60e12cf..f41df6b 100644
--- a/src/libGLESv2/renderer/Renderer11.cpp
+++ b/src/libGLESv2/renderer/Renderer11.cpp
@@ -37,6 +37,8 @@
mDeviceContext = NULL;
mDxgiAdapter = NULL;
mDxgiFactory = NULL;
+
+ mForceSetBlendState = true;
}
Renderer11::~Renderer11()
@@ -160,6 +162,8 @@
// to reset the scene status and ensure the default states are reset.
void Renderer11::initializeDevice()
{
+ mStateCache.initialize(mDevice);
+
// Permanent non-default states
// TODO
// UNIMPLEMENTED();
@@ -257,8 +261,31 @@
void Renderer11::setBlendState(const gl::BlendState &blendState, const gl::Color &blendColor,
unsigned int sampleMask)
{
- // TODO
- UNIMPLEMENTED();
+ if (mForceSetBlendState ||
+ 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,
@@ -292,6 +319,7 @@
{
// TODO
// UNIMPLEMENTED();
+ mStateCache.clear();
}
void Renderer11::markDeviceLost()
@@ -357,6 +385,8 @@
initializeDevice();
mDeviceLost = false;
+ mForceSetBlendState = true;
+
return true;
}