Hash :
0fd806f1
Author :
Date :
2017-06-01T17:11:40
D3D11: Consolidate Shader allocation. Similar to the InputLayout init, this adds a small helper type to act as a wrapper around shader init data (binary and size). This also adds error trapping to the blit shader compilation. It also removes the LazyResource2 class, and the CompileXS helper methods. BUG=angleproject:2034 Change-Id: I3fd718393c8a0250e4263890f00d0e9147ec9567 Reviewed-on: https://chromium-review.googlesource.com/506776 Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
//
// Copyright (c) 2012-2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// ShaderExecutable11.cpp: Implements a D3D11-specific class to contain shader
// executable implementation details.
#include "libANGLE/renderer/d3d/d3d11/ShaderExecutable11.h"
#include "libANGLE/renderer/d3d/d3d11/Renderer11.h"
namespace rx
{
ShaderExecutable11::ShaderExecutable11(const void *function,
size_t length,
d3d11::PixelShader &&executable)
: ShaderExecutableD3D(function, length),
mPixelExecutable(std::move(executable)),
mVertexExecutable(),
mGeometryExecutable(),
mStreamOutExecutable(),
mComputeExecutable()
{
}
ShaderExecutable11::ShaderExecutable11(const void *function,
size_t length,
d3d11::VertexShader &&executable,
d3d11::GeometryShader &&streamOut)
: ShaderExecutableD3D(function, length),
mPixelExecutable(),
mVertexExecutable(std::move(executable)),
mGeometryExecutable(),
mStreamOutExecutable(std::move(streamOut)),
mComputeExecutable()
{
}
ShaderExecutable11::ShaderExecutable11(const void *function,
size_t length,
d3d11::GeometryShader &&executable)
: ShaderExecutableD3D(function, length),
mPixelExecutable(),
mVertexExecutable(),
mGeometryExecutable(std::move(executable)),
mStreamOutExecutable(),
mComputeExecutable()
{
}
ShaderExecutable11::ShaderExecutable11(const void *function,
size_t length,
d3d11::ComputeShader &&executable)
: ShaderExecutableD3D(function, length),
mPixelExecutable(),
mVertexExecutable(),
mGeometryExecutable(),
mStreamOutExecutable(),
mComputeExecutable(std::move(executable))
{
}
ShaderExecutable11::~ShaderExecutable11()
{
}
ID3D11VertexShader *ShaderExecutable11::getVertexShader() const
{
return mVertexExecutable.get();
}
ID3D11PixelShader *ShaderExecutable11::getPixelShader() const
{
return mPixelExecutable.get();
}
ID3D11GeometryShader *ShaderExecutable11::getGeometryShader() const
{
return mGeometryExecutable.get();
}
ID3D11GeometryShader *ShaderExecutable11::getStreamOutShader() const
{
return mStreamOutExecutable.get();
}
ID3D11ComputeShader *ShaderExecutable11::getComputeShader() const
{
return mComputeExecutable.get();
}
UniformStorage11::UniformStorage11(size_t initialSize)
: UniformStorageD3D(initialSize), mConstantBuffer()
{
}
UniformStorage11::~UniformStorage11()
{
}
gl::Error UniformStorage11::getConstantBuffer(Renderer11 *renderer, const d3d11::Buffer **bufferOut)
{
if (size() > 0 && !mConstantBuffer.valid())
{
D3D11_BUFFER_DESC constantBufferDescription = {0};
constantBufferDescription.ByteWidth = static_cast<unsigned int>(size());
constantBufferDescription.Usage = D3D11_USAGE_DYNAMIC;
constantBufferDescription.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
constantBufferDescription.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
constantBufferDescription.MiscFlags = 0;
constantBufferDescription.StructureByteStride = 0;
ANGLE_TRY(renderer->allocateResource(constantBufferDescription, &mConstantBuffer));
}
*bufferOut = &mConstantBuffer;
return gl::NoError();
}
} // namespace rx