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(
mDeviceContext = NULL;
mDxgiAdapter = NULL;
mDxgiFactory = NULL;
mForceSetBlendState = true;
}
Renderer11::~Renderer11()
......@@ -160,6 +162,8 @@ EGLint Renderer11::initialize()
// 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::setRasterizerState(const gl::RasterizerState &rasterState, unsi
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 @@ void Renderer11::releaseDeviceResources()
{
// TODO
// UNIMPLEMENTED();
mStateCache.clear();
}
void Renderer11::markDeviceLost()
......@@ -357,6 +385,8 @@ bool Renderer11::resetDevice()
initializeDevice();
mDeviceLost = false;
mForceSetBlendState = true;
return true;
}
......
......@@ -21,6 +21,7 @@
#include "common/angleutils.h"
#include "libGLESv2/renderer/Renderer.h"
#include "libGLESv2/renderer/RenderStateCache.h"
namespace rx
{
......@@ -123,6 +124,14 @@ class Renderer11 : public Renderer
void initializeDevice();
void releaseDeviceResources();
RenderStateCache mStateCache;
// Currently applied blend state
bool mForceSetBlendState;
gl::BlendState mCurBlendState;
gl::Color mCurBlendColor;
unsigned int mCurSampleMask;
ID3D11Device *mDevice;
D3D_FEATURE_LEVEL mFeatureLevel;
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