• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "Direct3DPixelShader8.hpp"
16 
17 #include "Debug.hpp"
18 
19 namespace D3D8
20 {
Direct3DPixelShader8(Direct3DDevice8 * device,const unsigned long * shaderToken)21 	Direct3DPixelShader8::Direct3DPixelShader8(Direct3DDevice8 *device, const unsigned long *shaderToken) : device(device), pixelShader(shaderToken)
22 	{
23 		const unsigned long *token = shaderToken;
24 
25 		size = 0;
26 
27 		while(shaderToken[size] != 0x0000FFFF)
28 		{
29 			size++;
30 		}
31 
32 		size++;
33 
34 		this->shaderToken = new unsigned long[size];
35 		memcpy(this->shaderToken, shaderToken, size * sizeof(unsigned long));
36 	}
37 
~Direct3DPixelShader8()38 	Direct3DPixelShader8::~Direct3DPixelShader8()
39 	{
40 		delete[] shaderToken;
41 		shaderToken = 0;
42 	}
43 
QueryInterface(const IID & iid,void ** object)44 	long Direct3DPixelShader8::QueryInterface(const IID &iid, void **object)
45 	{
46 		TRACE("");
47 
48 		ASSERT(false);   // Internal object
49 
50 		return NOINTERFACE(iid);
51 	}
52 
AddRef()53 	unsigned long Direct3DPixelShader8::AddRef()
54 	{
55 		TRACE("");
56 
57 		return Unknown::AddRef();
58 	}
59 
Release()60 	unsigned long Direct3DPixelShader8::Release()
61 	{
62 		TRACE("");
63 
64 		return Unknown::Release();
65 	}
66 
GetFunction(void * data,unsigned int * size)67 	void Direct3DPixelShader8::GetFunction(void *data, unsigned int *size)
68 	{
69 		TRACE("");
70 
71 		if(data)
72 		{
73 			memcpy(data, shaderToken, this->size * 4);
74 		}
75 
76 		*size = this->size * 4;
77 	}
78 
getPixelShader() const79 	const sw::PixelShader *Direct3DPixelShader8::getPixelShader() const
80 	{
81 		return &pixelShader;
82 	}
83 }