gfx/angle/src/libGLESv2/renderer/ShaderExecutable11.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/angle/src/libGLESv2/renderer/ShaderExecutable11.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,109 @@
     1.4 +#include "precompiled.h"
     1.5 +//
     1.6 +// Copyright (c) 2012-2013 The ANGLE Project Authors. All rights reserved.
     1.7 +// Use of this source code is governed by a BSD-style license that can be
     1.8 +// found in the LICENSE file.
     1.9 +//
    1.10 +
    1.11 +// ShaderExecutable11.cpp: Implements a D3D11-specific class to contain shader
    1.12 +// executable implementation details.
    1.13 +
    1.14 +#include "libGLESv2/renderer/ShaderExecutable11.h"
    1.15 +
    1.16 +#include "common/debug.h"
    1.17 +
    1.18 +namespace rx
    1.19 +{
    1.20 +
    1.21 +ShaderExecutable11::ShaderExecutable11(const void *function, size_t length, ID3D11PixelShader *executable)
    1.22 +    : ShaderExecutable(function, length)
    1.23 +{
    1.24 +    mPixelExecutable = executable;
    1.25 +    mVertexExecutable = NULL;
    1.26 +    mGeometryExecutable = NULL;
    1.27 +
    1.28 +    mConstantBuffer = NULL;
    1.29 +}
    1.30 +
    1.31 +ShaderExecutable11::ShaderExecutable11(const void *function, size_t length, ID3D11VertexShader *executable)
    1.32 +    : ShaderExecutable(function, length)
    1.33 +{
    1.34 +    mVertexExecutable = executable;
    1.35 +    mPixelExecutable = NULL;
    1.36 +    mGeometryExecutable = NULL;
    1.37 +
    1.38 +    mConstantBuffer = NULL;
    1.39 +}
    1.40 +
    1.41 +ShaderExecutable11::ShaderExecutable11(const void *function, size_t length, ID3D11GeometryShader *executable)
    1.42 +    : ShaderExecutable(function, length)
    1.43 +{
    1.44 +    mGeometryExecutable = executable;
    1.45 +    mVertexExecutable = NULL;
    1.46 +    mPixelExecutable = NULL;
    1.47 +
    1.48 +    mConstantBuffer = NULL;
    1.49 +}
    1.50 +
    1.51 +ShaderExecutable11::~ShaderExecutable11()
    1.52 +{
    1.53 +    if (mVertexExecutable)
    1.54 +    {
    1.55 +        mVertexExecutable->Release();
    1.56 +    }
    1.57 +    if (mPixelExecutable)
    1.58 +    {
    1.59 +        mPixelExecutable->Release();
    1.60 +    }
    1.61 +    if (mGeometryExecutable)
    1.62 +    {
    1.63 +        mGeometryExecutable->Release();
    1.64 +    }
    1.65 +    
    1.66 +    if (mConstantBuffer)
    1.67 +    {
    1.68 +        mConstantBuffer->Release();
    1.69 +    }
    1.70 +}
    1.71 +
    1.72 +ShaderExecutable11 *ShaderExecutable11::makeShaderExecutable11(ShaderExecutable *executable)
    1.73 +{
    1.74 +    ASSERT(HAS_DYNAMIC_TYPE(ShaderExecutable11*, executable));
    1.75 +    return static_cast<ShaderExecutable11*>(executable);
    1.76 +}
    1.77 +
    1.78 +ID3D11VertexShader *ShaderExecutable11::getVertexShader() const
    1.79 +{
    1.80 +    return mVertexExecutable;
    1.81 +}
    1.82 +
    1.83 +ID3D11PixelShader *ShaderExecutable11::getPixelShader() const
    1.84 +{
    1.85 +    return mPixelExecutable;
    1.86 +}
    1.87 +
    1.88 +ID3D11GeometryShader *ShaderExecutable11::getGeometryShader() const
    1.89 +{
    1.90 +    return mGeometryExecutable;
    1.91 +}
    1.92 +
    1.93 +ID3D11Buffer *ShaderExecutable11::getConstantBuffer(ID3D11Device *device, unsigned int registerCount)
    1.94 +{
    1.95 +    if (!mConstantBuffer && registerCount > 0)
    1.96 +    {
    1.97 +        D3D11_BUFFER_DESC constantBufferDescription = {0};
    1.98 +        constantBufferDescription.ByteWidth = registerCount * sizeof(float[4]);
    1.99 +        constantBufferDescription.Usage = D3D11_USAGE_DYNAMIC;
   1.100 +        constantBufferDescription.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
   1.101 +        constantBufferDescription.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
   1.102 +        constantBufferDescription.MiscFlags = 0;
   1.103 +        constantBufferDescription.StructureByteStride = 0;
   1.104 +
   1.105 +        HRESULT result = device->CreateBuffer(&constantBufferDescription, NULL, &mConstantBuffer);
   1.106 +        ASSERT(SUCCEEDED(result));
   1.107 +    }
   1.108 +
   1.109 +    return mConstantBuffer;
   1.110 +}
   1.111 +
   1.112 +}
   1.113 \ No newline at end of file

mercurial