Implemented Renderer11::setSamplerState.

TRAC #22251 Signed-off-by: Nicolas Capens Signed-off-by: Daniel Koch Author: Geoff Lang git-svn-id: https://angleproject.googlecode.com/svn/branches/dx11proto@1665 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 8e4f552e
// //
// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved. // Copyright (c) 2012-2013 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// //
...@@ -267,8 +267,65 @@ SwapChain *Renderer11::createSwapChain(HWND window, HANDLE shareHandle, GLenum b ...@@ -267,8 +267,65 @@ SwapChain *Renderer11::createSwapChain(HWND window, HANDLE shareHandle, GLenum b
void Renderer11::setSamplerState(gl::SamplerType type, int index, const gl::SamplerState &samplerState) void Renderer11::setSamplerState(gl::SamplerType type, int index, const gl::SamplerState &samplerState)
{ {
// TODO if (type == gl::SAMPLER_PIXEL)
UNIMPLEMENTED(); {
if (index < 0 || index >= gl::MAX_TEXTURE_IMAGE_UNITS)
{
ERR("Pixel shader sampler index %i is not valid.", index);
return;
}
if (mForceSetPixelSamplerStates[index] || memcmp(&samplerState, &mCurPixelSamplerStates[index], sizeof(gl::SamplerState)) != 0)
{
ID3D11SamplerState *dxSamplerState = mStateCache.getSamplerState(samplerState);
if (!dxSamplerState)
{
ERR("NULL sampler state returned by RenderStateCache::getSamplerState, setting the default"
"sampler state for pixel shaders at slot %i.", index);
}
mDeviceContext->PSSetSamplers(index, 1, &dxSamplerState);
if (dxSamplerState)
{
dxSamplerState->Release();
}
mCurPixelSamplerStates[index] = samplerState;
}
mForceSetPixelSamplerStates[index] = false;
}
else if (type == gl::SAMPLER_VERTEX)
{
if (index < 0 || index >= gl::MAX_VERTEX_TEXTURE_IMAGE_UNITS_VTF)
{
ERR("Vertex shader sampler index %i is not valid.", index);
return;
}
if (mForceSetVertexSamplerStates[index] || memcmp(&samplerState, &mCurVertexSamplerStates[index], sizeof(gl::SamplerState)) != 0)
{
ID3D11SamplerState *dxSamplerState = mStateCache.getSamplerState(samplerState);
if (!dxSamplerState)
{
ERR("NULL sampler state returned by RenderStateCache::getSamplerState, setting the default"
"sampler state for vertex shaders at slot %i.", index);
}
mDeviceContext->VSSetSamplers(index, 1, &dxSamplerState);
if (dxSamplerState)
{
dxSamplerState->Release();
}
mCurVertexSamplerStates[index] = samplerState;
}
mForceSetVertexSamplerStates[index] = false;
}
else UNREACHABLE();
} }
void Renderer11::setTexture(gl::SamplerType type, int index, gl::Texture *texture) void Renderer11::setTexture(gl::SamplerType type, int index, gl::Texture *texture)
...@@ -998,6 +1055,15 @@ void Renderer11::markAllStateDirty() ...@@ -998,6 +1055,15 @@ void Renderer11::markAllStateDirty()
mDepthStencilInitialized = false; mDepthStencilInitialized = false;
mRenderTargetDescInitialized = false; mRenderTargetDescInitialized = false;
for (int i = 0; i < gl::MAX_VERTEX_TEXTURE_IMAGE_UNITS_VTF; i++)
{
mForceSetVertexSamplerStates[i] = true;
}
for (int i = 0; i < gl::MAX_TEXTURE_IMAGE_UNITS; i++)
{
mForceSetPixelSamplerStates[i] = true;
}
mForceSetBlendState = true; mForceSetBlendState = true;
mForceSetRasterState = true; mForceSetRasterState = true;
mForceSetDepthStencilState = true; mForceSetDepthStencilState = true;
......
...@@ -180,6 +180,13 @@ class Renderer11 : public Renderer ...@@ -180,6 +180,13 @@ class Renderer11 : public Renderer
unsigned int mCurDepthSize; unsigned int mCurDepthSize;
unsigned int mCurStencilSize; unsigned int mCurStencilSize;
// Currently applied sampler states
bool mForceSetVertexSamplerStates[gl::MAX_VERTEX_TEXTURE_IMAGE_UNITS_VTF];
gl::SamplerState mCurVertexSamplerStates[gl::MAX_VERTEX_TEXTURE_IMAGE_UNITS_VTF];
bool mForceSetPixelSamplerStates[gl::MAX_TEXTURE_IMAGE_UNITS];
gl::SamplerState mCurPixelSamplerStates[gl::MAX_TEXTURE_IMAGE_UNITS];
// Currently applied blend state // Currently applied blend state
bool mForceSetBlendState; bool mForceSetBlendState;
gl::BlendState mCurBlendState; gl::BlendState mCurBlendState;
......
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