diff options
author | Jamie Madill <jmadill@chromium.org> | 2014-09-03 09:40:45 -0400 |
---|---|---|
committer | Jamie Madill <jmadill@chromium.org> | 2014-09-03 15:52:05 +0000 |
commit | 2ad1dc48ed14cb53f7de6d9dea34d88851e1bb2e (patch) | |
tree | 190978087434850f0e180c0de1406dc3237d8964 /src/libGLESv2/renderer/d3d/ShaderD3D.cpp | |
parent | d15250e62703537195df41ea6c2412d92aee120a (diff) | |
download | angle-2ad1dc48ed14cb53f7de6d9dea34d88851e1bb2e.tar.gz |
Compact the D3D shader specializations into one.
BUG=angle:731
Change-Id: I4f35a05aeea130f9011ec62cfe931ed23e2681c9
Reviewed-on: https://chromium-review.googlesource.com/214871
Tested-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Diffstat (limited to 'src/libGLESv2/renderer/d3d/ShaderD3D.cpp')
-rw-r--r-- | src/libGLESv2/renderer/d3d/ShaderD3D.cpp | 107 |
1 files changed, 40 insertions, 67 deletions
diff --git a/src/libGLESv2/renderer/d3d/ShaderD3D.cpp b/src/libGLESv2/renderer/d3d/ShaderD3D.cpp index f26df10e..a6d5266a 100644 --- a/src/libGLESv2/renderer/d3d/ShaderD3D.cpp +++ b/src/libGLESv2/renderer/d3d/ShaderD3D.cpp @@ -27,8 +27,8 @@ const std::vector<VarT> *GetShaderVariables(const std::vector<VarT> *variableLis return variableList; } -ShaderD3D::ShaderD3D(rx::Renderer *renderer) - : ShaderImpl(), +ShaderD3D::ShaderD3D(GLenum type, rx::Renderer *renderer) + : mType(type), mRenderer(renderer), mShaderVersion(100) { @@ -340,15 +340,28 @@ unsigned int ShaderD3D::getInterfaceBlockRegister(const std::string &blockName) return mInterfaceBlockRegisterMap.find(blockName)->second; } +void *ShaderD3D::getCompiler() +{ + if (mType == GL_VERTEX_SHADER) + { + return mVertexCompiler; + } + else + { + ASSERT(mType == GL_FRAGMENT_SHADER); + return mFragmentCompiler; + } +} + ShShaderOutput ShaderD3D::getCompilerOutputType(GLenum shader) { void *compiler = NULL; switch (shader) { - case GL_VERTEX_SHADER: compiler = mVertexCompiler; break; - case GL_FRAGMENT_SHADER: compiler = mFragmentCompiler; break; - default: UNREACHABLE(); return SH_HLSL9_OUTPUT; + case GL_VERTEX_SHADER: compiler = mVertexCompiler; break; + case GL_FRAGMENT_SHADER: compiler = mFragmentCompiler; break; + default: UNREACHABLE(); return SH_HLSL9_OUTPUT; } size_t outputType = 0; @@ -357,47 +370,45 @@ ShShaderOutput ShaderD3D::getCompilerOutputType(GLenum shader) return static_cast<ShShaderOutput>(outputType); } -VertexShaderD3D::VertexShaderD3D(rx::Renderer *renderer) : ShaderD3D(renderer) +bool ShaderD3D::compile(const std::string &source) { -} + uncompile(); -VertexShaderD3D::~VertexShaderD3D() -{ -} + void *compiler = getCompiler(); -VertexShaderD3D *VertexShaderD3D::makeVertexShaderD3D(ShaderImpl *impl) -{ - ASSERT(HAS_DYNAMIC_TYPE(VertexShaderD3D*, impl)); - return static_cast<VertexShaderD3D*>(impl); -} + compileToHLSL(compiler, source); -const VertexShaderD3D *VertexShaderD3D::makeVertexShaderD3D(const ShaderImpl *impl) -{ - ASSERT(HAS_DYNAMIC_TYPE(const VertexShaderD3D*, impl)); - return static_cast<const VertexShaderD3D*>(impl); -} + if (mType == GL_VERTEX_SHADER) + { + parseAttributes(compiler); + } -bool VertexShaderD3D::compile(const std::string &source) -{ - uncompile(); + parseVaryings(compiler); + + if (mType == GL_FRAGMENT_SHADER) + { + std::sort(mVaryings.begin(), mVaryings.end(), compareVarying); - compileToHLSL(mVertexCompiler, source); - parseAttributes(); - parseVaryings(mVertexCompiler); + const std::string &hlsl = getTranslatedSource(); + if (!hlsl.empty()) + { + mActiveOutputVariables = *GetShaderVariables(ShGetOutputVariables(compiler)); + } + } return !getTranslatedSource().empty(); } -void VertexShaderD3D::parseAttributes() +void ShaderD3D::parseAttributes(void *compiler) { const std::string &hlsl = getTranslatedSource(); if (!hlsl.empty()) { - mActiveAttributes = *GetShaderVariables(ShGetAttributes(mVertexCompiler)); + mActiveAttributes = *GetShaderVariables(ShGetAttributes(compiler)); } } -int VertexShaderD3D::getSemanticIndex(const std::string &attributeName) const +int ShaderD3D::getSemanticIndex(const std::string &attributeName) const { if (!attributeName.empty()) { @@ -418,42 +429,4 @@ int VertexShaderD3D::getSemanticIndex(const std::string &attributeName) const return -1; } -FragmentShaderD3D::FragmentShaderD3D(rx::Renderer *renderer) : ShaderD3D(renderer) -{ -} - -FragmentShaderD3D::~FragmentShaderD3D() -{ -} - -FragmentShaderD3D *FragmentShaderD3D::makeFragmentShaderD3D(ShaderImpl *impl) -{ - ASSERT(HAS_DYNAMIC_TYPE(FragmentShaderD3D*, impl)); - return static_cast<FragmentShaderD3D*>(impl); -} - -const FragmentShaderD3D *FragmentShaderD3D::makeFragmentShaderD3D(const ShaderImpl *impl) -{ - ASSERT(HAS_DYNAMIC_TYPE(const FragmentShaderD3D*, impl)); - return static_cast<const FragmentShaderD3D*>(impl); -} - -bool FragmentShaderD3D::compile(const std::string &source) -{ - uncompile(); - - compileToHLSL(mFragmentCompiler, source); - parseVaryings(mFragmentCompiler); - - std::sort(mVaryings.begin(), mVaryings.end(), compareVarying); - - const std::string &hlsl = getTranslatedSource(); - if (!hlsl.empty()) - { - mActiveOutputVariables = *GetShaderVariables(ShGetOutputVariables(mFragmentCompiler)); - return true; - } - return false; -} - } |