SamplerCore.hpp revision 894018228b0e0bdbd7aa7e8f47d4a9458789ca82
1// SwiftShader Software Renderer 2// 3// Copyright(c) 2005-2011 TransGaming Inc. 4// 5// All rights reserved. No part of this software may be copied, distributed, transmitted, 6// transcribed, stored in a retrieval system, translated into any human or computer 7// language by any means, or disclosed to third parties without the explicit written 8// agreement of TransGaming Inc. Without such an agreement, no rights or licenses, express 9// or implied, including but not limited to any patent rights, are granted to you. 10// 11 12#ifndef sw_SamplerCore_hpp 13#define sw_SamplerCore_hpp 14 15#include "PixelRoutine.hpp" 16#include "Reactor/Nucleus.hpp" 17 18namespace sw 19{ 20 class SamplerCore 21 { 22 public: 23 SamplerCore(Pointer<Byte> &r, const Sampler::State &state); 24 25 void sampleTexture(Pointer<Byte> &texture, Color4i &c, Float4 &u, Float4 &v, Float4 &w, Float4 &q, Color4f &dsx, Color4f &dsy, bool bias = false, bool fixed12 = true, bool gradients = false, bool lodProvided = false); 26 void sampleTexture(Pointer<Byte> &texture, Color4f &c, Float4 &u, Float4 &v, Float4 &w, Float4 &q, Color4f &dsx, Color4f &dsy, bool bias = false, bool gradients = false, bool lodProvided = false); 27 28 private: 29 void border(Short4 &mask, Float4 &coordinates); 30 void border(Int4 &mask, Float4 &coordinates); 31 Short4 offsetSample(Short4 &uvw, Pointer<Byte> &mipmap, int halfOffset, bool wrap, int count); 32 void sampleFilter(Pointer<Byte> &texture, Color4i &c, Float4 &u, Float4 &v, Float4 &w, Float &lod, Float &anisotropy, Float4 &uDelta, Float4 &vDelta, Int face[4], bool lodProvided); 33 void sampleAniso(Pointer<Byte> &texture, Color4i &c, Float4 &u, Float4 &v, Float4 &w, Float &lod, Float &anisotropy, Float4 &uDelta, Float4 &vDelta, Int face[4], bool secondLOD, bool lodProvided); 34 void sampleQuad(Pointer<Byte> &texture, Color4i &c, Float4 &u, Float4 &v, Float4 &w, Float &lod, Int face[4], bool secondLOD); 35 void sampleQuad2D(Pointer<Byte> &texture, Color4i &c, Float4 &u, Float4 &v, Float &lod, Int face[4], bool secondLOD); 36 void sample3D(Pointer<Byte> &texture, Color4i &c, Float4 &u, Float4 &v, Float4 &w, Float &lod, bool secondLOD); 37 void sampleFloatFilter(Pointer<Byte> &texture, Color4f &c, Float4 &u, Float4 &v, Float4 &w, Float &lod, Float &anisotropy, Float4 &uDelta, Float4 &vDelta, Int face[4], bool lodProvided); 38 void sampleFloatAniso(Pointer<Byte> &texture, Color4f &c, Float4 &u, Float4 &v, Float4 &w, Float &lod, Float &anisotropy, Float4 &uDelta, Float4 &vDelta, Int face[4], bool secondLOD, bool lodProvided); 39 void sampleFloat(Pointer<Byte> &texture, Color4f &c, Float4 &u, Float4 &v, Float4 &w, Float &lod, Int face[4], bool secondLOD); 40 void sampleFloat2D(Pointer<Byte> &texture, Color4f &c, Float4 &u, Float4 &v, Float4 &z, Float &lod, Int face[4], bool secondLOD); 41 void sampleFloat3D(Pointer<Byte> &texture, Color4f &c, Float4 &u, Float4 &v, Float4 &w, Float &lod, bool secondLOD); 42 void computeLod(Pointer<Byte> &texture, Float &lod, Float &anisotropy, Float4 &uDelta, Float4 &vDelta, Float4 &u, Float4 &v, Float &lodBias, Color4f &dsx, Color4f &dsy, bool bias, bool gradients, bool lodProvided); 43 void computeLod3D(Pointer<Byte> &texture, Float &lod, Float4 &u, Float4 &v, Float4 &w, Float &lodBias, Color4f &dsx, Color4f &dsy, bool bias, bool gradients, bool lodProvided); 44 void cubeFace(Int face[4], Float4 &U, Float4 &V, Float4 &lodU, Float4 &lodV, Float4 &x, Float4 &y, Float4 &z); 45 void computeIndices(Int index[4], Short4 uuuu, Short4 vvvv, Short4 wwww, const Pointer<Byte> &mipmap); 46 void sampleTexel(Color4i &c, Short4 &u, Short4 &v, Short4 &s, Pointer<Byte> &mipmap, Pointer<Byte> buffer[4]); 47 void sampleTexel(Color4f &c, Short4 &u, Short4 &v, Short4 &s, Float4 &z, Pointer<Byte> &mipmap, Pointer<Byte> buffer[4]); 48 void selectMipmap(Pointer<Byte> &texture, Pointer<Byte> buffer[4], Pointer<Byte> &mipmap, Float &lod, Int face[4], bool secondLOD); 49 void address(Short4 &uuuu, Float4 &uw, AddressingMode addressingMode); 50 51 void convertFixed12(Short4 &ci, Float4 &cf); 52 void convertFixed12(Color4i &ci, Color4f &cf); 53 void convertSigned12(Float4 &cf, Short4 &ci); 54 void convertSigned15(Float4 &cf, Short4 &ci); 55 void convertUnsigned16(Float4 &cf, Short4 &ci); 56 void sRGBtoLinear16_12(Short4 &c); 57 58 bool hasFloatTexture() const; 59 bool hasUnsignedTextureComponent(int component) const; 60 int textureComponentCount() const; 61 bool has16bitTexture() const; 62 bool isRGBComponent(int component) const; 63 64 Pointer<Byte> &constants; 65 const Sampler::State &state; 66 }; 67} 68 69#endif // sw_SamplerCore_hpp 70