Commit 37584b36 by Xinghua Cao Committed by Commit Bot

Refactor: replace SamplerType with ShaderType

BUG=angleproject:1987 Change-Id: I189e1606bd966eb369e8192a6866c8e90810e937 Reviewed-on: https://chromium-review.googlesource.com/802956 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarYunchao He <yunchao.he@intel.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 1f679cc6
...@@ -40,13 +40,6 @@ enum PrimitiveType ...@@ -40,13 +40,6 @@ enum PrimitiveType
PrimitiveType GetPrimitiveType(GLenum drawMode); PrimitiveType GetPrimitiveType(GLenum drawMode);
enum SamplerType
{
SAMPLER_PIXEL,
SAMPLER_VERTEX,
SAMPLER_COMPUTE
};
enum ShaderType enum ShaderType
{ {
SHADER_VERTEX, SHADER_VERTEX,
......
...@@ -651,7 +651,7 @@ bool ProgramD3D::usesInstancedPointSpriteEmulation() const ...@@ -651,7 +651,7 @@ bool ProgramD3D::usesInstancedPointSpriteEmulation() const
return mRenderer->getWorkarounds().useInstancedPointSpriteEmulation; return mRenderer->getWorkarounds().useInstancedPointSpriteEmulation;
} }
GLint ProgramD3D::getSamplerMapping(gl::SamplerType type, GLint ProgramD3D::getSamplerMapping(gl::ShaderType type,
unsigned int samplerIndex, unsigned int samplerIndex,
const gl::Caps &caps) const const gl::Caps &caps) const
{ {
...@@ -659,21 +659,21 @@ GLint ProgramD3D::getSamplerMapping(gl::SamplerType type, ...@@ -659,21 +659,21 @@ GLint ProgramD3D::getSamplerMapping(gl::SamplerType type,
switch (type) switch (type)
{ {
case gl::SAMPLER_PIXEL: case gl::SHADER_FRAGMENT:
ASSERT(samplerIndex < caps.maxTextureImageUnits); ASSERT(samplerIndex < caps.maxTextureImageUnits);
if (samplerIndex < mSamplersPS.size() && mSamplersPS[samplerIndex].active) if (samplerIndex < mSamplersPS.size() && mSamplersPS[samplerIndex].active)
{ {
logicalTextureUnit = mSamplersPS[samplerIndex].logicalTextureUnit; logicalTextureUnit = mSamplersPS[samplerIndex].logicalTextureUnit;
} }
break; break;
case gl::SAMPLER_VERTEX: case gl::SHADER_VERTEX:
ASSERT(samplerIndex < caps.maxVertexTextureImageUnits); ASSERT(samplerIndex < caps.maxVertexTextureImageUnits);
if (samplerIndex < mSamplersVS.size() && mSamplersVS[samplerIndex].active) if (samplerIndex < mSamplersVS.size() && mSamplersVS[samplerIndex].active)
{ {
logicalTextureUnit = mSamplersVS[samplerIndex].logicalTextureUnit; logicalTextureUnit = mSamplersVS[samplerIndex].logicalTextureUnit;
} }
break; break;
case gl::SAMPLER_COMPUTE: case gl::SHADER_COMPUTE:
ASSERT(samplerIndex < caps.maxComputeTextureImageUnits); ASSERT(samplerIndex < caps.maxComputeTextureImageUnits);
if (samplerIndex < mSamplersCS.size() && mSamplersCS[samplerIndex].active) if (samplerIndex < mSamplersCS.size() && mSamplersCS[samplerIndex].active)
{ {
...@@ -695,19 +695,19 @@ GLint ProgramD3D::getSamplerMapping(gl::SamplerType type, ...@@ -695,19 +695,19 @@ GLint ProgramD3D::getSamplerMapping(gl::SamplerType type,
// Returns the texture type for a given Direct3D 9 sampler type and // Returns the texture type for a given Direct3D 9 sampler type and
// index (0-15 for the pixel shader and 0-3 for the vertex shader). // index (0-15 for the pixel shader and 0-3 for the vertex shader).
GLenum ProgramD3D::getSamplerTextureType(gl::SamplerType type, unsigned int samplerIndex) const GLenum ProgramD3D::getSamplerTextureType(gl::ShaderType type, unsigned int samplerIndex) const
{ {
switch (type) switch (type)
{ {
case gl::SAMPLER_PIXEL: case gl::SHADER_FRAGMENT:
ASSERT(samplerIndex < mSamplersPS.size()); ASSERT(samplerIndex < mSamplersPS.size());
ASSERT(mSamplersPS[samplerIndex].active); ASSERT(mSamplersPS[samplerIndex].active);
return mSamplersPS[samplerIndex].textureType; return mSamplersPS[samplerIndex].textureType;
case gl::SAMPLER_VERTEX: case gl::SHADER_VERTEX:
ASSERT(samplerIndex < mSamplersVS.size()); ASSERT(samplerIndex < mSamplersVS.size());
ASSERT(mSamplersVS[samplerIndex].active); ASSERT(mSamplersVS[samplerIndex].active);
return mSamplersVS[samplerIndex].textureType; return mSamplersVS[samplerIndex].textureType;
case gl::SAMPLER_COMPUTE: case gl::SHADER_COMPUTE:
ASSERT(samplerIndex < mSamplersCS.size()); ASSERT(samplerIndex < mSamplersCS.size());
ASSERT(mSamplersCS[samplerIndex].active); ASSERT(mSamplersCS[samplerIndex].active);
return mSamplersCS[samplerIndex].textureType; return mSamplersCS[samplerIndex].textureType;
...@@ -718,15 +718,15 @@ GLenum ProgramD3D::getSamplerTextureType(gl::SamplerType type, unsigned int samp ...@@ -718,15 +718,15 @@ GLenum ProgramD3D::getSamplerTextureType(gl::SamplerType type, unsigned int samp
return GL_TEXTURE_2D; return GL_TEXTURE_2D;
} }
GLuint ProgramD3D::getUsedSamplerRange(gl::SamplerType type) const GLuint ProgramD3D::getUsedSamplerRange(gl::ShaderType type) const
{ {
switch (type) switch (type)
{ {
case gl::SAMPLER_PIXEL: case gl::SHADER_FRAGMENT:
return mUsedPixelSamplerRange; return mUsedPixelSamplerRange;
case gl::SAMPLER_VERTEX: case gl::SHADER_VERTEX:
return mUsedVertexSamplerRange; return mUsedVertexSamplerRange;
case gl::SAMPLER_COMPUTE: case gl::SHADER_COMPUTE:
return mUsedComputeSamplerRange; return mUsedComputeSamplerRange;
default: default:
UNREACHABLE(); UNREACHABLE();
......
...@@ -161,11 +161,11 @@ class ProgramD3D : public ProgramImpl ...@@ -161,11 +161,11 @@ class ProgramD3D : public ProgramImpl
const std::vector<PixelShaderOutputVariable> &getPixelShaderKey() { return mPixelShaderKey; } const std::vector<PixelShaderOutputVariable> &getPixelShaderKey() { return mPixelShaderKey; }
GLint getSamplerMapping(gl::SamplerType type, GLint getSamplerMapping(gl::ShaderType type,
unsigned int samplerIndex, unsigned int samplerIndex,
const gl::Caps &caps) const; const gl::Caps &caps) const;
GLenum getSamplerTextureType(gl::SamplerType type, unsigned int samplerIndex) const; GLenum getSamplerTextureType(gl::ShaderType type, unsigned int samplerIndex) const;
GLuint getUsedSamplerRange(gl::SamplerType type) const; GLuint getUsedSamplerRange(gl::ShaderType type) const;
enum SamplerMapping enum SamplerMapping
{ {
......
...@@ -1960,7 +1960,7 @@ gl::ErrorOrResult<TextureHelper11> Blit11::resolveDepth(const gl::Context *conte ...@@ -1960,7 +1960,7 @@ gl::ErrorOrResult<TextureHelper11> Blit11::resolveDepth(const gl::Context *conte
stateManager->setSimpleViewport(extents); stateManager->setSimpleViewport(extents);
// Set the viewport // Set the viewport
stateManager->setShaderResourceShared(gl::SAMPLER_PIXEL, 0, &depth->getShaderResourceView()); stateManager->setShaderResourceShared(gl::SHADER_FRAGMENT, 0, &depth->getShaderResourceView());
// Trigger the blit on the GPU. // Trigger the blit on the GPU.
deviceContext->Draw(6, 0); deviceContext->Draw(6, 0);
...@@ -2118,9 +2118,9 @@ gl::ErrorOrResult<TextureHelper11> Blit11::resolveStencil(const gl::Context *con ...@@ -2118,9 +2118,9 @@ gl::ErrorOrResult<TextureHelper11> Blit11::resolveStencil(const gl::Context *con
// Set the viewport // Set the viewport
stateManager->setSimpleViewport(extents); stateManager->setSimpleViewport(extents);
stateManager->setShaderResourceShared(gl::SAMPLER_PIXEL, 0, stateManager->setShaderResourceShared(gl::SHADER_FRAGMENT, 0,
&depthStencil->getShaderResourceView()); &depthStencil->getShaderResourceView());
stateManager->setShaderResource(gl::SAMPLER_PIXEL, 1, &mStencilSRV); stateManager->setShaderResource(gl::SHADER_FRAGMENT, 1, &mStencilSRV);
// Trigger the blit on the GPU. // Trigger the blit on the GPU.
deviceContext->Draw(6, 0); deviceContext->Draw(6, 0);
......
...@@ -191,7 +191,7 @@ gl::Error PixelTransfer11::copyBufferToTexture(const gl::Context *context, ...@@ -191,7 +191,7 @@ gl::Error PixelTransfer11::copyBufferToTexture(const gl::Context *context,
StateManager11 *stateManager = mRenderer->getStateManager(); StateManager11 *stateManager = mRenderer->getStateManager();
stateManager->setDrawShaders(&mBufferToTextureVS, geometryShader, pixelShader); stateManager->setDrawShaders(&mBufferToTextureVS, geometryShader, pixelShader);
stateManager->setShaderResource(gl::SAMPLER_PIXEL, 0, bufferSRV); stateManager->setShaderResource(gl::SHADER_FRAGMENT, 0, bufferSRV);
stateManager->setInputLayout(nullptr); stateManager->setInputLayout(nullptr);
stateManager->setPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_POINTLIST); stateManager->setPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_POINTLIST);
......
...@@ -249,15 +249,15 @@ void ShaderConstants11::init(const gl::Caps &caps) ...@@ -249,15 +249,15 @@ void ShaderConstants11::init(const gl::Caps &caps)
mSamplerMetadataCS.resize(caps.maxComputeTextureImageUnits); mSamplerMetadataCS.resize(caps.maxComputeTextureImageUnits);
} }
size_t ShaderConstants11::getRequiredBufferSize(gl::SamplerType samplerType) const size_t ShaderConstants11::getRequiredBufferSize(gl::ShaderType shaderType) const
{ {
switch (samplerType) switch (shaderType)
{ {
case gl::SAMPLER_VERTEX: case gl::SHADER_VERTEX:
return sizeof(Vertex) + mSamplerMetadataVS.size() * sizeof(SamplerMetadata); return sizeof(Vertex) + mSamplerMetadataVS.size() * sizeof(SamplerMetadata);
case gl::SAMPLER_PIXEL: case gl::SHADER_FRAGMENT:
return sizeof(Pixel) + mSamplerMetadataPS.size() * sizeof(SamplerMetadata); return sizeof(Pixel) + mSamplerMetadataPS.size() * sizeof(SamplerMetadata);
case gl::SAMPLER_COMPUTE: case gl::SHADER_COMPUTE:
return sizeof(Compute) + mSamplerMetadataCS.size() * sizeof(SamplerMetadata); return sizeof(Compute) + mSamplerMetadataCS.size() * sizeof(SamplerMetadata);
default: default:
UNREACHABLE(); UNREACHABLE();
...@@ -432,25 +432,25 @@ void ShaderConstants11::onViewportChange(const gl::Rectangle &glViewport, ...@@ -432,25 +432,25 @@ void ShaderConstants11::onViewportChange(const gl::Rectangle &glViewport,
mVertex.viewScale[1] = mPixel.viewScale[1]; mVertex.viewScale[1] = mPixel.viewScale[1];
} }
void ShaderConstants11::onSamplerChange(gl::SamplerType samplerType, void ShaderConstants11::onSamplerChange(gl::ShaderType shaderType,
unsigned int samplerIndex, unsigned int samplerIndex,
const gl::Texture &texture) const gl::Texture &texture)
{ {
switch (samplerType) switch (shaderType)
{ {
case gl::SAMPLER_VERTEX: case gl::SHADER_VERTEX:
if (updateSamplerMetadata(&mSamplerMetadataVS[samplerIndex], texture)) if (updateSamplerMetadata(&mSamplerMetadataVS[samplerIndex], texture))
{ {
mSamplerMetadataVSDirty = true; mSamplerMetadataVSDirty = true;
} }
break; break;
case gl::SAMPLER_PIXEL: case gl::SHADER_FRAGMENT:
if (updateSamplerMetadata(&mSamplerMetadataPS[samplerIndex], texture)) if (updateSamplerMetadata(&mSamplerMetadataPS[samplerIndex], texture))
{ {
mSamplerMetadataPSDirty = true; mSamplerMetadataPSDirty = true;
} }
break; break;
case gl::SAMPLER_COMPUTE: case gl::SHADER_COMPUTE:
if (updateSamplerMetadata(&mSamplerMetadataCS[samplerIndex], texture)) if (updateSamplerMetadata(&mSamplerMetadataCS[samplerIndex], texture))
{ {
mSamplerMetadataCSDirty = true; mSamplerMetadataCSDirty = true;
...@@ -463,7 +463,7 @@ void ShaderConstants11::onSamplerChange(gl::SamplerType samplerType, ...@@ -463,7 +463,7 @@ void ShaderConstants11::onSamplerChange(gl::SamplerType samplerType,
} }
gl::Error ShaderConstants11::updateBuffer(ID3D11DeviceContext *deviceContext, gl::Error ShaderConstants11::updateBuffer(ID3D11DeviceContext *deviceContext,
gl::SamplerType samplerType, gl::ShaderType shaderType,
const ProgramD3D &programD3D, const ProgramD3D &programD3D,
const d3d11::Buffer &driverConstantBuffer) const d3d11::Buffer &driverConstantBuffer)
{ {
...@@ -472,9 +472,9 @@ gl::Error ShaderConstants11::updateBuffer(ID3D11DeviceContext *deviceContext, ...@@ -472,9 +472,9 @@ gl::Error ShaderConstants11::updateBuffer(ID3D11DeviceContext *deviceContext,
const uint8_t *data = nullptr; const uint8_t *data = nullptr;
const uint8_t *samplerData = nullptr; const uint8_t *samplerData = nullptr;
switch (samplerType) switch (shaderType)
{ {
case gl::SAMPLER_VERTEX: case gl::SHADER_VERTEX:
dirty = mVertexDirty || mSamplerMetadataVSDirty; dirty = mVertexDirty || mSamplerMetadataVSDirty;
dataSize = sizeof(Vertex); dataSize = sizeof(Vertex);
data = reinterpret_cast<const uint8_t *>(&mVertex); data = reinterpret_cast<const uint8_t *>(&mVertex);
...@@ -482,7 +482,7 @@ gl::Error ShaderConstants11::updateBuffer(ID3D11DeviceContext *deviceContext, ...@@ -482,7 +482,7 @@ gl::Error ShaderConstants11::updateBuffer(ID3D11DeviceContext *deviceContext,
mVertexDirty = false; mVertexDirty = false;
mSamplerMetadataVSDirty = false; mSamplerMetadataVSDirty = false;
break; break;
case gl::SAMPLER_PIXEL: case gl::SHADER_FRAGMENT:
dirty = mPixelDirty || mSamplerMetadataPSDirty; dirty = mPixelDirty || mSamplerMetadataPSDirty;
dataSize = sizeof(Pixel); dataSize = sizeof(Pixel);
data = reinterpret_cast<const uint8_t *>(&mPixel); data = reinterpret_cast<const uint8_t *>(&mPixel);
...@@ -490,7 +490,7 @@ gl::Error ShaderConstants11::updateBuffer(ID3D11DeviceContext *deviceContext, ...@@ -490,7 +490,7 @@ gl::Error ShaderConstants11::updateBuffer(ID3D11DeviceContext *deviceContext,
mPixelDirty = false; mPixelDirty = false;
mSamplerMetadataPSDirty = false; mSamplerMetadataPSDirty = false;
break; break;
case gl::SAMPLER_COMPUTE: case gl::SHADER_COMPUTE:
dirty = mComputeDirty || mSamplerMetadataCSDirty; dirty = mComputeDirty || mSamplerMetadataCSDirty;
dataSize = sizeof(Compute); dataSize = sizeof(Compute);
data = reinterpret_cast<const uint8_t *>(&mCompute); data = reinterpret_cast<const uint8_t *>(&mCompute);
...@@ -520,7 +520,7 @@ gl::Error ShaderConstants11::updateBuffer(ID3D11DeviceContext *deviceContext, ...@@ -520,7 +520,7 @@ gl::Error ShaderConstants11::updateBuffer(ID3D11DeviceContext *deviceContext,
return gl::OutOfMemory() << "Internal error mapping constant buffer: " << gl::FmtHR(result); return gl::OutOfMemory() << "Internal error mapping constant buffer: " << gl::FmtHR(result);
} }
size_t samplerDataBytes = sizeof(SamplerMetadata) * programD3D.getUsedSamplerRange(samplerType); size_t samplerDataBytes = sizeof(SamplerMetadata) * programD3D.getUsedSamplerRange(shaderType);
memcpy(mapping.pData, data, dataSize); memcpy(mapping.pData, data, dataSize);
memcpy(reinterpret_cast<uint8_t *>(mapping.pData) + dataSize, samplerData, samplerDataBytes); memcpy(reinterpret_cast<uint8_t *>(mapping.pData) + dataSize, samplerData, samplerDataBytes);
...@@ -625,11 +625,11 @@ StateManager11::~StateManager11() ...@@ -625,11 +625,11 @@ StateManager11::~StateManager11()
} }
template <typename SRVType> template <typename SRVType>
void StateManager11::setShaderResourceInternal(gl::SamplerType shaderType, void StateManager11::setShaderResourceInternal(gl::ShaderType shaderType,
UINT resourceSlot, UINT resourceSlot,
const SRVType *srv) const SRVType *srv)
{ {
auto &currentSRVs = (shaderType == gl::SAMPLER_VERTEX ? mCurVertexSRVs : mCurPixelSRVs); auto &currentSRVs = (shaderType == gl::SHADER_VERTEX ? mCurVertexSRVs : mCurPixelSRVs);
ASSERT(static_cast<size_t>(resourceSlot) < currentSRVs.size()); ASSERT(static_cast<size_t>(resourceSlot) < currentSRVs.size());
const SRVRecord &record = currentSRVs[resourceSlot]; const SRVRecord &record = currentSRVs[resourceSlot];
...@@ -638,7 +638,7 @@ void StateManager11::setShaderResourceInternal(gl::SamplerType shaderType, ...@@ -638,7 +638,7 @@ void StateManager11::setShaderResourceInternal(gl::SamplerType shaderType,
{ {
ID3D11DeviceContext *deviceContext = mRenderer->getDeviceContext(); ID3D11DeviceContext *deviceContext = mRenderer->getDeviceContext();
ID3D11ShaderResourceView *srvPtr = srv ? srv->get() : nullptr; ID3D11ShaderResourceView *srvPtr = srv ? srv->get() : nullptr;
if (shaderType == gl::SAMPLER_VERTEX) if (shaderType == gl::SHADER_VERTEX)
{ {
deviceContext->VSSetShaderResources(resourceSlot, 1, &srvPtr); deviceContext->VSSetShaderResources(resourceSlot, 1, &srvPtr);
} }
...@@ -702,7 +702,7 @@ gl::Error StateManager11::updateStateForCompute(const gl::Context *context, ...@@ -702,7 +702,7 @@ gl::Error StateManager11::updateStateForCompute(const gl::Context *context,
programD3D->updateSamplerMapping(); programD3D->updateSamplerMapping();
// TODO(jmadill): Use dirty bits. // TODO(jmadill): Use dirty bits.
ANGLE_TRY(generateSwizzlesForShader(context, gl::SAMPLER_COMPUTE)); ANGLE_TRY(generateSwizzlesForShader(context, gl::SHADER_COMPUTE));
// TODO(jmadill): More complete implementation. // TODO(jmadill): More complete implementation.
ANGLE_TRY(syncTextures(context)); ANGLE_TRY(syncTextures(context));
...@@ -1522,7 +1522,7 @@ gl::Error StateManager11::onMakeCurrent(const gl::Context *context) ...@@ -1522,7 +1522,7 @@ gl::Error StateManager11::onMakeCurrent(const gl::Context *context)
return gl::NoError(); return gl::NoError();
} }
gl::Error StateManager11::clearTextures(gl::SamplerType samplerType, gl::Error StateManager11::clearTextures(gl::ShaderType shaderType,
size_t rangeStart, size_t rangeStart,
size_t rangeEnd) size_t rangeEnd)
{ {
...@@ -1531,7 +1531,7 @@ gl::Error StateManager11::clearTextures(gl::SamplerType samplerType, ...@@ -1531,7 +1531,7 @@ gl::Error StateManager11::clearTextures(gl::SamplerType samplerType,
return gl::NoError(); return gl::NoError();
} }
auto &currentSRVs = (samplerType == gl::SAMPLER_VERTEX ? mCurVertexSRVs : mCurPixelSRVs); auto &currentSRVs = (shaderType == gl::SHADER_VERTEX ? mCurVertexSRVs : mCurPixelSRVs);
gl::Range<size_t> clearRange(rangeStart, std::min(rangeEnd, currentSRVs.highestUsed())); gl::Range<size_t> clearRange(rangeStart, std::min(rangeEnd, currentSRVs.highestUsed()));
if (clearRange.empty()) if (clearRange.empty())
...@@ -1540,7 +1540,7 @@ gl::Error StateManager11::clearTextures(gl::SamplerType samplerType, ...@@ -1540,7 +1540,7 @@ gl::Error StateManager11::clearTextures(gl::SamplerType samplerType,
} }
ID3D11DeviceContext *deviceContext = mRenderer->getDeviceContext(); ID3D11DeviceContext *deviceContext = mRenderer->getDeviceContext();
if (samplerType == gl::SAMPLER_VERTEX) if (shaderType == gl::SHADER_VERTEX)
{ {
deviceContext->VSSetShaderResources(static_cast<unsigned int>(clearRange.low()), deviceContext->VSSetShaderResources(static_cast<unsigned int>(clearRange.low()),
static_cast<unsigned int>(clearRange.length()), static_cast<unsigned int>(clearRange.length()),
...@@ -1564,15 +1564,15 @@ gl::Error StateManager11::clearTextures(gl::SamplerType samplerType, ...@@ -1564,15 +1564,15 @@ gl::Error StateManager11::clearTextures(gl::SamplerType samplerType,
bool StateManager11::unsetConflictingView(ID3D11View *view) bool StateManager11::unsetConflictingView(ID3D11View *view)
{ {
uintptr_t resource = reinterpret_cast<uintptr_t>(GetViewResource(view)); uintptr_t resource = reinterpret_cast<uintptr_t>(GetViewResource(view));
return unsetConflictingSRVs(gl::SAMPLER_VERTEX, resource, nullptr) || return unsetConflictingSRVs(gl::SHADER_VERTEX, resource, nullptr) ||
unsetConflictingSRVs(gl::SAMPLER_PIXEL, resource, nullptr); unsetConflictingSRVs(gl::SHADER_FRAGMENT, resource, nullptr);
} }
bool StateManager11::unsetConflictingSRVs(gl::SamplerType samplerType, bool StateManager11::unsetConflictingSRVs(gl::ShaderType shaderType,
uintptr_t resource, uintptr_t resource,
const gl::ImageIndex *index) const gl::ImageIndex *index)
{ {
auto &currentSRVs = (samplerType == gl::SAMPLER_VERTEX ? mCurVertexSRVs : mCurPixelSRVs); auto &currentSRVs = (shaderType == gl::SHADER_VERTEX ? mCurVertexSRVs : mCurPixelSRVs);
bool foundOne = false; bool foundOne = false;
...@@ -1584,7 +1584,7 @@ bool StateManager11::unsetConflictingSRVs(gl::SamplerType samplerType, ...@@ -1584,7 +1584,7 @@ bool StateManager11::unsetConflictingSRVs(gl::SamplerType samplerType,
(!index || ImageIndexConflictsWithSRV(*index, record.desc))) (!index || ImageIndexConflictsWithSRV(*index, record.desc)))
{ {
setShaderResourceInternal<d3d11::ShaderResourceView>( setShaderResourceInternal<d3d11::ShaderResourceView>(
samplerType, static_cast<UINT>(resourceIndex), nullptr); shaderType, static_cast<UINT>(resourceIndex), nullptr);
foundOne = true; foundOne = true;
} }
} }
...@@ -1603,14 +1603,14 @@ void StateManager11::unsetConflictingAttachmentResources( ...@@ -1603,14 +1603,14 @@ void StateManager11::unsetConflictingAttachmentResources(
const gl::ImageIndex &index = attachment->getTextureImageIndex(); const gl::ImageIndex &index = attachment->getTextureImageIndex();
// The index doesn't need to be corrected for the small compressed texture workaround // The index doesn't need to be corrected for the small compressed texture workaround
// because a rendertarget is never compressed. // because a rendertarget is never compressed.
unsetConflictingSRVs(gl::SAMPLER_VERTEX, resourcePtr, &index); unsetConflictingSRVs(gl::SHADER_VERTEX, resourcePtr, &index);
unsetConflictingSRVs(gl::SAMPLER_PIXEL, resourcePtr, &index); unsetConflictingSRVs(gl::SHADER_FRAGMENT, resourcePtr, &index);
} }
else if (attachment->type() == GL_FRAMEBUFFER_DEFAULT) else if (attachment->type() == GL_FRAMEBUFFER_DEFAULT)
{ {
uintptr_t resourcePtr = reinterpret_cast<uintptr_t>(resource); uintptr_t resourcePtr = reinterpret_cast<uintptr_t>(resource);
unsetConflictingSRVs(gl::SAMPLER_VERTEX, resourcePtr, nullptr); unsetConflictingSRVs(gl::SHADER_VERTEX, resourcePtr, nullptr);
unsetConflictingSRVs(gl::SAMPLER_PIXEL, resourcePtr, nullptr); unsetConflictingSRVs(gl::SHADER_FRAGMENT, resourcePtr, nullptr);
} }
} }
...@@ -1994,7 +1994,7 @@ gl::Error StateManager11::updateState(const gl::Context *context, GLenum drawMod ...@@ -1994,7 +1994,7 @@ gl::Error StateManager11::updateState(const gl::Context *context, GLenum drawMod
return gl::NoError(); return gl::NoError();
} }
void StateManager11::setShaderResourceShared(gl::SamplerType shaderType, void StateManager11::setShaderResourceShared(gl::ShaderType shaderType,
UINT resourceSlot, UINT resourceSlot,
const d3d11::SharedSRV *srv) const d3d11::SharedSRV *srv)
{ {
...@@ -2004,7 +2004,7 @@ void StateManager11::setShaderResourceShared(gl::SamplerType shaderType, ...@@ -2004,7 +2004,7 @@ void StateManager11::setShaderResourceShared(gl::SamplerType shaderType,
mInternalDirtyBits.set(DIRTY_BIT_TEXTURE_AND_SAMPLER_STATE); mInternalDirtyBits.set(DIRTY_BIT_TEXTURE_AND_SAMPLER_STATE);
} }
void StateManager11::setShaderResource(gl::SamplerType shaderType, void StateManager11::setShaderResource(gl::ShaderType shaderType,
UINT resourceSlot, UINT resourceSlot,
const d3d11::ShaderResourceView *srv) const d3d11::ShaderResourceView *srv)
{ {
...@@ -2215,7 +2215,7 @@ void StateManager11::setSimplePixelTextureAndSampler(const d3d11::SharedSRV &srv ...@@ -2215,7 +2215,7 @@ void StateManager11::setSimplePixelTextureAndSampler(const d3d11::SharedSRV &srv
{ {
ID3D11DeviceContext *deviceContext = mRenderer->getDeviceContext(); ID3D11DeviceContext *deviceContext = mRenderer->getDeviceContext();
setShaderResourceInternal(gl::SAMPLER_PIXEL, 0, &srv); setShaderResourceInternal(gl::SHADER_FRAGMENT, 0, &srv);
deviceContext->PSSetSamplers(0, 1, samplerState.getPointer()); deviceContext->PSSetSamplers(0, 1, samplerState.getPointer());
mInternalDirtyBits.set(DIRTY_BIT_TEXTURE_AND_SAMPLER_STATE); mInternalDirtyBits.set(DIRTY_BIT_TEXTURE_AND_SAMPLER_STATE);
...@@ -2242,7 +2242,7 @@ void StateManager11::setScissorRectD3D(const D3D11_RECT &d3dRect) ...@@ -2242,7 +2242,7 @@ void StateManager11::setScissorRectD3D(const D3D11_RECT &d3dRect)
// looks up the corresponding OpenGL texture image unit and texture type, // looks up the corresponding OpenGL texture image unit and texture type,
// and sets the texture and its addressing/filtering state (or NULL when inactive). // and sets the texture and its addressing/filtering state (or NULL when inactive).
// Sampler mapping needs to be up-to-date on the program object before this is called. // Sampler mapping needs to be up-to-date on the program object before this is called.
gl::Error StateManager11::applyTextures(const gl::Context *context, gl::SamplerType shaderType) gl::Error StateManager11::applyTextures(const gl::Context *context, gl::ShaderType shaderType)
{ {
const auto &glState = context->getGLState(); const auto &glState = context->getGLState();
const auto &caps = context->getCaps(); const auto &caps = context->getCaps();
...@@ -2286,8 +2286,8 @@ gl::Error StateManager11::applyTextures(const gl::Context *context, gl::SamplerT ...@@ -2286,8 +2286,8 @@ gl::Error StateManager11::applyTextures(const gl::Context *context, gl::SamplerT
} }
// Set all the remaining textures to NULL // Set all the remaining textures to NULL
size_t samplerCount = (shaderType == gl::SAMPLER_PIXEL) ? caps.maxTextureImageUnits size_t samplerCount = (shaderType == gl::SHADER_FRAGMENT) ? caps.maxTextureImageUnits
: caps.maxVertexTextureImageUnits; : caps.maxVertexTextureImageUnits;
ANGLE_TRY(clearTextures(shaderType, samplerRange, samplerCount)); ANGLE_TRY(clearTextures(shaderType, samplerRange, samplerCount));
return gl::NoError(); return gl::NoError();
...@@ -2295,13 +2295,13 @@ gl::Error StateManager11::applyTextures(const gl::Context *context, gl::SamplerT ...@@ -2295,13 +2295,13 @@ gl::Error StateManager11::applyTextures(const gl::Context *context, gl::SamplerT
gl::Error StateManager11::syncTextures(const gl::Context *context) gl::Error StateManager11::syncTextures(const gl::Context *context)
{ {
ANGLE_TRY(applyTextures(context, gl::SAMPLER_VERTEX)); ANGLE_TRY(applyTextures(context, gl::SHADER_VERTEX));
ANGLE_TRY(applyTextures(context, gl::SAMPLER_PIXEL)); ANGLE_TRY(applyTextures(context, gl::SHADER_FRAGMENT));
return gl::NoError(); return gl::NoError();
} }
gl::Error StateManager11::setSamplerState(const gl::Context *context, gl::Error StateManager11::setSamplerState(const gl::Context *context,
gl::SamplerType type, gl::ShaderType type,
int index, int index,
gl::Texture *texture, gl::Texture *texture,
const gl::SamplerState &samplerState) const gl::SamplerState &samplerState)
...@@ -2316,7 +2316,7 @@ gl::Error StateManager11::setSamplerState(const gl::Context *context, ...@@ -2316,7 +2316,7 @@ gl::Error StateManager11::setSamplerState(const gl::Context *context,
auto *deviceContext = mRenderer->getDeviceContext(); auto *deviceContext = mRenderer->getDeviceContext();
if (type == gl::SAMPLER_PIXEL) if (type == gl::SHADER_FRAGMENT)
{ {
ASSERT(static_cast<unsigned int>(index) < mRenderer->getNativeCaps().maxTextureImageUnits); ASSERT(static_cast<unsigned int>(index) < mRenderer->getNativeCaps().maxTextureImageUnits);
...@@ -2334,7 +2334,7 @@ gl::Error StateManager11::setSamplerState(const gl::Context *context, ...@@ -2334,7 +2334,7 @@ gl::Error StateManager11::setSamplerState(const gl::Context *context,
mForceSetPixelSamplerStates[index] = false; mForceSetPixelSamplerStates[index] = false;
} }
else if (type == gl::SAMPLER_VERTEX) else if (type == gl::SHADER_VERTEX)
{ {
ASSERT(static_cast<unsigned int>(index) < ASSERT(static_cast<unsigned int>(index) <
mRenderer->getNativeCaps().maxVertexTextureImageUnits); mRenderer->getNativeCaps().maxVertexTextureImageUnits);
...@@ -2353,7 +2353,7 @@ gl::Error StateManager11::setSamplerState(const gl::Context *context, ...@@ -2353,7 +2353,7 @@ gl::Error StateManager11::setSamplerState(const gl::Context *context,
mForceSetVertexSamplerStates[index] = false; mForceSetVertexSamplerStates[index] = false;
} }
else if (type == gl::SAMPLER_COMPUTE) else if (type == gl::SHADER_COMPUTE)
{ {
ASSERT(static_cast<unsigned int>(index) < ASSERT(static_cast<unsigned int>(index) <
mRenderer->getNativeCaps().maxComputeTextureImageUnits); mRenderer->getNativeCaps().maxComputeTextureImageUnits);
...@@ -2384,7 +2384,7 @@ gl::Error StateManager11::setSamplerState(const gl::Context *context, ...@@ -2384,7 +2384,7 @@ gl::Error StateManager11::setSamplerState(const gl::Context *context,
} }
gl::Error StateManager11::setTexture(const gl::Context *context, gl::Error StateManager11::setTexture(const gl::Context *context,
gl::SamplerType type, gl::ShaderType type,
int index, int index,
gl::Texture *texture) gl::Texture *texture)
{ {
...@@ -2412,9 +2412,9 @@ gl::Error StateManager11::setTexture(const gl::Context *context, ...@@ -2412,9 +2412,9 @@ gl::Error StateManager11::setTexture(const gl::Context *context,
} }
ASSERT( ASSERT(
(type == gl::SAMPLER_PIXEL && (type == gl::SHADER_FRAGMENT &&
static_cast<unsigned int>(index) < mRenderer->getNativeCaps().maxTextureImageUnits) || static_cast<unsigned int>(index) < mRenderer->getNativeCaps().maxTextureImageUnits) ||
(type == gl::SAMPLER_VERTEX && (type == gl::SHADER_VERTEX &&
static_cast<unsigned int>(index) < mRenderer->getNativeCaps().maxVertexTextureImageUnits)); static_cast<unsigned int>(index) < mRenderer->getNativeCaps().maxVertexTextureImageUnits));
setShaderResourceInternal(type, index, textureSRV); setShaderResourceInternal(type, index, textureSRV);
...@@ -2672,8 +2672,7 @@ gl::Error StateManager11::generateSwizzle(const gl::Context *context, gl::Textur ...@@ -2672,8 +2672,7 @@ gl::Error StateManager11::generateSwizzle(const gl::Context *context, gl::Textur
return gl::NoError(); return gl::NoError();
} }
gl::Error StateManager11::generateSwizzlesForShader(const gl::Context *context, gl::Error StateManager11::generateSwizzlesForShader(const gl::Context *context, gl::ShaderType type)
gl::SamplerType type)
{ {
const auto &glState = context->getGLState(); const auto &glState = context->getGLState();
ProgramD3D *programD3D = GetImplAs<ProgramD3D>(glState.getProgram()); ProgramD3D *programD3D = GetImplAs<ProgramD3D>(glState.getProgram());
...@@ -2700,8 +2699,8 @@ gl::Error StateManager11::generateSwizzlesForShader(const gl::Context *context, ...@@ -2700,8 +2699,8 @@ gl::Error StateManager11::generateSwizzlesForShader(const gl::Context *context,
gl::Error StateManager11::generateSwizzles(const gl::Context *context) gl::Error StateManager11::generateSwizzles(const gl::Context *context)
{ {
ANGLE_TRY(generateSwizzlesForShader(context, gl::SAMPLER_VERTEX)); ANGLE_TRY(generateSwizzlesForShader(context, gl::SHADER_VERTEX));
ANGLE_TRY(generateSwizzlesForShader(context, gl::SAMPLER_PIXEL)); ANGLE_TRY(generateSwizzlesForShader(context, gl::SHADER_FRAGMENT));
return gl::NoError(); return gl::NoError();
} }
...@@ -2760,7 +2759,7 @@ gl::Error StateManager11::applyDriverUniforms(const ProgramD3D &programD3D) ...@@ -2760,7 +2759,7 @@ gl::Error StateManager11::applyDriverUniforms(const ProgramD3D &programD3D)
if (!mDriverConstantBufferVS.valid()) if (!mDriverConstantBufferVS.valid())
{ {
size_t requiredSize = mShaderConstants.getRequiredBufferSize(gl::SAMPLER_VERTEX); size_t requiredSize = mShaderConstants.getRequiredBufferSize(gl::SHADER_VERTEX);
D3D11_BUFFER_DESC constantBufferDescription = {0}; D3D11_BUFFER_DESC constantBufferDescription = {0};
d3d11::InitConstantBufferDesc(&constantBufferDescription, requiredSize); d3d11::InitConstantBufferDesc(&constantBufferDescription, requiredSize);
...@@ -2773,7 +2772,7 @@ gl::Error StateManager11::applyDriverUniforms(const ProgramD3D &programD3D) ...@@ -2773,7 +2772,7 @@ gl::Error StateManager11::applyDriverUniforms(const ProgramD3D &programD3D)
if (!mDriverConstantBufferPS.valid()) if (!mDriverConstantBufferPS.valid())
{ {
size_t requiredSize = mShaderConstants.getRequiredBufferSize(gl::SAMPLER_PIXEL); size_t requiredSize = mShaderConstants.getRequiredBufferSize(gl::SHADER_FRAGMENT);
D3D11_BUFFER_DESC constantBufferDescription = {0}; D3D11_BUFFER_DESC constantBufferDescription = {0};
d3d11::InitConstantBufferDesc(&constantBufferDescription, requiredSize); d3d11::InitConstantBufferDesc(&constantBufferDescription, requiredSize);
...@@ -2786,9 +2785,9 @@ gl::Error StateManager11::applyDriverUniforms(const ProgramD3D &programD3D) ...@@ -2786,9 +2785,9 @@ gl::Error StateManager11::applyDriverUniforms(const ProgramD3D &programD3D)
// Sampler metadata and driver constants need to coexist in the same constant buffer to conserve // Sampler metadata and driver constants need to coexist in the same constant buffer to conserve
// constant buffer slots. We update both in the constant buffer if needed. // constant buffer slots. We update both in the constant buffer if needed.
ANGLE_TRY(mShaderConstants.updateBuffer(deviceContext, gl::SAMPLER_VERTEX, programD3D, ANGLE_TRY(mShaderConstants.updateBuffer(deviceContext, gl::SHADER_VERTEX, programD3D,
mDriverConstantBufferVS)); mDriverConstantBufferVS));
ANGLE_TRY(mShaderConstants.updateBuffer(deviceContext, gl::SAMPLER_PIXEL, programD3D, ANGLE_TRY(mShaderConstants.updateBuffer(deviceContext, gl::SHADER_FRAGMENT, programD3D,
mDriverConstantBufferPS)); mDriverConstantBufferPS));
// needed for the point sprite geometry shader // needed for the point sprite geometry shader
...@@ -2833,7 +2832,7 @@ gl::Error StateManager11::applyComputeUniforms(ProgramD3D *programD3D) ...@@ -2833,7 +2832,7 @@ gl::Error StateManager11::applyComputeUniforms(ProgramD3D *programD3D)
if (!mDriverConstantBufferCS.valid()) if (!mDriverConstantBufferCS.valid())
{ {
size_t requiredSize = mShaderConstants.getRequiredBufferSize(gl::SAMPLER_COMPUTE); size_t requiredSize = mShaderConstants.getRequiredBufferSize(gl::SHADER_COMPUTE);
D3D11_BUFFER_DESC constantBufferDescription = {0}; D3D11_BUFFER_DESC constantBufferDescription = {0};
d3d11::InitConstantBufferDesc(&constantBufferDescription, requiredSize); d3d11::InitConstantBufferDesc(&constantBufferDescription, requiredSize);
...@@ -2843,7 +2842,7 @@ gl::Error StateManager11::applyComputeUniforms(ProgramD3D *programD3D) ...@@ -2843,7 +2842,7 @@ gl::Error StateManager11::applyComputeUniforms(ProgramD3D *programD3D)
&buffer); &buffer);
} }
ANGLE_TRY(mShaderConstants.updateBuffer(deviceContext, gl::SAMPLER_COMPUTE, *programD3D, ANGLE_TRY(mShaderConstants.updateBuffer(deviceContext, gl::SHADER_COMPUTE, *programD3D,
mDriverConstantBufferCS)); mDriverConstantBufferCS));
return gl::NoError(); return gl::NoError();
......
...@@ -34,7 +34,7 @@ class ShaderConstants11 : angle::NonCopyable ...@@ -34,7 +34,7 @@ class ShaderConstants11 : angle::NonCopyable
~ShaderConstants11(); ~ShaderConstants11();
void init(const gl::Caps &caps); void init(const gl::Caps &caps);
size_t getRequiredBufferSize(gl::SamplerType samplerType) const; size_t getRequiredBufferSize(gl::ShaderType shaderType) const;
void markDirty(); void markDirty();
void setComputeWorkGroups(GLuint numGroupsX, GLuint numGroupsY, GLuint numGroupsZ); void setComputeWorkGroups(GLuint numGroupsX, GLuint numGroupsY, GLuint numGroupsZ);
...@@ -43,12 +43,12 @@ class ShaderConstants11 : angle::NonCopyable ...@@ -43,12 +43,12 @@ class ShaderConstants11 : angle::NonCopyable
const D3D11_VIEWPORT &dxViewport, const D3D11_VIEWPORT &dxViewport,
bool is9_3, bool is9_3,
bool presentPathFast); bool presentPathFast);
void onSamplerChange(gl::SamplerType samplerType, void onSamplerChange(gl::ShaderType shaderType,
unsigned int samplerIndex, unsigned int samplerIndex,
const gl::Texture &texture); const gl::Texture &texture);
gl::Error updateBuffer(ID3D11DeviceContext *deviceContext, gl::Error updateBuffer(ID3D11DeviceContext *deviceContext,
gl::SamplerType samplerType, gl::ShaderType shaderType,
const ProgramD3D &programD3D, const ProgramD3D &programD3D,
const d3d11::Buffer &driverConstantBuffer); const d3d11::Buffer &driverConstantBuffer);
...@@ -236,10 +236,10 @@ class StateManager11 final : angle::NonCopyable ...@@ -236,10 +236,10 @@ class StateManager11 final : angle::NonCopyable
gl::Error updateState(const gl::Context *context, GLenum drawMode); gl::Error updateState(const gl::Context *context, GLenum drawMode);
void setShaderResourceShared(gl::SamplerType shaderType, void setShaderResourceShared(gl::ShaderType shaderType,
UINT resourceSlot, UINT resourceSlot,
const d3d11::SharedSRV *srv); const d3d11::SharedSRV *srv);
void setShaderResource(gl::SamplerType shaderType, void setShaderResource(gl::ShaderType shaderType,
UINT resourceSlot, UINT resourceSlot,
const d3d11::ShaderResourceView *srv); const d3d11::ShaderResourceView *srv);
void setPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY primitiveTopology); void setPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY primitiveTopology);
...@@ -289,12 +289,12 @@ class StateManager11 final : angle::NonCopyable ...@@ -289,12 +289,12 @@ class StateManager11 final : angle::NonCopyable
private: private:
template <typename SRVType> template <typename SRVType>
void setShaderResourceInternal(gl::SamplerType shaderType, void setShaderResourceInternal(gl::ShaderType shaderType,
UINT resourceSlot, UINT resourceSlot,
const SRVType *srv); const SRVType *srv);
bool unsetConflictingView(ID3D11View *view); bool unsetConflictingView(ID3D11View *view);
bool unsetConflictingSRVs(gl::SamplerType shaderType, bool unsetConflictingSRVs(gl::ShaderType shaderType,
uintptr_t resource, uintptr_t resource,
const gl::ImageIndex *index); const gl::ImageIndex *index);
void unsetConflictingAttachmentResources(const gl::FramebufferAttachment *attachment, void unsetConflictingAttachmentResources(const gl::FramebufferAttachment *attachment,
...@@ -320,26 +320,26 @@ class StateManager11 final : angle::NonCopyable ...@@ -320,26 +320,26 @@ class StateManager11 final : angle::NonCopyable
gl::Error syncProgram(const gl::Context *context, GLenum drawMode); gl::Error syncProgram(const gl::Context *context, GLenum drawMode);
gl::Error syncTextures(const gl::Context *context); gl::Error syncTextures(const gl::Context *context);
gl::Error applyTextures(const gl::Context *context, gl::SamplerType shaderType); gl::Error applyTextures(const gl::Context *context, gl::ShaderType shaderType);
gl::Error setSamplerState(const gl::Context *context, gl::Error setSamplerState(const gl::Context *context,
gl::SamplerType type, gl::ShaderType type,
int index, int index,
gl::Texture *texture, gl::Texture *texture,
const gl::SamplerState &sampler); const gl::SamplerState &sampler);
gl::Error setTexture(const gl::Context *context, gl::Error setTexture(const gl::Context *context,
gl::SamplerType type, gl::ShaderType type,
int index, int index,
gl::Texture *texture); gl::Texture *texture);
// Faster than calling setTexture a jillion times // Faster than calling setTexture a jillion times
gl::Error clearTextures(gl::SamplerType samplerType, size_t rangeStart, size_t rangeEnd); gl::Error clearTextures(gl::ShaderType shaderType, size_t rangeStart, size_t rangeEnd);
void handleMultiviewDrawFramebufferChange(const gl::Context *context); void handleMultiviewDrawFramebufferChange(const gl::Context *context);
gl::Error syncCurrentValueAttribs(const gl::State &glState); gl::Error syncCurrentValueAttribs(const gl::State &glState);
gl::Error generateSwizzle(const gl::Context *context, gl::Texture *texture); gl::Error generateSwizzle(const gl::Context *context, gl::Texture *texture);
gl::Error generateSwizzlesForShader(const gl::Context *context, gl::SamplerType type); gl::Error generateSwizzlesForShader(const gl::Context *context, gl::ShaderType type);
gl::Error generateSwizzles(const gl::Context *context); gl::Error generateSwizzles(const gl::Context *context);
gl::Error applyDriverUniforms(const ProgramD3D &programD3D); gl::Error applyDriverUniforms(const ProgramD3D &programD3D);
......
...@@ -935,13 +935,14 @@ gl::Error Renderer9::fastCopyBufferToTexture(const gl::Context *context, ...@@ -935,13 +935,14 @@ gl::Error Renderer9::fastCopyBufferToTexture(const gl::Context *context,
} }
gl::Error Renderer9::setSamplerState(const gl::Context *context, gl::Error Renderer9::setSamplerState(const gl::Context *context,
gl::SamplerType type, gl::ShaderType type,
int index, int index,
gl::Texture *texture, gl::Texture *texture,
const gl::SamplerState &samplerState) const gl::SamplerState &samplerState)
{ {
CurSamplerState &appliedSampler = (type == gl::SAMPLER_PIXEL) ? mCurPixelSamplerStates[index] CurSamplerState &appliedSampler = (type == gl::SHADER_FRAGMENT)
: mCurVertexSamplerStates[index]; ? mCurPixelSamplerStates[index]
: mCurVertexSamplerStates[index];
// Make sure to add the level offset for our tiny compressed texture workaround // Make sure to add the level offset for our tiny compressed texture workaround
TextureD3D *textureD3D = GetImplAs<TextureD3D>(texture); TextureD3D *textureD3D = GetImplAs<TextureD3D>(texture);
...@@ -957,7 +958,7 @@ gl::Error Renderer9::setSamplerState(const gl::Context *context, ...@@ -957,7 +958,7 @@ gl::Error Renderer9::setSamplerState(const gl::Context *context,
if (appliedSampler.forceSet || appliedSampler.baseLevel != baseLevel || if (appliedSampler.forceSet || appliedSampler.baseLevel != baseLevel ||
memcmp(&samplerState, &appliedSampler, sizeof(gl::SamplerState)) != 0) memcmp(&samplerState, &appliedSampler, sizeof(gl::SamplerState)) != 0)
{ {
int d3dSamplerOffset = (type == gl::SAMPLER_PIXEL) ? 0 : D3DVERTEXTEXTURESAMPLER0; int d3dSamplerOffset = (type == gl::SHADER_FRAGMENT) ? 0 : D3DVERTEXTEXTURESAMPLER0;
int d3dSampler = index + d3dSamplerOffset; int d3dSampler = index + d3dSamplerOffset;
mDevice->SetSamplerState(d3dSampler, D3DSAMP_ADDRESSU, mDevice->SetSamplerState(d3dSampler, D3DSAMP_ADDRESSU,
...@@ -993,17 +994,17 @@ gl::Error Renderer9::setSamplerState(const gl::Context *context, ...@@ -993,17 +994,17 @@ gl::Error Renderer9::setSamplerState(const gl::Context *context,
} }
gl::Error Renderer9::setTexture(const gl::Context *context, gl::Error Renderer9::setTexture(const gl::Context *context,
gl::SamplerType type, gl::ShaderType type,
int index, int index,
gl::Texture *texture) gl::Texture *texture)
{ {
int d3dSamplerOffset = (type == gl::SAMPLER_PIXEL) ? 0 : D3DVERTEXTEXTURESAMPLER0; int d3dSamplerOffset = (type == gl::SHADER_FRAGMENT) ? 0 : D3DVERTEXTEXTURESAMPLER0;
int d3dSampler = index + d3dSamplerOffset; int d3dSampler = index + d3dSamplerOffset;
IDirect3DBaseTexture9 *d3dTexture = nullptr; IDirect3DBaseTexture9 *d3dTexture = nullptr;
bool forceSetTexture = false; bool forceSetTexture = false;
std::vector<uintptr_t> &appliedTextures = std::vector<uintptr_t> &appliedTextures =
(type == gl::SAMPLER_PIXEL) ? mCurPixelTextures : mCurVertexTextures; (type == gl::SHADER_FRAGMENT) ? mCurPixelTextures : mCurVertexTextures;
if (texture) if (texture)
{ {
...@@ -3244,7 +3245,7 @@ bool Renderer9::canSelectViewInVertexShader() const ...@@ -3244,7 +3245,7 @@ bool Renderer9::canSelectViewInVertexShader() const
// looks up the corresponding OpenGL texture image unit and texture type, // looks up the corresponding OpenGL texture image unit and texture type,
// and sets the texture and its addressing/filtering state (or NULL when inactive). // and sets the texture and its addressing/filtering state (or NULL when inactive).
// Sampler mapping needs to be up-to-date on the program object before this is called. // Sampler mapping needs to be up-to-date on the program object before this is called.
gl::Error Renderer9::applyTextures(const gl::Context *context, gl::SamplerType shaderType) gl::Error Renderer9::applyTextures(const gl::Context *context, gl::ShaderType shaderType)
{ {
const auto &glState = context->getGLState(); const auto &glState = context->getGLState();
const auto &caps = context->getCaps(); const auto &caps = context->getCaps();
...@@ -3288,8 +3289,8 @@ gl::Error Renderer9::applyTextures(const gl::Context *context, gl::SamplerType s ...@@ -3288,8 +3289,8 @@ gl::Error Renderer9::applyTextures(const gl::Context *context, gl::SamplerType s
} }
// Set all the remaining textures to NULL // Set all the remaining textures to NULL
size_t samplerCount = (shaderType == gl::SAMPLER_PIXEL) ? caps.maxTextureImageUnits size_t samplerCount = (shaderType == gl::SHADER_FRAGMENT) ? caps.maxTextureImageUnits
: caps.maxVertexTextureImageUnits; : caps.maxVertexTextureImageUnits;
// TODO(jmadill): faster way? // TODO(jmadill): faster way?
for (size_t samplerIndex = samplerRange; samplerIndex < samplerCount; samplerIndex++) for (size_t samplerIndex = samplerRange; samplerIndex < samplerCount; samplerIndex++)
...@@ -3302,8 +3303,8 @@ gl::Error Renderer9::applyTextures(const gl::Context *context, gl::SamplerType s ...@@ -3302,8 +3303,8 @@ gl::Error Renderer9::applyTextures(const gl::Context *context, gl::SamplerType s
gl::Error Renderer9::applyTextures(const gl::Context *context) gl::Error Renderer9::applyTextures(const gl::Context *context)
{ {
ANGLE_TRY(applyTextures(context, gl::SAMPLER_VERTEX)); ANGLE_TRY(applyTextures(context, gl::SHADER_VERTEX));
ANGLE_TRY(applyTextures(context, gl::SAMPLER_PIXEL)); ANGLE_TRY(applyTextures(context, gl::SHADER_FRAGMENT));
return gl::NoError(); return gl::NoError();
} }
......
...@@ -120,12 +120,12 @@ class Renderer9 : public RendererD3D ...@@ -120,12 +120,12 @@ class Renderer9 : public RendererD3D
D3DFORMAT Format, D3DFORMAT Format,
IDirect3DIndexBuffer9 **ppIndexBuffer); IDirect3DIndexBuffer9 **ppIndexBuffer);
gl::Error setSamplerState(const gl::Context *context, gl::Error setSamplerState(const gl::Context *context,
gl::SamplerType type, gl::ShaderType type,
int index, int index,
gl::Texture *texture, gl::Texture *texture,
const gl::SamplerState &sampler); const gl::SamplerState &sampler);
gl::Error setTexture(const gl::Context *context, gl::Error setTexture(const gl::Context *context,
gl::SamplerType type, gl::ShaderType type,
int index, int index,
gl::Texture *texture); gl::Texture *texture);
...@@ -404,7 +404,7 @@ class Renderer9 : public RendererD3D ...@@ -404,7 +404,7 @@ class Renderer9 : public RendererD3D
gl::Error applyShaders(const gl::Context *context, GLenum drawMode); gl::Error applyShaders(const gl::Context *context, GLenum drawMode);
gl::Error applyTextures(const gl::Context *context); gl::Error applyTextures(const gl::Context *context);
gl::Error applyTextures(const gl::Context *context, gl::SamplerType shaderType); gl::Error applyTextures(const gl::Context *context, gl::ShaderType shaderType);
void generateCaps(gl::Caps *outCaps, void generateCaps(gl::Caps *outCaps,
gl::TextureCapsMap *outTextureCaps, gl::TextureCapsMap *outTextureCaps,
......
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