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,
unsigned int reservedSemanticIndex = packing.getMaxSemanticIndex();
BuiltinInfo *builtins = &mBuiltinInfo[static_cast<size_t>(shaderType)];
BuiltinInfo *builtins = &mBuiltinInfo[shaderType];
if (metadata.getRendererMajorShaderModel() >= 4)
{
......
......@@ -98,26 +98,20 @@ class BuiltinVaryingsD3D
BuiltinVaryingsD3D(const ProgramD3DMetadata &metadata, const gl::VaryingPacking &packing);
~BuiltinVaryingsD3D();
bool usesPointSize() const
{
return mBuiltinInfo[static_cast<size_t>(gl::ShaderType::Vertex)].glPointSize.enabled;
}
bool usesPointSize() const { return mBuiltinInfo[gl::ShaderType::Vertex].glPointSize.enabled; }
const BuiltinInfo &operator[](gl::ShaderType shaderType) const
{
return mBuiltinInfo[static_cast<size_t>(shaderType)];
}
BuiltinInfo &operator[](gl::ShaderType shaderType)
{
return mBuiltinInfo[static_cast<size_t>(shaderType)];
return mBuiltinInfo[shaderType];
}
BuiltinInfo &operator[](gl::ShaderType shaderType) { return mBuiltinInfo[shaderType]; }
private:
void updateBuiltins(gl::ShaderType shaderType,
const ProgramD3DMetadata &metadata,
const gl::VaryingPacking &packing);
std::array<BuiltinInfo, static_cast<size_t>(gl::ShaderType::EnumCount)> mBuiltinInfo;
gl::ShaderMap<BuiltinInfo> mBuiltinInfo;
};
class DynamicHLSL : angle::NonCopyable
......
......@@ -124,6 +124,8 @@ class ShaderConstants11 : angle::NonCopyable
static_assert(sizeof(SamplerMetadata) == 16u,
"Sampler metadata struct must be one 4-vec / 16 bytes.");
static size_t GetShaderConstantsStructSize(gl::ShaderType shaderType);
// Return true if dirty.
bool updateSamplerMetadata(SamplerMetadata *data, const gl::Texture &texture);
......@@ -132,12 +134,8 @@ class ShaderConstants11 : angle::NonCopyable
Compute mCompute;
gl::ShaderBitSet mShaderConstantsDirty;
std::vector<SamplerMetadata> mSamplerMetadataVS;
int mNumActiveVSSamplers;
std::vector<SamplerMetadata> mSamplerMetadataPS;
int mNumActivePSSamplers;
std::vector<SamplerMetadata> mSamplerMetadataCS;
int mNumActiveCSSamplers;
gl::ShaderMap<std::vector<SamplerMetadata>> mShaderSamplerMetadata;
gl::ShaderMap<int> mNumActiveShaderSamplers;
};
class StateManager11 final : angle::NonCopyable
......@@ -461,9 +459,7 @@ class StateManager11 final : angle::NonCopyable
using SRVCache = ViewCache<ID3D11ShaderResourceView, D3D11_SHADER_RESOURCE_VIEW_DESC>;
using UAVCache = ViewCache<ID3D11UnorderedAccessView, D3D11_UNORDERED_ACCESS_VIEW_DESC>;
SRVCache mCurVertexSRVs;
SRVCache mCurPixelSRVs;
SRVCache mCurComputeSRVs;
gl::ShaderMap<SRVCache> mCurShaderSRVs;
UAVCache mCurComputeUAVs;
SRVCache *getSRVCache(gl::ShaderType shaderType);
......@@ -491,20 +487,11 @@ class StateManager11 final : angle::NonCopyable
GLsizei mCurrentMinimumDrawCount;
// Currently applied shaders
ResourceSerial mAppliedVertexShader;
ResourceSerial mAppliedGeometryShader;
ResourceSerial mAppliedPixelShader;
ResourceSerial mAppliedComputeShader;
gl::ShaderMap<ResourceSerial> mAppliedShaders;
// Currently applied sampler states
std::vector<bool> mForceSetVertexSamplerStates;
std::vector<gl::SamplerState> mCurVertexSamplerStates;
std::vector<bool> mForceSetPixelSamplerStates;
std::vector<gl::SamplerState> mCurPixelSamplerStates;
std::vector<bool> mForceSetComputeSamplerStates;
std::vector<gl::SamplerState> mCurComputeSamplerStates;
gl::ShaderMap<std::vector<bool>> mForceSetShaderSamplerStates;
gl::ShaderMap<std::vector<gl::SamplerState>> mCurShaderSamplerStates;
// Special dirty bit for swizzles. Since they use internal shaders, must be done in a pre-pass.
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