daniel@transgaming.com | d5d1019 | 2012-11-28 20:57:55 +0000 | [diff] [blame] | 1 | // |
| 2 | // Copyright (c) 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 | // ShaderExecutable9.cpp: Implements a D3D9-specific class to contain shader |
| 8 | // executable implementation details. |
| 9 | |
| 10 | #include "libGLESv2/renderer/ShaderExecutable9.h" |
| 11 | |
| 12 | #include "common/debug.h" |
| 13 | |
| 14 | namespace rx |
| 15 | { |
| 16 | |
| 17 | ShaderExecutable9::ShaderExecutable9(IDirect3DPixelShader9 *executable, gl::D3DConstantTable *constantTable) |
| 18 | { |
| 19 | mPixelExecutable = executable; |
| 20 | mVertexExecutable = NULL; |
| 21 | mConstantTable = constantTable; |
| 22 | } |
| 23 | |
| 24 | ShaderExecutable9::ShaderExecutable9(IDirect3DVertexShader9 *executable, gl::D3DConstantTable *constantTable) |
| 25 | { |
| 26 | mVertexExecutable = executable; |
| 27 | mPixelExecutable = NULL; |
| 28 | mConstantTable = constantTable; |
| 29 | } |
| 30 | |
| 31 | ShaderExecutable9::~ShaderExecutable9() |
| 32 | { |
| 33 | if (mVertexExecutable) |
| 34 | { |
| 35 | mVertexExecutable->Release(); |
| 36 | } |
| 37 | if (mPixelExecutable) |
| 38 | { |
| 39 | mPixelExecutable->Release(); |
| 40 | } |
| 41 | |
| 42 | delete mConstantTable; |
| 43 | } |
| 44 | |
| 45 | ShaderExecutable9 *ShaderExecutable9::makeShaderExecutable9(ShaderExecutable *executable) |
| 46 | { |
| 47 | ASSERT(dynamic_cast<ShaderExecutable9*>(executable) != NULL); |
| 48 | return static_cast<ShaderExecutable9*>(executable); |
| 49 | } |
| 50 | |
daniel@transgaming.com | c0ccbd8 | 2012-11-28 20:59:37 +0000 | [diff] [blame^] | 51 | bool ShaderExecutable9::getVertexFunction(void *pData, UINT *pSizeOfData) |
| 52 | { |
| 53 | HRESULT hr = D3DERR_INVALIDCALL; |
| 54 | if (mVertexExecutable) |
| 55 | { |
| 56 | hr = mVertexExecutable->GetFunction(pData, pSizeOfData); |
| 57 | } |
| 58 | return SUCCEEDED(hr); |
| 59 | } |
| 60 | |
| 61 | bool ShaderExecutable9::getPixelFunction(void *pData, UINT *pSizeOfData) |
| 62 | { |
| 63 | HRESULT hr = D3DERR_INVALIDCALL; |
| 64 | if (mPixelExecutable) |
| 65 | { |
| 66 | hr = mPixelExecutable->GetFunction(pData, pSizeOfData); |
| 67 | } |
| 68 | return SUCCEEDED(hr); |
| 69 | } |
| 70 | |
daniel@transgaming.com | d5d1019 | 2012-11-28 20:57:55 +0000 | [diff] [blame] | 71 | IDirect3DVertexShader9 *ShaderExecutable9::getVertexShader() |
| 72 | { |
daniel@transgaming.com | d5d1019 | 2012-11-28 20:57:55 +0000 | [diff] [blame] | 73 | return mVertexExecutable; |
| 74 | } |
| 75 | |
| 76 | IDirect3DPixelShader9 *ShaderExecutable9::getPixelShader() |
| 77 | { |
daniel@transgaming.com | d5d1019 | 2012-11-28 20:57:55 +0000 | [diff] [blame] | 78 | return mPixelExecutable; |
| 79 | } |
| 80 | |
| 81 | gl::D3DConstantTable *ShaderExecutable9::getConstantTable() |
| 82 | { |
| 83 | return mConstantTable; |
| 84 | } |
| 85 | |
| 86 | } |