r600 : add some defs
authorRichard Li <richardradeon@gmail.com>
Wed, 18 Nov 2009 19:43:59 +0000 (14:43 -0500)
committerRichard Li <richardradeon@gmail.com>
Wed, 18 Nov 2009 20:38:45 +0000 (15:38 -0500)
src/mesa/drivers/dri/r600/r700_assembler.c
src/mesa/drivers/dri/r600/r700_assembler.h
src/mesa/drivers/dri/r600/r700_shader.c

index 4b5d40bd3a9d5824e5c8909b74c042fa59f47a01..6e8d1cd9270dcc73079503e05ec99ddb6aec1b56 100644 (file)
@@ -39,6 +39,7 @@
 #include "r700_assembler.h"
 
 #define USE_CF_FOR_CONTINUE_BREAK 1
+#define USE_CF_FOR_POP_AFTER      1
 
 BITS addrmode_PVSDST(PVSDST * pPVSDST)
 {
@@ -489,10 +490,12 @@ int Init_r700_AssemblerBase(SHADER_PIPE_TYPE spt, r700_AssemblerBase* pAsm, R700
     pAsm->unCallerArrayPointer = 0;
 
     pAsm->CALLSP = 0;
-    pAsm->CALLSTACK[0].FCSP_BeforeEntry;
+    pAsm->CALLSTACK[0].FCSP_BeforeEntry = 0;
     pAsm->CALLSTACK[0].plstCFInstructions_local
           = &(pAsm->pR700Shader->lstCFInstructions);
 
+    pAsm->CALLSTACK[0].stackUsage.bits = 0;
+
     SetActiveCFlist(pAsm->pR700Shader, pAsm->CALLSTACK[0].plstCFInstructions_local);
 
     pAsm->unCFflags = 0;
@@ -4978,6 +4981,21 @@ GLboolean assemble_EXPORT(r700_AssemblerBase *pAsm)
     return GL_TRUE;
 }
 
+inline void checkStackDepth(r700_AssemblerBase *pAsm, GLuint uReason)
+{
+    switch (uReason)
+    {
+    case FC_PUSH_VPM:
+        break;
+    case FC_PUSH_WQM:
+        break;
+    case FC_LOOP:
+        break;
+    case FC_REP:
+        break;
+    };
+}
+
 GLboolean jumpToOffest(r700_AssemblerBase *pAsm, GLuint pops, GLint offset)
 {
     if(GL_FALSE == add_cf_instruction(pAsm) )
@@ -5024,7 +5042,7 @@ GLboolean pops(r700_AssemblerBase *pAsm, GLuint pops)
     return GL_TRUE;
 }
 
-GLboolean assemble_IF(r700_AssemblerBase *pAsm)
+GLboolean assemble_IF(r700_AssemblerBase *pAsm, GLboolean bHasElse)
 {
     if(GL_FALSE == add_cf_instruction(pAsm) )
     {
@@ -5056,10 +5074,12 @@ GLboolean assemble_IF(r700_AssemblerBase *pAsm)
     pAsm->fc_stack[pAsm->FCSP].midLen= 0;
     pAsm->fc_stack[pAsm->FCSP].first = pAsm->cf_current_cf_clause_ptr;
 
+#ifndef USE_CF_FOR_POP_AFTER
     if(GL_TRUE != bHasElse)
     {
         pAsm->alu_x_opcode = SQ_CF_INST_ALU_POP_AFTER;
     }
+#endif /* USE_CF_FOR_POP_AFTER */
 
     pAsm->branch_depth++;
 
@@ -5072,6 +5092,10 @@ GLboolean assemble_IF(r700_AssemblerBase *pAsm)
 
 GLboolean assemble_ELSE(r700_AssemblerBase *pAsm)
 {
+#ifdef USE_CF_FOR_POP_AFTER
+    pops(pAsm, 1);
+#endif /* USE_CF_FOR_POP_AFTER */
+
     if(GL_FALSE == add_cf_instruction(pAsm) )
     {
         return GL_FALSE;
@@ -5094,7 +5118,9 @@ GLboolean assemble_ELSE(r700_AssemblerBase *pAsm)
     pAsm->fc_stack[pAsm->FCSP].mid[0] = pAsm->cf_current_cf_clause_ptr;
     //pAsm->fc_stack[pAsm->FCSP].unNumMid = 1;
 
+#ifndef USE_CF_FOR_POP_AFTER
     pAsm->alu_x_opcode = SQ_CF_INST_ALU_POP_AFTER;
+#endif /* USE_CF_FOR_POP_AFTER */
 
     pAsm->fc_stack[pAsm->FCSP].first->m_Word0.f.addr = pAsm->pR700Shader->plstCFInstructions_active->uNumOfNode - 1; 
 
@@ -5103,6 +5129,10 @@ GLboolean assemble_ELSE(r700_AssemblerBase *pAsm)
 
 GLboolean assemble_ENDIF(r700_AssemblerBase *pAsm)
 {
+#ifdef USE_CF_FOR_POP_AFTER
+    pops(pAsm, 1);
+#endif /* USE_CF_FOR_POP_AFTER */
+
     pAsm->alu_x_opcode = SQ_CF_INST_ALU;
 
     if(NULL == pAsm->fc_stack[pAsm->FCSP].mid)
@@ -5410,6 +5440,7 @@ GLboolean assemble_BGNSUB(r700_AssemblerBase *pAsm, GLint nILindex)
     pAsm->CALLSTACK[pAsm->CALLSP].FCSP_BeforeEntry = pAsm->FCSP;
     pAsm->CALLSTACK[pAsm->CALLSP].plstCFInstructions_local
                    = &(pAsm->subs[pAsm->unSubArrayPointer].lstCFInstructions_local);
+    pAsm->CALLSTACK[pAsm->CALLSP].stackUsage.bits = 0;
     SetActiveCFlist(pAsm->pR700Shader, 
                     pAsm->CALLSTACK[pAsm->CALLSP].plstCFInstructions_local);
 
index 85d32212c07df2edf4a507cc5084bdbcb1871dd4..516923f67cd8781175e5be1a500b4ed439741147 100644 (file)
@@ -259,6 +259,8 @@ enum
     FC_IF = 1,
     FC_LOOP = 2,
     FC_REP = 3,
+    FC_PUSH_VPM = 4,
+    FC_PUSH_WQM = 5,
 
     COND_NONE = 0,
     COND_BOOL = 1,
@@ -304,12 +306,30 @@ typedef struct CALLER_POINTER
 
 #define SQ_MAX_CALL_DEPTH 0x00000020
 
+typedef struct STACK_USAGE 
+{
+       BITS pushs   :8;
+       BITS current :8;
+       BITS max     :8;
+} STACK_USAGE;
+
+typedef union STACKDWORDtag 
+{
+       BITS        bits;
+       STACK_USAGE su;
+} STACKDWORD;
+
 typedef struct CALL_LEVEL
 {
     unsigned int      FCSP_BeforeEntry;
+    STACKDWORD        stackUsage;
     TypedShaderList * plstCFInstructions_local;
 } CALL_LEVEL;
 
+#define HAS_CURRENT_LOOPRET 0x1L
+#define HAS_LOOPRET         0x2L
+#define LOOPRET_FLAGS       HAS_LOOPRET | HAS_CURRENT_LOOPRET
+
 typedef struct r700_AssemblerBase 
 {
        R700ControlFlowSXClause*      cf_last_export_ptr;
@@ -429,6 +449,7 @@ typedef struct r700_AssemblerBase
 } r700_AssemblerBase;
 
 //Internal use
+inline void checkStackDepth(r700_AssemblerBase *pAsm, GLuint uReason);
 BITS addrmode_PVSDST(PVSDST * pPVSDST);
 void setaddrmode_PVSDST(PVSDST * pPVSDST, BITS addrmode);
 void nomask_PVSDST(PVSDST * pPVSDST);
index 2eed1acc2f55f2f26139291e67a4299221bd530f..db951e48c4f0ccfa21c092c14a2944b11ef0d9ce 100644 (file)
@@ -140,7 +140,7 @@ void Init_R700_Shader(R700_Shader * pShader)
        pShader->killIsUsed = GL_FALSE;
 
        pShader->uCFOffset = 0;
-       pShader->uStackSize = 0;
+       pShader->uStackSize = 10; //richard test
        pShader->uMaxCallDepth = 0;
 
        pShader->bSurfAllocated = GL_FALSE;