1 #include "precompiled.h"
3 // Copyright (c) 2012-2014 The ANGLE Project Authors. All rights reserved.
4 // Use of this source code is governed by a BSD-style license that can be
5 // found in the LICENSE file.
8 // ShaderExecutable11.cpp: Implements a D3D11-specific class to contain shader
9 // executable implementation details.
11 #include "libGLESv2/renderer/d3d/d3d11/ShaderExecutable11.h"
13 #include "libGLESv2/renderer/d3d/d3d11/Renderer11.h"
18 ShaderExecutable11::ShaderExecutable11(const void *function, size_t length, ID3D11PixelShader *executable)
19 : ShaderExecutable(function, length)
21 mPixelExecutable = executable;
22 mVertexExecutable = NULL;
23 mGeometryExecutable = NULL;
24 mStreamOutExecutable = NULL;
27 ShaderExecutable11::ShaderExecutable11(const void *function, size_t length, ID3D11VertexShader *executable, ID3D11GeometryShader *streamOut)
28 : ShaderExecutable(function, length)
30 mVertexExecutable = executable;
31 mPixelExecutable = NULL;
32 mGeometryExecutable = NULL;
33 mStreamOutExecutable = streamOut;
36 ShaderExecutable11::ShaderExecutable11(const void *function, size_t length, ID3D11GeometryShader *executable)
37 : ShaderExecutable(function, length)
39 mGeometryExecutable = executable;
40 mVertexExecutable = NULL;
41 mPixelExecutable = NULL;
42 mStreamOutExecutable = NULL;
45 ShaderExecutable11::~ShaderExecutable11()
47 SafeRelease(mVertexExecutable);
48 SafeRelease(mPixelExecutable);
49 SafeRelease(mGeometryExecutable);
50 SafeRelease(mStreamOutExecutable);
53 ShaderExecutable11 *ShaderExecutable11::makeShaderExecutable11(ShaderExecutable *executable)
55 ASSERT(HAS_DYNAMIC_TYPE(ShaderExecutable11*, executable));
56 return static_cast<ShaderExecutable11*>(executable);
59 ID3D11VertexShader *ShaderExecutable11::getVertexShader() const
61 return mVertexExecutable;
64 ID3D11PixelShader *ShaderExecutable11::getPixelShader() const
66 return mPixelExecutable;
69 ID3D11GeometryShader *ShaderExecutable11::getGeometryShader() const
71 return mGeometryExecutable;
74 ID3D11GeometryShader *ShaderExecutable11::getStreamOutShader() const
76 return mStreamOutExecutable;
79 UniformStorage11::UniformStorage11(Renderer11 *renderer, size_t initialSize)
80 : UniformStorage(initialSize),
83 ID3D11Device *d3d11Device = renderer->getDevice();
87 D3D11_BUFFER_DESC constantBufferDescription = {0};
88 constantBufferDescription.ByteWidth = initialSize;
89 constantBufferDescription.Usage = D3D11_USAGE_DYNAMIC;
90 constantBufferDescription.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
91 constantBufferDescription.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
92 constantBufferDescription.MiscFlags = 0;
93 constantBufferDescription.StructureByteStride = 0;
95 HRESULT result = d3d11Device->CreateBuffer(&constantBufferDescription, NULL, &mConstantBuffer);
96 UNUSED_ASSERTION_VARIABLE(result);
97 ASSERT(SUCCEEDED(result));
101 UniformStorage11::~UniformStorage11()
103 SafeRelease(mConstantBuffer);
106 const UniformStorage11 *UniformStorage11::makeUniformStorage11(const UniformStorage *uniformStorage)
108 ASSERT(HAS_DYNAMIC_TYPE(const UniformStorage11*, uniformStorage));
109 return static_cast<const UniformStorage11*>(uniformStorage);