1 // Copyright 2016 The SwiftShader Authors. All Rights Reserved. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 #include "Direct3DVertexShader8.hpp" 16 17 #include "Debug.hpp" 18 19 namespace D3D8 20 { Direct3DVertexShader8(Direct3DDevice8 * device,const unsigned long * declaration,const unsigned long * shaderToken)21 Direct3DVertexShader8::Direct3DVertexShader8(Direct3DDevice8 *device, const unsigned long *declaration, const unsigned long *shaderToken) : device(device) 22 { 23 if(shaderToken) 24 { 25 vertexShader = new sw::VertexShader(shaderToken); 26 27 const unsigned long *token = shaderToken; 28 size = 0; 29 30 while(shaderToken[size] != 0x0000FFFF) 31 { 32 size++; 33 } 34 35 size++; 36 37 this->shaderToken = new unsigned long[size]; 38 memcpy(this->shaderToken, shaderToken, size * sizeof(unsigned long)); 39 } 40 else 41 { 42 vertexShader = 0; 43 this->shaderToken = 0; 44 } 45 46 this->declaration = new Direct3DVertexDeclaration8(device, declaration); 47 } 48 ~Direct3DVertexShader8()49 Direct3DVertexShader8::~Direct3DVertexShader8() 50 { 51 delete vertexShader; 52 vertexShader = 0; 53 54 delete[] shaderToken; 55 shaderToken = 0; 56 57 declaration->Release(); 58 } 59 QueryInterface(const IID & iid,void ** object)60 long Direct3DVertexShader8::QueryInterface(const IID &iid, void **object) 61 { 62 TRACE(""); 63 64 ASSERT(false); // Internal object 65 66 return NOINTERFACE(iid); 67 } 68 AddRef()69 unsigned long Direct3DVertexShader8::AddRef() 70 { 71 TRACE(""); 72 73 return Unknown::AddRef(); 74 } 75 Release()76 unsigned long Direct3DVertexShader8::Release() 77 { 78 TRACE(""); 79 80 return Unknown::Release(); 81 } 82 getVertexShader() const83 const sw::VertexShader *Direct3DVertexShader8::getVertexShader() const 84 { 85 return vertexShader; 86 } 87 getDeclaration()88 const unsigned long *Direct3DVertexShader8::getDeclaration() 89 { 90 return declaration->getDeclaration(); 91 } 92 }