swr/rast: Add private state parameter in fetcher
authorGeorge Kyriazis <george.kyriazis@intel.com>
Fri, 19 Jan 2018 21:46:58 +0000 (15:46 -0600)
committerGeorge Kyriazis <george.kyriazis@intel.com>
Fri, 19 Jan 2018 22:48:41 +0000 (16:48 -0600)
Reviewed-by: Bruce Cherniak <bruce.cherniak@intel.com>
src/gallium/drivers/swr/rasterizer/core/frontend.cpp
src/gallium/drivers/swr/rasterizer/core/state.h
src/gallium/drivers/swr/rasterizer/jitter/JitManager.cpp
src/gallium/drivers/swr/rasterizer/jitter/fetch_jit.cpp
src/gallium/drivers/swr/rasterizer/jitter/fetch_jit.h

index ed8ce151c390e46cbef8b642f46956979f3c15d4..727b7105cdfe7a8f40c5514ed41aa43f6fa8ca74 100644 (file)
@@ -1720,13 +1720,13 @@ void ProcessDraw(
                 // 1. Execute FS/VS for a single SIMD.
                 AR_BEGIN(FEFetchShader, pDC->drawId);
 #if USE_SIMD16_SHADERS
-                state.pfnFetchFunc(fetchInfo_lo, vin);
+                state.pfnFetchFunc(GetPrivateState(pDC), fetchInfo_lo, vin);
 #else
-                state.pfnFetchFunc(fetchInfo_lo, vin_lo);
+                state.pfnFetchFunc(GetPrivateState(pDC), fetchInfo_lo, vin_lo);
 
                 if ((i + KNOB_SIMD_WIDTH) < endVertex)  // 1/2 of KNOB_SIMD16_WIDTH
                 {
-                    state.pfnFetchFunc(fetchInfo_hi, vin_hi);
+                    state.pfnFetchFunc(GetPrivateState(pDC), fetchInfo_hi, vin_hi);
                 }
 #endif
                 AR_END(FEFetchShader, 0);
@@ -1968,7 +1968,7 @@ void ProcessDraw(
 
                 // 1. Execute FS/VS for a single SIMD.
                 AR_BEGIN(FEFetchShader, pDC->drawId);
-                state.pfnFetchFunc(fetchInfo, vout);
+                state.pfnFetchFunc(GetPrivateState(pDC), fetchInfo, vout);
                 AR_END(FEFetchShader, 0);
 
                 // forward fetch generated vertex IDs to the vertex shader
index d11ffc69b016746d22b34dc41e80ab43dff08eb9..c93c37b46870e87c3b695eb40edf70abcd01e75b 100644 (file)
@@ -873,9 +873,9 @@ static_assert(sizeof(SWR_BLEND_STATE) == 36, "Invalid SWR_BLEND_STATE size");
 /// FUNCTION POINTERS FOR SHADERS
 
 #if USE_SIMD16_SHADERS
-typedef void(__cdecl *PFN_FETCH_FUNC)(SWR_FETCH_CONTEXT& fetchInfo, simd16vertex& out);
+typedef void(__cdecl *PFN_FETCH_FUNC)(HANDLE hPrivateData, SWR_FETCH_CONTEXT& fetchInfo, simd16vertex& out);
 #else
-typedef void(__cdecl *PFN_FETCH_FUNC)(SWR_FETCH_CONTEXT& fetchInfo, simdvertex& out);
+typedef void(__cdecl *PFN_FETCH_FUNC)(HANDLE hPrivateData, SWR_FETCH_CONTEXT& fetchInfo, simdvertex& out);
 #endif
 typedef void(__cdecl *PFN_VERTEX_FUNC)(HANDLE hPrivateData, SWR_VS_CONTEXT* pVsContext);
 typedef void(__cdecl *PFN_HS_FUNC)(HANDLE hPrivateData, SWR_HS_CONTEXT* pHsContext);
index 40ca644121368e43eb696c9341ee3b87e52dc865..fbca1a74a72f50b07111ec24ae93c53b4bc63e0d 100644 (file)
@@ -125,6 +125,9 @@ JitManager::JitManager(uint32_t simdWidth, const char *arch, const char* core)
     // typedef void(__cdecl *PFN_FETCH_FUNC)(SWR_FETCH_CONTEXT& fetchInfo, simdvertex& out);
 #endif
     std::vector<Type*> fsArgs;
+
+    fsArgs.push_back(PointerType::get(Type::getVoidTy(mContext), 0));
+
     fsArgs.push_back(PointerType::get(Gen_SWR_FETCH_CONTEXT(this), 0));
 #if USE_SIMD16_SHADERS
     fsArgs.push_back(PointerType::get(Gen_simd16vertex(this), 0));
index ad70cbe95d3b49192f2ee4c0b7895b6d4231b3c6..d835f2d0296bbe2be8fa15615c83f3484bdc1b32 100644 (file)
@@ -127,6 +127,7 @@ struct FetchJit : public Builder
     void CreateGatherOddFormats(SWR_FORMAT format, Value* pMask, Value* pBase, Value* offsets, Value* result[4]);
     void ConvertFormat(SWR_FORMAT format, Value *texels[4]);
 
+    Value* mpPrivateContext;
     Value* mpFetchInfo;
 };
 
@@ -145,6 +146,9 @@ Function* FetchJit::Create(const FETCH_COMPILE_STATE& fetchState)
     auto    argitr = fetch->arg_begin();
 
     // Fetch shader arguments
+    mpPrivateContext = &*argitr; ++argitr;
+    mpPrivateContext->setName("privateContext");
+
     mpFetchInfo = &*argitr; ++argitr;
     mpFetchInfo->setName("fetchInfo");
     Value*    pVtxOut = &*argitr;
@@ -2806,8 +2810,10 @@ Value *FetchJit::GenerateCompCtrlVector16(const ComponentControl ctrl)
             Value *pId = BITCAST(LOAD(GEP(mpFetchInfo, { 0, SWR_FETCH_CONTEXT_CurInstance })), mFP32Ty);
             return VBROADCAST_16(pId);
         }
