Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 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 | #ifndef sw_PixelPipeline_hpp |
| 16 | #define sw_PixelPipeline_hpp |
| 17 | |
| 18 | #include "PixelRoutine.hpp" |
| 19 | |
| 20 | namespace sw |
| 21 | { |
| 22 | class PixelPipeline : public PixelRoutine |
| 23 | { |
| 24 | public: |
| 25 | PixelPipeline(const PixelProcessor::State &state, const PixelShader *shader) : |
| 26 | PixelRoutine(state, shader), current(rs[0]), diffuse(vs[0]), specular(vs[1]), perturbate(false), luminance(false), previousScaling(false) {} |
| 27 | virtual ~PixelPipeline() {} |
| 28 | |
| 29 | protected: |
| 30 | virtual void setBuiltins(Int &x, Int &y, Float4(&z)[4], Float4 &w); |
| 31 | virtual void applyShader(Int cMask[4]); |
| 32 | virtual Bool alphaTest(Int cMask[4]); |
| 33 | virtual void rasterOperation(Float4 &fog, Pointer<Byte> cBuffer[4], Int &x, Int sMask[4], Int zMask[4], Int cMask[4]); |
| 34 | |
| 35 | private: |
| 36 | Vector4s ¤t; |
| 37 | Vector4s &diffuse; |
| 38 | Vector4s &specular; |
| 39 | |
| 40 | Vector4s rs[6]; |
| 41 | Vector4s vs[2]; |
| 42 | Vector4s ts[6]; |
| 43 | |
| 44 | // bem(l) offsets and luminance |
| 45 | Float4 du; |
| 46 | Float4 dv; |
| 47 | Short4 L; |
| 48 | |
| 49 | // texm3x3 temporaries |
| 50 | Float4 u_; // FIXME |
| 51 | Float4 v_; // FIXME |
| 52 | Float4 w_; // FIXME |
| 53 | Float4 U; // FIXME |
| 54 | Float4 V; // FIXME |
| 55 | Float4 W; // FIXME |
| 56 | |
| 57 | void fixedFunction(); |
| 58 | void blendTexture(Vector4s &temp, Vector4s &texture, int stage); |
| 59 | void fogBlend(Vector4s ¤t, Float4 &fog); |
| 60 | void specularPixel(Vector4s ¤t, Vector4s &specular); |
| 61 | |
Nicolas Capens | 89a218b | 2017-11-07 13:05:20 -0500 | [diff] [blame] | 62 | Vector4s sampleTexture(int coordinates, int sampler, bool project = false); |
| 63 | Vector4s sampleTexture(int sampler, Float4 &u, Float4 &v, Float4 &w, Float4 &q, bool project = false); |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 64 | |
| 65 | Short4 convertFixed12(RValue<Float4> cf); |
| 66 | void convertFixed12(Vector4s &cs, Vector4f &cf); |
| 67 | Float4 convertSigned12(Short4 &cs); |
| 68 | void convertSigned12(Vector4f &cf, Vector4s &cs); |
| 69 | |
| 70 | void writeDestination(Vector4s &d, const Dst &dst); |
| 71 | Vector4s fetchRegister(const Src &src); |
| 72 | |
| 73 | // Instructions |
| 74 | void MOV(Vector4s &dst, Vector4s &src0); |
| 75 | void ADD(Vector4s &dst, Vector4s &src0, Vector4s &src1); |
| 76 | void SUB(Vector4s &dst, Vector4s &src0, Vector4s &src1); |
| 77 | void MAD(Vector4s &dst, Vector4s &src0, Vector4s &src1, Vector4s &src2); |
| 78 | void MUL(Vector4s &dst, Vector4s &src0, Vector4s &src1); |
| 79 | void DP3(Vector4s &dst, Vector4s &src0, Vector4s &src1); |
| 80 | void DP4(Vector4s &dst, Vector4s &src0, Vector4s &src1); |
| 81 | void LRP(Vector4s &dst, Vector4s &src0, Vector4s &src1, Vector4s &src2); |
| 82 | void TEXCOORD(Vector4s &dst, Float4 &u, Float4 &v, Float4 &s, int coordinate); |
| 83 | void TEXCRD(Vector4s &dst, Float4 &u, Float4 &v, Float4 &s, int coordinate, bool project); |
| 84 | void TEXDP3(Vector4s &dst, Float4 &u, Float4 &v, Float4 &s, Vector4s &src); |
| 85 | void TEXDP3TEX(Vector4s &dst, Float4 &u, Float4 &v, Float4 &s, int stage, Vector4s &src0); |
| 86 | void TEXKILL(Int cMask[4], Float4 &u, Float4 &v, Float4 &s); |
| 87 | void TEXKILL(Int cMask[4], Vector4s &dst); |
| 88 | void TEX(Vector4s &dst, Float4 &u, Float4 &v, Float4 &s, int stage, bool project); |
| 89 | void TEXLD(Vector4s &dst, Vector4s &src, int stage, bool project); |
| 90 | void TEXBEM(Vector4s &dst, Vector4s &src, Float4 &u, Float4 &v, Float4 &s, int stage); |
| 91 | void TEXBEML(Vector4s &dst, Vector4s &src, Float4 &u, Float4 &v, Float4 &s, int stage); |
| 92 | void TEXREG2AR(Vector4s &dst, Vector4s &src0, int stage); |
| 93 | void TEXREG2GB(Vector4s &dst, Vector4s &src0, int stage); |
| 94 | void TEXREG2RGB(Vector4s &dst, Vector4s &src0, int stage); |
| 95 | void TEXM3X2DEPTH(Vector4s &dst, Float4 &u, Float4 &v, Float4 &s, Vector4s &src, bool signedScaling); |
| 96 | void TEXM3X2PAD(Float4 &u, Float4 &v, Float4 &s, Vector4s &src0, int component, bool signedScaling); |
| 97 | void TEXM3X2TEX(Vector4s &dst, Float4 &u, Float4 &v, Float4 &s, int stage, Vector4s &src0, bool signedScaling); |
| 98 | void TEXM3X3(Vector4s &dst, Float4 &u, Float4 &v, Float4 &s, Vector4s &src0, bool signedScaling); |
| 99 | void TEXM3X3PAD(Float4 &u, Float4 &v, Float4 &s, Vector4s &src0, int component, bool signedScaling); |
| 100 | void TEXM3X3SPEC(Vector4s &dst, Float4 &u, Float4 &v, Float4 &s, int stage, Vector4s &src0, Vector4s &src1); |
| 101 | void TEXM3X3TEX(Vector4s &dst, Float4 &u, Float4 &v, Float4 &s, int stage, Vector4s &src0, bool singedScaling); |
| 102 | void TEXM3X3VSPEC(Vector4s &dst, Float4 &u, Float4 &v, Float4 &s, int stage, Vector4s &src0); |
| 103 | void TEXDEPTH(); |
| 104 | void CND(Vector4s &dst, Vector4s &src0, Vector4s &src1, Vector4s &src2); |
| 105 | void CMP(Vector4s &dst, Vector4s &src0, Vector4s &src1, Vector4s &src2); |
| 106 | void BEM(Vector4s &dst, Vector4s &src0, Vector4s &src1, int stage); |
| 107 | |
| 108 | bool perturbate; |
| 109 | bool luminance; |
| 110 | bool previousScaling; |
| 111 | }; |
| 112 | } |
| 113 | |
| 114 | #endif |