OSDN Git Service

Add SwiftShader dump from Feb 6 2013
[android-x86/external-swiftshader.git] / src / Shader / SamplerCore.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 sw_SamplerCore_hpp\r
13 #define sw_SamplerCore_hpp\r
14 \r
15 #include "PixelRoutine.hpp"\r
16 #include "Reactor/Nucleus.hpp"\r
17 \r
18 namespace sw\r
19 {\r
20         class SamplerCore\r
21         {\r
22         public:\r
23                 SamplerCore(Pointer<Byte> &r, const Sampler::State &state);\r
24 \r
25                 void sampleTexture(Pointer<Byte> &texture, Vector4i &c, Float4 &u, Float4 &v, Float4 &w, Float4 &q, Vector4f &dsx, Vector4f &dsy, bool bias = false, bool fixed12 = true, bool gradients = false, bool lodProvided = false);\r
26                 void sampleTexture(Pointer<Byte> &texture, Vector4f &c, Float4 &u, Float4 &v, Float4 &w, Float4 &q, Vector4f &dsx, Vector4f &dsy, bool bias = false, bool gradients = false, bool lodProvided = false);\r
27 \r
28         private:\r
29                 void border(Short4 &mask, Float4 &coordinates);\r
30                 void border(Int4 &mask, Float4 &coordinates);\r
31                 Short4 offsetSample(Short4 &uvw, Pointer<Byte> &mipmap, int halfOffset, bool wrap, int count);\r
32                 void sampleFilter(Pointer<Byte> &texture, Vector4i &c, Float4 &u, Float4 &v, Float4 &w, Float &lod, Float &anisotropy, Float4 &uDelta, Float4 &vDelta, Int face[4], bool lodProvided);\r
33                 void sampleAniso(Pointer<Byte> &texture, Vector4i &c, Float4 &u, Float4 &v, Float4 &w, Float &lod, Float &anisotropy, Float4 &uDelta, Float4 &vDelta, Int face[4], bool secondLOD, bool lodProvided);\r
34                 void sampleQuad(Pointer<Byte> &texture, Vector4i &c, Float4 &u, Float4 &v, Float4 &w, Float &lod, Int face[4], bool secondLOD);\r
35                 void sampleQuad2D(Pointer<Byte> &texture, Vector4i &c, Float4 &u, Float4 &v, Float &lod, Int face[4], bool secondLOD);\r
36                 void sample3D(Pointer<Byte> &texture, Vector4i &c, Float4 &u, Float4 &v, Float4 &w, Float &lod, bool secondLOD);\r
37                 void sampleFloatFilter(Pointer<Byte> &texture, Vector4f &c, Float4 &u, Float4 &v, Float4 &w, Float &lod, Float &anisotropy, Float4 &uDelta, Float4 &vDelta, Int face[4], bool lodProvided);\r
38                 void sampleFloatAniso(Pointer<Byte> &texture, Vector4f &c, Float4 &u, Float4 &v, Float4 &w, Float &lod, Float &anisotropy, Float4 &uDelta, Float4 &vDelta, Int face[4], bool secondLOD, bool lodProvided);\r
39                 void sampleFloat(Pointer<Byte> &texture, Vector4f &c, Float4 &u, Float4 &v, Float4 &w, Float &lod, Int face[4], bool secondLOD);\r
40                 void sampleFloat2D(Pointer<Byte> &texture, Vector4f &c, Float4 &u, Float4 &v, Float4 &z, Float &lod, Int face[4], bool secondLOD);\r
41                 void sampleFloat3D(Pointer<Byte> &texture, Vector4f &c, Float4 &u, Float4 &v, Float4 &w, Float &lod, bool secondLOD);\r
42                 void computeLod(Pointer<Byte> &texture, Float &lod, Float &anisotropy, Float4 &uDelta, Float4 &vDelta, Float4 &u, Float4 &v, const Float &lodBias, Vector4f &dsx, Vector4f &dsy, bool bias, bool gradients, bool lodProvided);\r
43                 void computeLod3D(Pointer<Byte> &texture, Float &lod, Float4 &u, Float4 &v, Float4 &w, const Float &lodBias, Vector4f &dsx, Vector4f &dsy, bool bias, bool gradients, bool lodProvided);\r
44                 void cubeFace(Int face[4], Float4 &U, Float4 &V, Float4 &lodU, Float4 &lodV, Float4 &x, Float4 &y, Float4 &z);\r
45                 void computeIndices(Int index[4], Short4 uuuu, Short4 vvvv, Short4 wwww, const Pointer<Byte> &mipmap);\r
46                 void sampleTexel(Vector4i &c, Short4 &u, Short4 &v, Short4 &s, Pointer<Byte> &mipmap, Pointer<Byte> buffer[4]);\r
47                 void sampleTexel(Vector4f &c, Short4 &u, Short4 &v, Short4 &s, Float4 &z, Pointer<Byte> &mipmap, Pointer<Byte> buffer[4]);\r
48                 void selectMipmap(Pointer<Byte> &texture, Pointer<Byte> buffer[4], Pointer<Byte> &mipmap, Float &lod, Int face[4], bool secondLOD);\r
49                 void address(Short4 &uuuu, Float4 &uw, AddressingMode addressingMode);\r
50 \r
51                 void convertFixed12(Short4 &ci, Float4 &cf);\r
52                 void convertFixed12(Vector4i &ci, Vector4f &cf);\r
53                 void convertSigned12(Float4 &cf, Short4 &ci);\r
54                 void convertSigned15(Float4 &cf, Short4 &ci);\r
55                 void convertUnsigned16(Float4 &cf, Short4 &ci);\r
56                 void sRGBtoLinear16_12(Short4 &c);\r
57 \r
58                 bool hasFloatTexture() const;\r
59                 bool hasUnsignedTextureComponent(int component) const;\r
60                 int textureComponentCount() const;\r
61                 bool has16bitTexture() const;\r
62                 bool isRGBComponent(int component) const;\r
63 \r
64                 Pointer<Byte> &constants;\r
65                 const Sampler::State &state;\r
66         };\r
67 }\r
68 \r
69 #endif   // sw_SamplerCore_hpp\r