+
+
         case StoreSrc:
-        default:        
+        default:
             SWR_INVALID("Invalid component control");
             return VUNDEF_I_16();
     }
@@ -2822,15 +2828,15 @@ Value *FetchJit::GenerateCompCtrlVector(const ComponentControl ctrl)
 {
     switch (ctrl)
     {
-        case NoStore:
-            return VUNDEF_I();
-        case Store0:
-            return VIMMED1(0);
-        case Store1Fp:
-            return VIMMED1(1.0f);
-        case Store1Int:
-            return VIMMED1(1);
-        case StoreVertexId:
+    case NoStore:
+        return VUNDEF_I();
+    case Store0:
+        return VIMMED1(0);
+    case Store1Fp:
+        return VIMMED1(1.0f);
+    case Store1Int:
+        return VIMMED1(1);
+    case StoreVertexId:
         {
 #if USE_SIMD16_SHADERS
             Value *pId;
@@ -2847,15 +2853,17 @@ Value *FetchJit::GenerateCompCtrlVector(const ComponentControl ctrl)
 #endif
             return pId;
         }
-        case StoreInstanceId:
+    case StoreInstanceId:
         {
             Value *pId = BITCAST(LOAD(GEP(mpFetchInfo, { 0, SWR_FETCH_CONTEXT_CurInstance })), mFP32Ty);
             return VBROADCAST(pId);
         }
-        case StoreSrc:
-        default:
-            SWR_INVALID("Invalid component control");
-            return VUNDEF_I();
+
+
+    case StoreSrc:
+    default:
+        SWR_INVALID("Invalid component control");
+        return VUNDEF_I();
     }
 }
 
@@ -2908,6 +2916,7 @@ PFN_FETCH_FUNC JitFetchFunc(HANDLE hJitMgr, const HANDLE hFunc)
 
     pJitMgr->DumpAsm(const_cast<llvm::Function*>(func), "final");
 
+
     return pfnFetch;
 }
 
index 18fa96357b8ccc4b977f8df09a3311d7e96874d1..e334c20c5ee944a470a20015b77af62e2d11b4f5 100644 (file)
@@ -46,12 +46,12 @@ struct INPUT_ELEMENT_DESC
             uint32_t            StreamIndex : 6;
             uint32_t            InstanceEnable : 1;
             uint32_t            InstanceStrideEnable : 1;
-            uint32_t            ComponentControl0 : 3;
-            uint32_t            ComponentControl1 : 3;
-            uint32_t            ComponentControl2 : 3;
-            uint32_t            ComponentControl3 : 3;
+            uint32_t            ComponentControl0 : 4;
+            uint32_t            ComponentControl1 : 4;
+            uint32_t            ComponentControl2 : 4;
+            uint32_t            ComponentControl3 : 4;
             uint32_t            ComponentPacking : 4;
-            uint32_t            _reserved : 18;
+            uint32_t            _reserved : 14;
         };
         uint64_t bits;
     };
@@ -87,7 +87,7 @@ enum ComponentControl
     Store1Fp        = 3,
     Store1Int       = 4,
     StoreVertexId   = 5,
-    StoreInstanceId = 6
+    StoreInstanceId = 6,
 };
 
 //////////////////////////////////////////////////////////////////////////
@@ -126,9 +126,9 @@ struct FETCH_COMPILE_STATE
         if (bForceSequentialAccessEnable != other.bForceSequentialAccessEnable) return false;
         if (bInstanceIDOffsetEnable != other.bInstanceIDOffsetEnable) return false;
 
-        for(uint32_t i = 0; i < numAttribs; ++i)
+        for (uint32_t i = 0; i < numAttribs; ++i)
         {
-            if((layout[i].bits != other.layout[i].bits) ||
+            if ((layout[i].bits != other.layout[i].bits) ||
                (((layout[i].InstanceEnable == 1) || (layout[i].InstanceStrideEnable == 1)) &&
                 (layout[i].InstanceAdvancementState != other.layout[i].InstanceAdvancementState))){
                 return false;