Commit 81970bc3 by Jiawei Shao Committed by Commit Bot

Use ShaderMap in DynamicHLSL and StateManager11 - Part I

This patch is the first one of using ShaderMap in both DynamicHLSL and StateManager11 to make the code cleaner and more straightforward. BUG=angleproject:2169 Change-Id: I2b206d0250f5ced071cc1c3632367b16e5e02dfb Reviewed-on: https://chromium-review.googlesource.com/1089473Reviewed-by: 's avatarJiajia Qin <jiajia.qin@intel.com> Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
parent e1a057e8
...@@ -1349,7 +1349,7 @@ void BuiltinVaryingsD3D::updateBuiltins(gl::ShaderType shaderType, ...@@ -1349,7 +1349,7 @@ void BuiltinVaryingsD3D::updateBuiltins(gl::ShaderType shaderType,
unsigned int reservedSemanticIndex = packing.getMaxSemanticIndex(); unsigned int reservedSemanticIndex = packing.getMaxSemanticIndex();
BuiltinInfo *builtins = &mBuiltinInfo[static_cast<size_t>(shaderType)]; BuiltinInfo *builtins = &mBuiltinInfo[shaderType];
if (metadata.getRendererMajorShaderModel() >= 4) if (metadata.getRendererMajorShaderModel() >= 4)
{ {
......
...@@ -98,26 +98,20 @@ class BuiltinVaryingsD3D ...@@ -98,26 +98,20 @@ class BuiltinVaryingsD3D
BuiltinVaryingsD3D(const ProgramD3DMetadata &metadata, const gl::VaryingPacking &packing); BuiltinVaryingsD3D(const ProgramD3DMetadata &metadata, const gl::VaryingPacking &packing);
~BuiltinVaryingsD3D(); ~BuiltinVaryingsD3D();
bool usesPointSize() const bool usesPointSize() const { return mBuiltinInfo[gl::ShaderType::Vertex].glPointSize.enabled; }
{
return mBuiltinInfo[static_cast<size_t>(gl::ShaderType::Vertex)].glPointSize.enabled;
}
const BuiltinInfo &operator[](gl::ShaderType shaderType) const const BuiltinInfo &operator[](gl::ShaderType shaderType) const
{ {
return mBuiltinInfo[static_cast<size_t>(shaderType)]; return mBuiltinInfo[shaderType];
}
BuiltinInfo &operator[](gl::ShaderType shaderType)
{
return mBuiltinInfo[static_cast<size_t>(shaderType)];
} }
BuiltinInfo &operator[](gl::ShaderType shaderType) { return mBuiltinInfo[shaderType]; }
private: private:
void updateBuiltins(gl::ShaderType shaderType, void updateBuiltins(gl::ShaderType shaderType,
const ProgramD3DMetadata &metadata, const ProgramD3DMetadata &metadata,
const gl::VaryingPacking &packing); const gl::VaryingPacking &packing);
std::array<BuiltinInfo, static_cast<size_t>(gl::ShaderType::EnumCount)> mBuiltinInfo; gl::ShaderMap<BuiltinInfo> mBuiltinInfo;
}; };
class DynamicHLSL : angle::NonCopyable class DynamicHLSL : angle::NonCopyable
......
...@@ -124,6 +124,8 @@ class ShaderConstants11 : angle::NonCopyable ...@@ -124,6 +124,8 @@ class ShaderConstants11 : angle::NonCopyable
static_assert(sizeof(SamplerMetadata) == 16u, static_assert(sizeof(SamplerMetadata) == 16u,
"Sampler metadata struct must be one 4-vec / 16 bytes."); "Sampler metadata struct must be one 4-vec / 16 bytes.");
static size_t GetShaderConstantsStructSize(gl::ShaderType shaderType);
// Return true if dirty. // Return true if dirty.
bool updateSamplerMetadata(SamplerMetadata *data, const gl::Texture &texture); bool updateSamplerMetadata(SamplerMetadata *data, const gl::Texture &texture);
...@@ -132,12 +134,8 @@ class ShaderConstants11 : angle::NonCopyable ...@@ -132,12 +134,8 @@ class ShaderConstants11 : angle::NonCopyable
Compute mCompute; Compute mCompute;
gl::ShaderBitSet mShaderConstantsDirty; gl::ShaderBitSet mShaderConstantsDirty;
std::vector<SamplerMetadata> mSamplerMetadataVS; gl::ShaderMap<std::vector<SamplerMetadata>> mShaderSamplerMetadata;
int mNumActiveVSSamplers; gl::ShaderMap<int> mNumActiveShaderSamplers;
std::vector<SamplerMetadata> mSamplerMetadataPS;
int mNumActivePSSamplers;
std::vector<SamplerMetadata> mSamplerMetadataCS;
int mNumActiveCSSamplers;
}; };
class StateManager11 final : angle::NonCopyable class StateManager11 final : angle::NonCopyable
...@@ -461,9 +459,7 @@ class StateManager11 final : angle::NonCopyable ...@@ -461,9 +459,7 @@ class StateManager11 final : angle::NonCopyable
using SRVCache = ViewCache<ID3D11ShaderResourceView, D3D11_SHADER_RESOURCE_VIEW_DESC>; using SRVCache = ViewCache<ID3D11ShaderResourceView, D3D11_SHADER_RESOURCE_VIEW_DESC>;
using UAVCache = ViewCache<ID3D11UnorderedAccessView, D3D11_UNORDERED_ACCESS_VIEW_DESC>; using UAVCache = ViewCache<ID3D11UnorderedAccessView, D3D11_UNORDERED_ACCESS_VIEW_DESC>;
SRVCache mCurVertexSRVs; gl::ShaderMap<SRVCache> mCurShaderSRVs;
SRVCache mCurPixelSRVs;
SRVCache mCurComputeSRVs;
UAVCache mCurComputeUAVs; UAVCache mCurComputeUAVs;
SRVCache *getSRVCache(gl::ShaderType shaderType); SRVCache *getSRVCache(gl::ShaderType shaderType);
...@@ -491,20 +487,11 @@ class StateManager11 final : angle::NonCopyable ...@@ -491,20 +487,11 @@ class StateManager11 final : angle::NonCopyable
GLsizei mCurrentMinimumDrawCount; GLsizei mCurrentMinimumDrawCount;
// Currently applied shaders // Currently applied shaders
ResourceSerial mAppliedVertexShader; gl::ShaderMap<ResourceSerial> mAppliedShaders;
ResourceSerial mAppliedGeometryShader;
ResourceSerial mAppliedPixelShader;
ResourceSerial mAppliedComputeShader;
// Currently applied sampler states // Currently applied sampler states
std::vector<bool> mForceSetVertexSamplerStates; gl::ShaderMap<std::vector<bool>> mForceSetShaderSamplerStates;
std::vector<gl::SamplerState> mCurVertexSamplerStates; gl::ShaderMap<std::vector<gl::SamplerState>> mCurShaderSamplerStates;
std::vector<bool> mForceSetPixelSamplerStates;
std::vector<gl::SamplerState> mCurPixelSamplerStates;
std::vector<bool> mForceSetComputeSamplerStates;
std::vector<gl::SamplerState> mCurComputeSamplerStates;
// Special dirty bit for swizzles. Since they use internal shaders, must be done in a pre-pass. // Special dirty bit for swizzles. Since they use internal shaders, must be done in a pre-pass.
bool mDirtySwizzles; bool mDirtySwizzles;
......
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