blob: e81a652bdfcf596701113ef1a0819ef830b1ac7e [file] [log] [blame]
daniel@transgaming.comd5d10192012-11-28 20:57:55 +00001//
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
14namespace rx
15{
16
17ShaderExecutable9::ShaderExecutable9(IDirect3DPixelShader9 *executable, gl::D3DConstantTable *constantTable)
18{
19 mPixelExecutable = executable;
20 mVertexExecutable = NULL;
21 mConstantTable = constantTable;
22}
23
24ShaderExecutable9::ShaderExecutable9(IDirect3DVertexShader9 *executable, gl::D3DConstantTable *constantTable)
25{
26 mVertexExecutable = executable;
27 mPixelExecutable = NULL;
28 mConstantTable = constantTable;
29}
30
31ShaderExecutable9::~ShaderExecutable9()
32{
33 if (mVertexExecutable)
34 {
35 mVertexExecutable->Release();
36 }
37 if (mPixelExecutable)
38 {
39 mPixelExecutable->Release();
40 }
41
42 delete mConstantTable;
43}
44
45ShaderExecutable9 *ShaderExecutable9::makeShaderExecutable9(ShaderExecutable *executable)
46{
47 ASSERT(dynamic_cast<ShaderExecutable9*>(executable) != NULL);
48 return static_cast<ShaderExecutable9*>(executable);
49}
50
daniel@transgaming.comc0ccbd82012-11-28 20:59:37 +000051bool 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
61bool 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.comd5d10192012-11-28 20:57:55 +000071IDirect3DVertexShader9 *ShaderExecutable9::getVertexShader()
72{
daniel@transgaming.comd5d10192012-11-28 20:57:55 +000073 return mVertexExecutable;
74}
75
76IDirect3DPixelShader9 *ShaderExecutable9::getPixelShader()
77{
daniel@transgaming.comd5d10192012-11-28 20:57:55 +000078 return mPixelExecutable;
79}
80
81gl::D3DConstantTable *ShaderExecutable9::getConstantTable()
82{
83 return mConstantTable;
84}
85
86}