OSDN Git Service

ef6f69b82474e6e31ff622a79d02c3eef63e9f69
[android-x86/external-swiftshader.git] / src / Radiance / libRAD / Device.hpp
1 // SwiftShader Software Renderer\r
2 //\r
3 // Copyright(c) 2005-2012 TransGaming Inc.\r
4 //\r
5 // All rights reserved. No part of this software may be copied, distributed, transmitted,\r
6 // transcribed, stored in a retrieval system, translated into any human or computer\r
7 // language by any means, or disclosed to third parties without the explicit written\r
8 // agreement of TransGaming Inc. Without such an agreement, no rights or licenses, express\r
9 // or implied, including but not limited to any patent rights, are granted to you.\r
10 //\r
11 \r
12 #ifndef gl_Device_hpp\r
13 #define gl_Device_hpp\r
14 \r
15 #include "Renderer/Renderer.hpp"\r
16 \r
17 namespace egl\r
18 {\r
19         class Image;\r
20 }\r
21 \r
22 namespace rad\r
23 {\r
24         class Texture;\r
25         class Image;\r
26 \r
27         enum PrimitiveType\r
28         {\r
29                 DRAW_POINTLIST,\r
30                 DRAW_LINELIST,\r
31                 DRAW_LINESTRIP,\r
32                 DRAW_LINELOOP,\r
33                 DRAW_TRIANGLELIST,\r
34                 DRAW_TRIANGLESTRIP,\r
35                 DRAW_TRIANGLEFAN\r
36         };\r
37 \r
38         struct Viewport\r
39         {\r
40                 int x0;\r
41                 int y0;\r
42                 unsigned int width;\r
43                 unsigned int height;\r
44                 float minZ;\r
45                 float maxZ;\r
46         };\r
47 \r
48         class Device : public sw::Renderer\r
49         {\r
50         public:\r
51                 explicit Device(sw::Context *context);\r
52 \r
53                 virtual ~Device();\r
54 \r
55                 virtual void clearColor(unsigned int color, unsigned int rgbaMask);\r
56                 virtual void clearDepth(float z);\r
57                 virtual void clearStencil(unsigned int stencil, unsigned int mask);\r
58                 virtual Image *createDepthStencilSurface(unsigned int width, unsigned int height, sw::Format format, int multiSampleDepth, bool discard);\r
59                 virtual Image *createRenderTarget(unsigned int width, unsigned int height, sw::Format format, int multiSampleDepth, bool lockable);\r
60                 virtual void drawIndexedPrimitive(PrimitiveType type, unsigned int indexOffset, unsigned int primitiveCount, int indexSize);\r
61                 virtual void drawPrimitive(PrimitiveType primitiveType, unsigned int primiveCount);\r
62                 virtual void setDepthStencilSurface(egl::Image *newDepthStencil);\r
63                 virtual void setPixelShader(sw::PixelShader *shader);\r
64                 virtual void setPixelShaderConstantF(unsigned int startRegister, const float *constantData, unsigned int count);\r
65                 virtual void setScissorEnable(bool enable);\r
66                 virtual void setRenderTarget(egl::Image *renderTarget);\r
67                 virtual void setScissorRect(const sw::Rect &rect);\r
68                 virtual void setVertexShader(sw::VertexShader *shader);\r
69                 virtual void setVertexShaderConstantF(unsigned int startRegister, const float *constantData, unsigned int count);\r
70                 virtual void setViewport(const Viewport &viewport);\r
71 \r
72                 virtual bool stretchRect(egl::Image *sourceSurface, const sw::Rect *sourceRect, egl::Image *destSurface, const sw::Rect *destRect, bool filter);\r
73                 virtual void finish();\r
74 \r
75         private:\r
76                 sw::Context *const context;\r
77 \r
78                 bool bindResources();\r
79                 void bindShaderConstants();\r
80                 bool bindViewport();   // Also adjusts for scissoring\r
81 \r
82                 bool validRectangle(const sw::Rect *rect, egl::Image *surface);\r
83 \r
84                 Viewport viewport;\r
85                 sw::Rect scissorRect;\r
86                 bool scissorEnable;\r
87 \r
88                 sw::PixelShader *pixelShader;\r
89                 sw::VertexShader *vertexShader;\r
90 \r
91                 bool pixelShaderDirty;\r
92                 unsigned int pixelShaderConstantsFDirty;\r
93                 bool vertexShaderDirty;\r
94                 unsigned int vertexShaderConstantsFDirty;\r
95 \r
96                 float pixelShaderConstantF[224][4];\r
97                 float vertexShaderConstantF[256][4];\r
98 \r
99                 egl::Image *renderTarget;\r
100                 egl::Image *depthStencil;\r
101         };\r
102 }\r
103 \r
104 #endif   // gl_Device_hpp\r