2 * Copyright (C) 2008-2009 Advanced Micro Devices, Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included
12 * in all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 * Richard Li <RichardZ.Li@amd.com>, <richardradeon@gmail.com>
28 #ifndef __R700_SHADER_H__
29 #define __R700_SHADER_H__
31 #include "main/mtypes.h"
33 #include "r700_shaderinst.h"
36 void r700ShaderInit(struct gl_context
* ctx
);
38 typedef enum R700ShaderType
45 R700_SHADER_INVALID
= 0x5,
48 typedef struct TypedShaderList
50 R700ShaderInstruction
* pHead
;
51 R700ShaderInstruction
* pTail
;
55 typedef struct RealRegister
61 typedef struct InstDeps
67 typedef struct R700_Shader
73 GLboolean bBinaryShader
;
74 GLboolean bFetchShaderRequired
;
75 GLboolean bNeedsAssembly
;
76 GLboolean bLinksDirty
;
78 GLuint uShaderBinaryDWORDSize
; // in DWORDS
80 GLuint nParamExports
; // VS_ EXPORT_COUNT (1 based, the actual register is 0 based!)
82 GLuint resource
; // VS and PS _RESOURCE
83 GLuint exportMode
; // VS and PS _EXPORT_MODE
85 GLboolean depthIsImported
;
87 // Vertex program exports
88 GLboolean positionVectorIsExported
;
90 GLboolean miscVectorIsExported
;
91 GLboolean renderTargetArrayIndexIsExported
;
93 GLboolean ccDist0VectorIsExported
;
94 GLboolean ccDist1VectorIsExported
;
96 // Pixel program exports
97 GLboolean depthIsExported
;
98 GLboolean stencilRefIsExported
;
99 GLboolean coverageToMaskIsExported
;
100 GLboolean maskIsExported
;
102 GLboolean killIsUsed
;
110 GLuint uMaxCallDepth
;
112 TypedShaderList
* plstCFInstructions_active
;
113 TypedShaderList lstCFInstructions
;
114 TypedShaderList lstALUInstructions
;
115 TypedShaderList lstTEXInstructions
;
116 TypedShaderList lstVTXInstructions
;
118 RealRegister RegStartAddr
;
119 RealRegister RegCFOffset
;
120 RealRegister RegEndCF
;
121 RealRegister RegEndALU
;
122 RealRegister egEndFetcg
;
124 // -------- constants
125 GLfloat ConstantArray
[SQ_ALU_CONSTANT_PS_COUNT
* 4];
127 GLboolean bSurfAllocated
;
131 void AddInstToList(TypedShaderList
* plstCFInstructions
, R700ShaderInstruction
* pInst
);
132 void TakeInstOutFromList(TypedShaderList
* plstCFInstructions
, R700ShaderInstruction
* pInst
);
133 void ResolveLinks(R700_Shader
*pShader
);
134 void Assemble(R700_Shader
*pShader
);
137 void Init_R700_Shader(R700_Shader
* pShader
);
138 void AddCFInstruction(R700_Shader
*pShader
, R700ControlFlowInstruction
*pCFInst
);
139 void AddVTXInstruction(R700_Shader
*pShader
, R700VertexInstruction
*pVTXInst
);
140 void AddTEXInstruction(R700_Shader
*pShader
, R700TextureInstruction
*pTEXInst
);
141 void AddALUInstruction(R700_Shader
*pShader
, R700ALUInstruction
*pALUInst
);
142 void SetActiveCFlist(R700_Shader
*pShader
, TypedShaderList
* plstCF
);
144 void LoadProgram(R700_Shader
*pShader
);
145 void UpdateShaderRegisters(R700_Shader
*pShader
);
146 void DeleteInstructions(R700_Shader
*pShader
);
147 void DebugPrint(void);
148 void cleanup_vfetch_shaderinst(R700_Shader
*pShader
);
150 void Clean_Up_Shader(R700_Shader
*pShader
);
152 #endif /*__R700_SHADER_H__*/