• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright 2012 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 //
6 
7 // ShaderExecutable.cpp: Implements a class to contain D3D shader executable
8 // implementation details.
9 
10 #include "libANGLE/renderer/d3d/ShaderExecutableD3D.h"
11 
12 #include "common/angleutils.h"
13 
14 namespace rx
15 {
16 
ShaderExecutableD3D(const void * function,size_t length)17 ShaderExecutableD3D::ShaderExecutableD3D(const void *function, size_t length)
18     : mFunctionBuffer(length)
19 {
20     memcpy(mFunctionBuffer.data(), function, length);
21 }
22 
~ShaderExecutableD3D()23 ShaderExecutableD3D::~ShaderExecutableD3D() {}
24 
getFunction() const25 const uint8_t *ShaderExecutableD3D::getFunction() const
26 {
27     return mFunctionBuffer.data();
28 }
29 
getLength() const30 size_t ShaderExecutableD3D::getLength() const
31 {
32     return mFunctionBuffer.size();
33 }
34 
getDebugInfo() const35 const std::string &ShaderExecutableD3D::getDebugInfo() const
36 {
37     return mDebugInfo;
38 }
39 
appendDebugInfo(const std::string & info)40 void ShaderExecutableD3D::appendDebugInfo(const std::string &info)
41 {
42     mDebugInfo += info;
43 }
44 
UniformStorageD3D(size_t initialSize)45 UniformStorageD3D::UniformStorageD3D(size_t initialSize) : mUniformData()
46 {
47     bool result = mUniformData.resize(initialSize);
48     ASSERT(result);
49 
50     // Uniform data is zero-initialized by default.
51     mUniformData.fill(0);
52 }
53 
~UniformStorageD3D()54 UniformStorageD3D::~UniformStorageD3D() {}
55 
size() const56 size_t UniformStorageD3D::size() const
57 {
58     return mUniformData.size();
59 }
60 
getDataPointer(unsigned int registerIndex,unsigned int registerElement)61 uint8_t *UniformStorageD3D::getDataPointer(unsigned int registerIndex, unsigned int registerElement)
62 {
63     size_t offset = ((registerIndex * 4 + registerElement) * sizeof(float));
64     return mUniformData.data() + offset;
65 }
66 
67 }  // namespace rx
68