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>
33 #include "main/mtypes.h"
34 #include "main/imports.h"
36 #include "radeon_debug.h"
37 #include "r600_context.h"
39 #include "r700_assembler.h"
41 #define USE_CF_FOR_CONTINUE_BREAK 1
43 BITS
addrmode_PVSDST(PVSDST
* pPVSDST
)
45 return pPVSDST
->addrmode0
| ((BITS
)pPVSDST
->addrmode1
<< 1);
48 void setaddrmode_PVSDST(PVSDST
* pPVSDST
, BITS addrmode
)
50 pPVSDST
->addrmode0
= addrmode
& 1;
51 pPVSDST
->addrmode1
= (addrmode
>> 1) & 1;
54 void nomask_PVSDST(PVSDST
* pPVSDST
)
56 pPVSDST
->writex
= pPVSDST
->writey
= pPVSDST
->writez
= pPVSDST
->writew
= 1;
59 BITS
addrmode_PVSSRC(PVSSRC
* pPVSSRC
)
61 return pPVSSRC
->addrmode0
| ((BITS
)pPVSSRC
->addrmode1
<< 1);
64 void setaddrmode_PVSSRC(PVSSRC
* pPVSSRC
, BITS addrmode
)
66 pPVSSRC
->addrmode0
= addrmode
& 1;
67 pPVSSRC
->addrmode1
= (addrmode
>> 1) & 1;
71 void setswizzle_PVSSRC(PVSSRC
* pPVSSRC
, BITS swz
)
76 pPVSSRC
->swizzlew
= swz
;
79 void noswizzle_PVSSRC(PVSSRC
* pPVSSRC
)
81 pPVSSRC
->swizzlex
= SQ_SEL_X
;
82 pPVSSRC
->swizzley
= SQ_SEL_Y
;
83 pPVSSRC
->swizzlez
= SQ_SEL_Z
;
84 pPVSSRC
->swizzlew
= SQ_SEL_W
;
88 swizzleagain_PVSSRC(PVSSRC
* pPVSSRC
, BITS x
, BITS y
, BITS z
, BITS w
)
92 case SQ_SEL_X
: x
= pPVSSRC
->swizzlex
;
94 case SQ_SEL_Y
: x
= pPVSSRC
->swizzley
;
96 case SQ_SEL_Z
: x
= pPVSSRC
->swizzlez
;
98 case SQ_SEL_W
: x
= pPVSSRC
->swizzlew
;
105 case SQ_SEL_X
: y
= pPVSSRC
->swizzlex
;
107 case SQ_SEL_Y
: y
= pPVSSRC
->swizzley
;
109 case SQ_SEL_Z
: y
= pPVSSRC
->swizzlez
;
111 case SQ_SEL_W
: y
= pPVSSRC
->swizzlew
;
118 case SQ_SEL_X
: z
= pPVSSRC
->swizzlex
;
120 case SQ_SEL_Y
: z
= pPVSSRC
->swizzley
;
122 case SQ_SEL_Z
: z
= pPVSSRC
->swizzlez
;
124 case SQ_SEL_W
: z
= pPVSSRC
->swizzlew
;
131 case SQ_SEL_X
: w
= pPVSSRC
->swizzlex
;
133 case SQ_SEL_Y
: w
= pPVSSRC
->swizzley
;
135 case SQ_SEL_Z
: w
= pPVSSRC
->swizzlez
;
137 case SQ_SEL_W
: w
= pPVSSRC
->swizzlew
;
142 pPVSSRC
->swizzlex
= x
;
143 pPVSSRC
->swizzley
= y
;
144 pPVSSRC
->swizzlez
= z
;
145 pPVSSRC
->swizzlew
= w
;
148 void neg_PVSSRC(PVSSRC
* pPVSSRC
)
156 void noneg_PVSSRC(PVSSRC
* pPVSSRC
)
164 // negate argument (for SUB instead of ADD and alike)
165 void flipneg_PVSSRC(PVSSRC
* pPVSSRC
)
167 pPVSSRC
->negx
= !pPVSSRC
->negx
;
168 pPVSSRC
->negy
= !pPVSSRC
->negy
;
169 pPVSSRC
->negz
= !pPVSSRC
->negz
;
170 pPVSSRC
->negw
= !pPVSSRC
->negw
;
173 void zerocomp_PVSSRC(PVSSRC
* pPVSSRC
, int c
)
177 case 0: pPVSSRC
->swizzlex
= SQ_SEL_0
; pPVSSRC
->negx
= 0; break;
178 case 1: pPVSSRC
->swizzley
= SQ_SEL_0
; pPVSSRC
->negy
= 0; break;
179 case 2: pPVSSRC
->swizzlez
= SQ_SEL_0
; pPVSSRC
->negz
= 0; break;
180 case 3: pPVSSRC
->swizzlew
= SQ_SEL_0
; pPVSSRC
->negw
= 0; break;
185 void onecomp_PVSSRC(PVSSRC
* pPVSSRC
, int c
)
189 case 0: pPVSSRC
->swizzlex
= SQ_SEL_1
; pPVSSRC
->negx
= 0; break;
190 case 1: pPVSSRC
->swizzley
= SQ_SEL_1
; pPVSSRC
->negy
= 0; break;
191 case 2: pPVSSRC
->swizzlez
= SQ_SEL_1
; pPVSSRC
->negz
= 0; break;
192 case 3: pPVSSRC
->swizzlew
= SQ_SEL_1
; pPVSSRC
->negw
= 0; break;
197 BITS
is_misc_component_exported(VAP_OUT_VTX_FMT_0
* pOutVTXFmt0
)
199 return (pOutVTXFmt0
->point_size
|
200 pOutVTXFmt0
->edge_flag
|
201 pOutVTXFmt0
->rta_index
|
202 pOutVTXFmt0
->kill_flag
|
203 pOutVTXFmt0
->viewport_index
);
206 BITS
is_depth_component_exported(OUT_FRAGMENT_FMT_0
* pFPOutFmt
)
208 return (pFPOutFmt
->depth
|
209 pFPOutFmt
->stencil_ref
|
211 pFPOutFmt
->coverage_to_mask
);
214 GLboolean
is_reduction_opcode(PVSDWORD
* dest
)
216 if (dest
->dst
.op3
== 0)
218 if ( (dest
->dst
.opcode
== SQ_OP2_INST_DOT4
|| dest
->dst
.opcode
== SQ_OP2_INST_DOT4_IEEE
|| dest
->dst
.opcode
== SQ_OP2_INST_CUBE
) )
226 GLuint
GetSurfaceFormat(GLenum eType
, GLuint nChannels
, GLuint
* pClient_size
)
228 GLuint format
= FMT_INVALID
;
229 GLuint uiElemSize
= 0;
234 case GL_UNSIGNED_BYTE
:
239 format
= FMT_8
; break;
241 format
= FMT_8_8
; break;
243 format
= FMT_8_8_8
; break;
245 format
= FMT_8_8_8_8
; break;
251 case GL_UNSIGNED_SHORT
:
257 format
= FMT_16
; break;
259 format
= FMT_16_16
; break;
261 format
= FMT_16_16_16
; break;
263 format
= FMT_16_16_16_16
; break;
269 case GL_UNSIGNED_INT
:
275 format
= FMT_32
; break;
277 format
= FMT_32_32
; break;
279 format
= FMT_32_32_32
; break;
281 format
= FMT_32_32_32_32
; break;
292 format
= FMT_32_FLOAT
; break;
294 format
= FMT_32_32_FLOAT
; break;
296 format
= FMT_32_32_32_FLOAT
; break;
298 format
= FMT_32_32_32_32_FLOAT
; break;
308 format
= FMT_32_FLOAT
; break;
310 format
= FMT_32_32_FLOAT
; break;
312 format
= FMT_32_32_32_FLOAT
; break;
314 format
= FMT_32_32_32_32_FLOAT
; break;
321 //GL_ASSERT_NO_CASE();
324 if(NULL
!= pClient_size
)
326 *pClient_size
= uiElemSize
* nChannels
;
332 unsigned int r700GetNumOperands(r700_AssemblerBase
* pAsm
)
339 switch (pAsm
->D
.dst
.opcode
)
341 case SQ_OP2_INST_ADD
:
342 case SQ_OP2_INST_KILLGT
:
343 case SQ_OP2_INST_MUL
:
344 case SQ_OP2_INST_MAX
:
345 case SQ_OP2_INST_MIN
:
346 //case SQ_OP2_INST_MAX_DX10:
347 //case SQ_OP2_INST_MIN_DX10:
348 case SQ_OP2_INST_SETE
:
349 case SQ_OP2_INST_SETNE
:
350 case SQ_OP2_INST_SETGT
:
351 case SQ_OP2_INST_SETGE
:
352 case SQ_OP2_INST_PRED_SETE
:
353 case SQ_OP2_INST_PRED_SETGT
:
354 case SQ_OP2_INST_PRED_SETGE
:
355 case SQ_OP2_INST_PRED_SETNE
:
356 case SQ_OP2_INST_DOT4
:
357 case SQ_OP2_INST_DOT4_IEEE
:
358 case SQ_OP2_INST_CUBE
:
361 case SQ_OP2_INST_MOV
:
362 case SQ_OP2_INST_MOVA_FLOOR
:
363 case SQ_OP2_INST_FRACT
:
364 case SQ_OP2_INST_FLOOR
:
365 case SQ_OP2_INST_EXP_IEEE
:
366 case SQ_OP2_INST_LOG_CLAMPED
:
367 case SQ_OP2_INST_LOG_IEEE
:
368 case SQ_OP2_INST_RECIP_IEEE
:
369 case SQ_OP2_INST_RECIPSQRT_IEEE
:
370 case SQ_OP2_INST_FLT_TO_INT
:
371 case SQ_OP2_INST_SIN
:
372 case SQ_OP2_INST_COS
:
375 default: radeon_error(
376 "Need instruction operand number for %x.\n", pAsm
->D
.dst
.opcode
);
382 int Init_r700_AssemblerBase(SHADER_PIPE_TYPE spt
, r700_AssemblerBase
* pAsm
, R700_Shader
* pShader
)
386 Init_R700_Shader(pShader
);
387 pAsm
->pR700Shader
= pShader
;
388 pAsm
->currentShaderType
= spt
;
390 pAsm
->cf_last_export_ptr
= NULL
;
392 pAsm
->cf_current_export_clause_ptr
= NULL
;
393 pAsm
->cf_current_alu_clause_ptr
= NULL
;
394 pAsm
->cf_current_tex_clause_ptr
= NULL
;
395 pAsm
->cf_current_vtx_clause_ptr
= NULL
;
396 pAsm
->cf_current_cf_clause_ptr
= NULL
;
398 // No clause has been created yet
399 pAsm
->cf_current_clause_type
= CF_EMPTY_CLAUSE
;
401 pAsm
->number_of_colorandz_exports
= 0;
402 pAsm
->number_of_exports
= 0;
403 pAsm
->number_of_export_opcodes
= 0;
405 pAsm
->alu_x_opcode
= 0;
414 pAsm
->uLastPosUpdate
= 0;
416 *(BITS
*) &pAsm
->fp_stOutFmt0
= 0;
420 pAsm
->number_used_registers
= 0;
421 pAsm
->uUsedConsts
= 256;
425 pAsm
->uBoolConsts
= 0;
426 pAsm
->uIntConsts
= 0;
431 pAsm
->fc_stack
[0].type
= FC_NONE
;
433 pAsm
->branch_depth
= 0;
434 pAsm
->max_branch_depth
= 0;
439 pAsm
->aArgSubst
[3] = (-1);
443 for (i
=0; i
<NUMBER_OF_OUTPUT_COLORS
; i
++)
445 pAsm
->color_export_register_number
[i
] = (-1);
449 pAsm
->depth_export_register_number
= (-1);
450 pAsm
->stencil_export_register_number
= (-1);
451 pAsm
->coverage_to_mask_export_register_number
= (-1);
452 pAsm
->mask_export_register_number
= (-1);
454 pAsm
->starting_export_register_number
= 0;
455 pAsm
->starting_vfetch_register_number
= 0;
456 pAsm
->starting_temp_register_number
= 0;
457 pAsm
->uFirstHelpReg
= 0;
460 pAsm
->input_position_is_used
= GL_FALSE
;
461 pAsm
->input_normal_is_used
= GL_FALSE
;
464 for (i
=0; i
<NUMBER_OF_INPUT_COLORS
; i
++)
466 pAsm
->input_color_is_used
[ i
] = GL_FALSE
;
469 for (i
=0; i
<NUMBER_OF_TEXTURE_UNITS
; i
++)
471 pAsm
->input_texture_unit_is_used
[ i
] = GL_FALSE
;
474 for (i
=0; i
<VERT_ATTRIB_MAX
; i
++)
476 pAsm
->vfetch_instruction_ptr_array
[ i
] = NULL
;
479 pAsm
->number_of_inputs
= 0;
481 pAsm
->is_tex
= GL_FALSE
;
482 pAsm
->need_tex_barrier
= GL_FALSE
;
485 pAsm
->unSubArraySize
= 0;
486 pAsm
->unSubArrayPointer
= 0;
487 pAsm
->callers
= NULL
;
488 pAsm
->unCallerArraySize
= 0;
489 pAsm
->unCallerArrayPointer
= 0;
492 pAsm
->CALLSTACK
[0].FCSP_BeforeEntry
;
493 pAsm
->CALLSTACK
[0].plstCFInstructions_local
494 = &(pAsm
->pR700Shader
->lstCFInstructions
);
496 SetActiveCFlist(pAsm
->pR700Shader
, pAsm
->CALLSTACK
[0].plstCFInstructions_local
);
503 GLboolean
IsTex(gl_inst_opcode Opcode
)
505 if( (OPCODE_TEX
==Opcode
) || (OPCODE_TXP
==Opcode
) || (OPCODE_TXB
==Opcode
) )
512 GLboolean
IsAlu(gl_inst_opcode Opcode
)
514 //TODO : more for fc and ex for higher spec.
522 int check_current_clause(r700_AssemblerBase
* pAsm
,
523 CF_CLAUSE_TYPE new_clause_type
)
525 if (pAsm
->cf_current_clause_type
!= new_clause_type
)
526 { //Close last open clause
527 switch (pAsm
->cf_current_clause_type
)
530 if ( pAsm
->cf_current_alu_clause_ptr
!= NULL
)
532 pAsm
->cf_current_alu_clause_ptr
= NULL
;
536 if ( pAsm
->cf_current_vtx_clause_ptr
!= NULL
)
538 pAsm
->cf_current_vtx_clause_ptr
= NULL
;
542 if ( pAsm
->cf_current_tex_clause_ptr
!= NULL
)
544 pAsm
->cf_current_tex_clause_ptr
= NULL
;
547 case CF_EXPORT_CLAUSE
:
548 if ( pAsm
->cf_current_export_clause_ptr
!= NULL
)
550 pAsm
->cf_current_export_clause_ptr
= NULL
;
553 case CF_OTHER_CLAUSE
:
554 if ( pAsm
->cf_current_cf_clause_ptr
!= NULL
)
556 pAsm
->cf_current_cf_clause_ptr
= NULL
;
559 case CF_EMPTY_CLAUSE
:
563 "Unknown CF_CLAUSE_TYPE (%d) in check_current_clause. \n", (int) new_clause_type
);
567 pAsm
->cf_current_clause_type
= CF_EMPTY_CLAUSE
;
570 switch (new_clause_type
)
573 pAsm
->cf_current_clause_type
= CF_ALU_CLAUSE
;
576 pAsm
->cf_current_clause_type
= CF_VTX_CLAUSE
;
579 pAsm
->cf_current_clause_type
= CF_TEX_CLAUSE
;
581 case CF_EXPORT_CLAUSE
:
583 R700ControlFlowSXClause
* pR700ControlFlowSXClause
584 = (R700ControlFlowSXClause
*) CALLOC_STRUCT(R700ControlFlowSXClause
);
586 // Add new export instruction to control flow program
587 if (pR700ControlFlowSXClause
!= 0)
589 pAsm
->cf_current_export_clause_ptr
= pR700ControlFlowSXClause
;
590 Init_R700ControlFlowSXClause(pR700ControlFlowSXClause
);
591 AddCFInstruction( pAsm
->pR700Shader
,
592 (R700ControlFlowInstruction
*)pR700ControlFlowSXClause
);
597 "Error allocating new EXPORT CF instruction in check_current_clause. \n");
600 pAsm
->cf_current_clause_type
= CF_EXPORT_CLAUSE
;
603 case CF_EMPTY_CLAUSE
:
605 case CF_OTHER_CLAUSE
:
606 pAsm
->cf_current_clause_type
= CF_OTHER_CLAUSE
;
610 "Unknown CF_CLAUSE_TYPE (%d) in check_current_clause. \n", (int) new_clause_type
);
618 GLboolean
add_cf_instruction(r700_AssemblerBase
* pAsm
)
620 if(GL_FALSE
== check_current_clause(pAsm
, CF_OTHER_CLAUSE
))
625 pAsm
->cf_current_cf_clause_ptr
=
626 (R700ControlFlowGenericClause
*) CALLOC_STRUCT(R700ControlFlowGenericClause
);
628 if (pAsm
->cf_current_cf_clause_ptr
!= NULL
)
630 Init_R700ControlFlowGenericClause(pAsm
->cf_current_cf_clause_ptr
);
631 AddCFInstruction( pAsm
->pR700Shader
,
632 (R700ControlFlowInstruction
*)pAsm
->cf_current_cf_clause_ptr
);
636 radeon_error("Could not allocate a new VFetch CF instruction.\n");
643 GLboolean
add_vfetch_instruction(r700_AssemblerBase
* pAsm
,
644 R700VertexInstruction
* vertex_instruction_ptr
)
646 if( GL_FALSE
== check_current_clause(pAsm
, CF_VTX_CLAUSE
) )
651 if( pAsm
->cf_current_vtx_clause_ptr
== NULL
||
652 ( (pAsm
->cf_current_vtx_clause_ptr
!= NULL
) &&
653 (pAsm
->cf_current_vtx_clause_ptr
->m_Word1
.f
.count
>= GetCFMaxInstructions(pAsm
->cf_current_vtx_clause_ptr
->m_ShaderInstType
)-1)
656 // Create new Vfetch control flow instruction for this new clause
657 pAsm
->cf_current_vtx_clause_ptr
= (R700ControlFlowGenericClause
*) CALLOC_STRUCT(R700ControlFlowGenericClause
);
659 if (pAsm
->cf_current_vtx_clause_ptr
!= NULL
)
661 Init_R700ControlFlowGenericClause(pAsm
->cf_current_vtx_clause_ptr
);
662 AddCFInstruction( pAsm
->pR700Shader
,
663 (R700ControlFlowInstruction
*)pAsm
->cf_current_vtx_clause_ptr
);
667 radeon_error("Could not allocate a new VFetch CF instruction.\n");
671 pAsm
->cf_current_vtx_clause_ptr
->m_Word1
.f
.pop_count
= 0x0;
672 pAsm
->cf_current_vtx_clause_ptr
->m_Word1
.f
.cf_const
= 0x0;
673 pAsm
->cf_current_vtx_clause_ptr
->m_Word1
.f
.cond
= SQ_CF_COND_ACTIVE
;
674 pAsm
->cf_current_vtx_clause_ptr
->m_Word1
.f
.count
= 0x0;
675 pAsm
->cf_current_vtx_clause_ptr
->m_Word1
.f
.end_of_program
= 0x0;
676 pAsm
->cf_current_vtx_clause_ptr
->m_Word1
.f
.valid_pixel_mode
= 0x0;
677 pAsm
->cf_current_vtx_clause_ptr
->m_Word1
.f
.cf_inst
= SQ_CF_INST_VTX
;
678 pAsm
->cf_current_vtx_clause_ptr
->m_Word1
.f
.whole_quad_mode
= 0x0;
679 pAsm
->cf_current_vtx_clause_ptr
->m_Word1
.f
.barrier
= 0x1;
681 LinkVertexInstruction(pAsm
->cf_current_vtx_clause_ptr
, vertex_instruction_ptr
);
685 pAsm
->cf_current_vtx_clause_ptr
->m_Word1
.f
.count
++;
688 AddVTXInstruction(pAsm
->pR700Shader
, vertex_instruction_ptr
);
693 GLboolean
add_tex_instruction(r700_AssemblerBase
* pAsm
,
694 R700TextureInstruction
* tex_instruction_ptr
)
696 if ( GL_FALSE
== check_current_clause(pAsm
, CF_TEX_CLAUSE
) )
701 if ( pAsm
->cf_current_tex_clause_ptr
== NULL
||
702 ( (pAsm
->cf_current_tex_clause_ptr
!= NULL
) &&
703 (pAsm
->cf_current_tex_clause_ptr
->m_Word1
.f
.count
>= GetCFMaxInstructions(pAsm
->cf_current_tex_clause_ptr
->m_ShaderInstType
)-1)
706 // new tex cf instruction for this new clause
707 pAsm
->cf_current_tex_clause_ptr
= (R700ControlFlowGenericClause
*) CALLOC_STRUCT(R700ControlFlowGenericClause
);
709 if (pAsm
->cf_current_tex_clause_ptr
!= NULL
)
711 Init_R700ControlFlowGenericClause(pAsm
->cf_current_tex_clause_ptr
);
712 AddCFInstruction( pAsm
->pR700Shader
,
713 (R700ControlFlowInstruction
*)pAsm
->cf_current_tex_clause_ptr
);
717 radeon_error("Could not allocate a new TEX CF instruction.\n");
721 pAsm
->cf_current_tex_clause_ptr
->m_Word1
.f
.pop_count
= 0x0;
722 pAsm
->cf_current_tex_clause_ptr
->m_Word1
.f
.cf_const
= 0x0;
723 pAsm
->cf_current_tex_clause_ptr
->m_Word1
.f
.cond
= SQ_CF_COND_ACTIVE
;
725 pAsm
->cf_current_tex_clause_ptr
->m_Word1
.f
.end_of_program
= 0x0;
726 pAsm
->cf_current_tex_clause_ptr
->m_Word1
.f
.valid_pixel_mode
= 0x0;
727 pAsm
->cf_current_tex_clause_ptr
->m_Word1
.f
.cf_inst
= SQ_CF_INST_TEX
;
728 pAsm
->cf_current_tex_clause_ptr
->m_Word1
.f
.whole_quad_mode
= 0x0;
729 pAsm
->cf_current_tex_clause_ptr
->m_Word1
.f
.barrier
= 0x0; //0x1;
733 pAsm
->cf_current_tex_clause_ptr
->m_Word1
.f
.count
++;
736 // If this clause constains any TEX instruction that is dependent on a previous instruction,
737 // set the barrier bit
738 if( pAsm
->pInstDeps
[pAsm
->uiCurInst
].nDstDep
> (-1) || pAsm
->need_tex_barrier
== GL_TRUE
)
740 pAsm
->cf_current_tex_clause_ptr
->m_Word1
.f
.barrier
= 0x1;
743 if(NULL
== pAsm
->cf_current_tex_clause_ptr
->m_pLinkedTEXInstruction
)
745 pAsm
->cf_current_tex_clause_ptr
->m_pLinkedTEXInstruction
= tex_instruction_ptr
;
746 tex_instruction_ptr
->m_pLinkedGenericClause
= pAsm
->cf_current_tex_clause_ptr
;
749 AddTEXInstruction(pAsm
->pR700Shader
, tex_instruction_ptr
);
754 GLboolean
assemble_vfetch_instruction(r700_AssemblerBase
* pAsm
,
756 GLuint destination_register
,
757 GLuint number_of_elements
,
758 GLenum dataElementType
,
759 VTX_FETCH_METHOD
* pFetchMethod
)
761 GLuint client_size_inbyte
;
763 GLuint mega_fetch_count
;
764 GLuint is_mega_fetch_flag
;
766 R700VertexGenericFetch
* vfetch_instruction_ptr
;
767 R700VertexGenericFetch
* assembled_vfetch_instruction_ptr
= pAsm
->vfetch_instruction_ptr_array
[ gl_client_id
];
769 if (assembled_vfetch_instruction_ptr
== NULL
)
771 vfetch_instruction_ptr
= (R700VertexGenericFetch
*) CALLOC_STRUCT(R700VertexGenericFetch
);
772 if (vfetch_instruction_ptr
== NULL
)
776 Init_R700VertexGenericFetch(vfetch_instruction_ptr
);
780 vfetch_instruction_ptr
= assembled_vfetch_instruction_ptr
;
783 data_format
= GetSurfaceFormat(dataElementType
, number_of_elements
, &client_size_inbyte
);
785 if(GL_TRUE
== pFetchMethod
->bEnableMini
) //More conditions here
791 mega_fetch_count
= MEGA_FETCH_BYTES
- 1;
792 is_mega_fetch_flag
= 0x1;
793 pFetchMethod
->mega_fetch_remainder
= MEGA_FETCH_BYTES
- client_size_inbyte
;
796 vfetch_instruction_ptr
->m_Word0
.f
.vtx_inst
= SQ_VTX_INST_FETCH
;
797 vfetch_instruction_ptr
->m_Word0
.f
.fetch_type
= SQ_VTX_FETCH_VERTEX_DATA
;
798 vfetch_instruction_ptr
->m_Word0
.f
.fetch_whole_quad
= 0x0;
800 vfetch_instruction_ptr
->m_Word0
.f
.buffer_id
= gl_client_id
;
801 vfetch_instruction_ptr
->m_Word0
.f
.src_gpr
= 0x0;
802 vfetch_instruction_ptr
->m_Word0
.f
.src_rel
= SQ_ABSOLUTE
;
803 vfetch_instruction_ptr
->m_Word0
.f
.src_sel_x
= SQ_SEL_X
;
804 vfetch_instruction_ptr
->m_Word0
.f
.mega_fetch_count
= mega_fetch_count
;
806 vfetch_instruction_ptr
->m_Word1
.f
.dst_sel_x
= (number_of_elements
< 1) ? SQ_SEL_0
: SQ_SEL_X
;
807 vfetch_instruction_ptr
->m_Word1
.f
.dst_sel_y
= (number_of_elements
< 2) ? SQ_SEL_0
: SQ_SEL_Y
;
808 vfetch_instruction_ptr
->m_Word1
.f
.dst_sel_z
= (number_of_elements
< 3) ? SQ_SEL_0
: SQ_SEL_Z
;
809 vfetch_instruction_ptr
->m_Word1
.f
.dst_sel_w
= (number_of_elements
< 4) ? SQ_SEL_1
: SQ_SEL_W
;
811 vfetch_instruction_ptr
->m_Word1
.f
.use_const_fields
= 1;
813 // Destination register
814 vfetch_instruction_ptr
->m_Word1_GPR
.f
.dst_gpr
= destination_register
;
815 vfetch_instruction_ptr
->m_Word1_GPR
.f
.dst_rel
= SQ_ABSOLUTE
;
817 vfetch_instruction_ptr
->m_Word2
.f
.offset
= 0;
818 vfetch_instruction_ptr
->m_Word2
.f
.const_buf_no_stride
= 0x0;
820 vfetch_instruction_ptr
->m_Word2
.f
.mega_fetch
= is_mega_fetch_flag
;
822 if (assembled_vfetch_instruction_ptr
== NULL
)
824 if ( GL_FALSE
== add_vfetch_instruction(pAsm
, (R700VertexInstruction
*)vfetch_instruction_ptr
) )
829 if (pAsm
->vfetch_instruction_ptr_array
[ gl_client_id
] != NULL
)
835 pAsm
->vfetch_instruction_ptr_array
[ gl_client_id
] = vfetch_instruction_ptr
;
842 GLboolean
assemble_vfetch_instruction2(r700_AssemblerBase
* pAsm
,
843 GLuint destination_register
,
849 VTX_FETCH_METHOD
* pFetchMethod
)
851 GLuint client_size_inbyte
;
853 GLuint mega_fetch_count
;
854 GLuint is_mega_fetch_flag
;
856 R700VertexGenericFetch
* vfetch_instruction_ptr
;
857 R700VertexGenericFetch
* assembled_vfetch_instruction_ptr
858 = pAsm
->vfetch_instruction_ptr_array
[element
];
860 if (assembled_vfetch_instruction_ptr
== NULL
)
862 vfetch_instruction_ptr
= (R700VertexGenericFetch
*) CALLOC_STRUCT(R700VertexGenericFetch
);
863 if (vfetch_instruction_ptr
== NULL
)
867 Init_R700VertexGenericFetch(vfetch_instruction_ptr
);
871 vfetch_instruction_ptr
= assembled_vfetch_instruction_ptr
;
874 data_format
= GetSurfaceFormat(type
, size
, &client_size_inbyte
);
876 if(GL_TRUE
== pFetchMethod
->bEnableMini
) //More conditions here
882 mega_fetch_count
= MEGA_FETCH_BYTES
- 1;
883 is_mega_fetch_flag
= 0x1;
884 pFetchMethod
->mega_fetch_remainder
= MEGA_FETCH_BYTES
- client_size_inbyte
;
887 vfetch_instruction_ptr
->m_Word0
.f
.vtx_inst
= SQ_VTX_INST_FETCH
;
888 vfetch_instruction_ptr
->m_Word0
.f
.fetch_type
= SQ_VTX_FETCH_VERTEX_DATA
;
889 vfetch_instruction_ptr
->m_Word0
.f
.fetch_whole_quad
= 0x0;
891 vfetch_instruction_ptr
->m_Word0
.f
.buffer_id
= element
;
892 vfetch_instruction_ptr
->m_Word0
.f
.src_gpr
= 0x0;
893 vfetch_instruction_ptr
->m_Word0
.f
.src_rel
= SQ_ABSOLUTE
;
894 vfetch_instruction_ptr
->m_Word0
.f
.src_sel_x
= SQ_SEL_X
;
895 vfetch_instruction_ptr
->m_Word0
.f
.mega_fetch_count
= mega_fetch_count
;
897 vfetch_instruction_ptr
->m_Word1
.f
.dst_sel_x
= (size
< 1) ? SQ_SEL_0
: SQ_SEL_X
;
898 vfetch_instruction_ptr
->m_Word1
.f
.dst_sel_y
= (size
< 2) ? SQ_SEL_0
: SQ_SEL_Y
;
899 vfetch_instruction_ptr
->m_Word1
.f
.dst_sel_z
= (size
< 3) ? SQ_SEL_0
: SQ_SEL_Z
;
900 vfetch_instruction_ptr
->m_Word1
.f
.dst_sel_w
= (size
< 4) ? SQ_SEL_1
: SQ_SEL_W
;
902 vfetch_instruction_ptr
->m_Word1
.f
.use_const_fields
= 1;
903 vfetch_instruction_ptr
->m_Word1
.f
.data_format
= data_format
;
904 vfetch_instruction_ptr
->m_Word2
.f
.endian_swap
= SQ_ENDIAN_NONE
;
908 vfetch_instruction_ptr
->m_Word1
.f
.format_comp_all
= SQ_FORMAT_COMP_SIGNED
;
912 vfetch_instruction_ptr
->m_Word1
.f
.format_comp_all
= SQ_FORMAT_COMP_UNSIGNED
;
915 if(GL_TRUE
== normalize
)
917 vfetch_instruction_ptr
->m_Word1
.f
.num_format_all
= SQ_NUM_FORMAT_NORM
;
921 vfetch_instruction_ptr
->m_Word1
.f
.num_format_all
= SQ_NUM_FORMAT_INT
;
924 // Destination register
925 vfetch_instruction_ptr
->m_Word1_GPR
.f
.dst_gpr
= destination_register
;
926 vfetch_instruction_ptr
->m_Word1_GPR
.f
.dst_rel
= SQ_ABSOLUTE
;
928 vfetch_instruction_ptr
->m_Word2
.f
.offset
= 0;
929 vfetch_instruction_ptr
->m_Word2
.f
.const_buf_no_stride
= 0x0;
931 vfetch_instruction_ptr
->m_Word2
.f
.mega_fetch
= is_mega_fetch_flag
;
933 if (assembled_vfetch_instruction_ptr
== NULL
)
935 if ( GL_FALSE
== add_vfetch_instruction(pAsm
, (R700VertexInstruction
*)vfetch_instruction_ptr
) )
940 if (pAsm
->vfetch_instruction_ptr_array
[element
] != NULL
)
946 pAsm
->vfetch_instruction_ptr_array
[element
] = vfetch_instruction_ptr
;
953 GLboolean
cleanup_vfetch_instructions(r700_AssemblerBase
* pAsm
)
956 pAsm
->cf_current_clause_type
= CF_EMPTY_CLAUSE
;
957 pAsm
->cf_current_vtx_clause_ptr
= NULL
;
959 for (i
=0; i
<VERT_ATTRIB_MAX
; i
++)
961 pAsm
->vfetch_instruction_ptr_array
[ i
] = NULL
;
964 cleanup_vfetch_shaderinst(pAsm
->pR700Shader
);
969 GLuint
gethelpr(r700_AssemblerBase
* pAsm
)
971 GLuint r
= pAsm
->uHelpReg
;
973 if (pAsm
->uHelpReg
> pAsm
->number_used_registers
)
975 pAsm
->number_used_registers
= pAsm
->uHelpReg
;
979 void resethelpr(r700_AssemblerBase
* pAsm
)
981 pAsm
->uHelpReg
= pAsm
->uFirstHelpReg
;
984 void checkop_init(r700_AssemblerBase
* pAsm
)
990 pAsm
->aArgSubst
[3] = -1;
993 GLboolean
mov_temp(r700_AssemblerBase
* pAsm
, int src
)
995 GLuint tmp
= gethelpr(pAsm
);
997 //mov src to temp helper gpr.
998 pAsm
->D
.dst
.opcode
= SQ_OP2_INST_MOV
;
1000 setaddrmode_PVSDST(&(pAsm
->D
.dst
), ADDR_ABSOLUTE
);
1002 pAsm
->D
.dst
.rtype
= DST_REG_TEMPORARY
;
1003 pAsm
->D
.dst
.reg
= tmp
;
1005 nomask_PVSDST(&(pAsm
->D
.dst
));
1007 if( GL_FALSE
== assemble_src(pAsm
, src
, 0) )
1012 noswizzle_PVSSRC(&(pAsm
->S
[0].src
));
1013 noneg_PVSSRC(&(pAsm
->S
[0].src
));
1015 if( GL_FALSE
== next_ins(pAsm
) )
1020 pAsm
->aArgSubst
[1 + src
] = tmp
;
1025 GLboolean
checkop1(r700_AssemblerBase
* pAsm
)
1031 GLboolean
checkop2(r700_AssemblerBase
* pAsm
)
1033 GLboolean bSrcConst
[2];
1034 struct prog_instruction
*pILInst
= &(pAsm
->pILInst
[pAsm
->uiCurInst
]);
1038 if( (pILInst
->SrcReg
[0].File
== PROGRAM_CONSTANT
) ||
1039 (pILInst
->SrcReg
[0].File
== PROGRAM_LOCAL_PARAM
) ||
1040 (pILInst
->SrcReg
[0].File
== PROGRAM_ENV_PARAM
) ||
1041 (pILInst
->SrcReg
[0].File
== PROGRAM_STATE_VAR
) )
1043 bSrcConst
[0] = GL_TRUE
;
1047 bSrcConst
[0] = GL_FALSE
;
1049 if( (pILInst
->SrcReg
[1].File
== PROGRAM_CONSTANT
) ||
1050 (pILInst
->SrcReg
[1].File
== PROGRAM_LOCAL_PARAM
) ||
1051 (pILInst
->SrcReg
[1].File
== PROGRAM_ENV_PARAM
) ||
1052 (pILInst
->SrcReg
[1].File
== PROGRAM_STATE_VAR
) )
1054 bSrcConst
[1] = GL_TRUE
;
1058 bSrcConst
[1] = GL_FALSE
;
1061 if( (bSrcConst
[0] == GL_TRUE
) && (bSrcConst
[1] == GL_TRUE
) )
1063 if(pILInst
->SrcReg
[0].Index
!= pILInst
->SrcReg
[1].Index
)
1065 if( GL_FALSE
== mov_temp(pAsm
, 1) )
1075 GLboolean
checkop3(r700_AssemblerBase
* pAsm
)
1077 GLboolean bSrcConst
[3];
1078 struct prog_instruction
*pILInst
= &(pAsm
->pILInst
[pAsm
->uiCurInst
]);
1082 if( (pILInst
->SrcReg
[0].File
== PROGRAM_CONSTANT
) ||
1083 (pILInst
->SrcReg
[0].File
== PROGRAM_LOCAL_PARAM
) ||
1084 (pILInst
->SrcReg
[0].File
== PROGRAM_ENV_PARAM
) ||
1085 (pILInst
->SrcReg
[0].File
== PROGRAM_STATE_VAR
) )
1087 bSrcConst
[0] = GL_TRUE
;
1091 bSrcConst
[0] = GL_FALSE
;
1093 if( (pILInst
->SrcReg
[1].File
== PROGRAM_CONSTANT
) ||
1094 (pILInst
->SrcReg
[1].File
== PROGRAM_LOCAL_PARAM
) ||
1095 (pILInst
->SrcReg
[1].File
== PROGRAM_ENV_PARAM
) ||
1096 (pILInst
->SrcReg
[1].File
== PROGRAM_STATE_VAR
) )
1098 bSrcConst
[1] = GL_TRUE
;
1102 bSrcConst
[1] = GL_FALSE
;
1104 if( (pILInst
->SrcReg
[2].File
== PROGRAM_CONSTANT
) ||
1105 (pILInst
->SrcReg
[2].File
== PROGRAM_LOCAL_PARAM
) ||
1106 (pILInst
->SrcReg
[2].File
== PROGRAM_ENV_PARAM
) ||
1107 (pILInst
->SrcReg
[2].File
== PROGRAM_STATE_VAR
) )
1109 bSrcConst
[2] = GL_TRUE
;
1113 bSrcConst
[2] = GL_FALSE
;
1116 if( (GL_TRUE
== bSrcConst
[0]) &&
1117 (GL_TRUE
== bSrcConst
[1]) &&
1118 (GL_TRUE
== bSrcConst
[2]) )
1120 if( GL_FALSE
== mov_temp(pAsm
, 1) )
1124 if( GL_FALSE
== mov_temp(pAsm
, 2) )
1131 else if( (GL_TRUE
== bSrcConst
[0]) &&
1132 (GL_TRUE
== bSrcConst
[1]) )
1134 if(pILInst
->SrcReg
[0].Index
!= pILInst
->SrcReg
[1].Index
)
1136 if( GL_FALSE
== mov_temp(pAsm
, 1) )
1144 else if ( (GL_TRUE
== bSrcConst
[0]) &&
1145 (GL_TRUE
== bSrcConst
[2]) )
1147 if(pILInst
->SrcReg
[0].Index
!= pILInst
->SrcReg
[2].Index
)
1149 if( GL_FALSE
== mov_temp(pAsm
, 2) )
1157 else if( (GL_TRUE
== bSrcConst
[1]) &&
1158 (GL_TRUE
== bSrcConst
[2]) )
1160 if(pILInst
->SrcReg
[1].Index
!= pILInst
->SrcReg
[2].Index
)
1162 if( GL_FALSE
== mov_temp(pAsm
, 2) )
1174 GLboolean
assemble_src(r700_AssemblerBase
*pAsm
,
1178 struct prog_instruction
*pILInst
= &(pAsm
->pILInst
[pAsm
->uiCurInst
]);
1185 if(pAsm
->aArgSubst
[1+src
] >= 0)
1187 setaddrmode_PVSSRC(&(pAsm
->S
[fld
].src
), ADDR_ABSOLUTE
);
1188 pAsm
->S
[fld
].src
.rtype
= SRC_REG_TEMPORARY
;
1189 pAsm
->S
[fld
].src
.reg
= pAsm
->aArgSubst
[1+src
];
1193 switch (pILInst
->SrcReg
[src
].File
)
1195 case PROGRAM_TEMPORARY
:
1196 setaddrmode_PVSSRC(&(pAsm
->S
[fld
].src
), ADDR_ABSOLUTE
);
1197 pAsm
->S
[fld
].src
.rtype
= SRC_REG_TEMPORARY
;
1198 pAsm
->S
[fld
].src
.reg
= pILInst
->SrcReg
[src
].Index
+ pAsm
->starting_temp_register_number
;
1200 case PROGRAM_CONSTANT
:
1201 case PROGRAM_LOCAL_PARAM
:
1202 case PROGRAM_ENV_PARAM
:
1203 case PROGRAM_STATE_VAR
:
1204 case PROGRAM_UNIFORM
:
1205 if (1 == pILInst
->SrcReg
[src
].RelAddr
)
1207 setaddrmode_PVSSRC(&(pAsm
->S
[fld
].src
), ADDR_RELATIVE_A0
);
1211 setaddrmode_PVSSRC(&(pAsm
->S
[fld
].src
), ADDR_ABSOLUTE
);
1214 pAsm
->S
[fld
].src
.rtype
= SRC_REG_CONSTANT
;
1215 pAsm
->S
[fld
].src
.reg
= pILInst
->SrcReg
[src
].Index
;
1218 setaddrmode_PVSSRC(&(pAsm
->S
[fld
].src
), ADDR_ABSOLUTE
);
1219 pAsm
->S
[fld
].src
.rtype
= SRC_REG_INPUT
;
1220 switch (pAsm
->currentShaderType
)
1223 pAsm
->S
[fld
].src
.reg
= pAsm
->uiFP_AttributeMap
[pILInst
->SrcReg
[src
].Index
];
1226 pAsm
->S
[fld
].src
.reg
= pAsm
->ucVP_AttributeMap
[pILInst
->SrcReg
[src
].Index
];
1231 radeon_error("Invalid source argument type : %d \n", pILInst
->SrcReg
[src
].File
);
1236 pAsm
->S
[fld
].src
.swizzlex
= pILInst
->SrcReg
[src
].Swizzle
& 0x7;
1237 pAsm
->S
[fld
].src
.swizzley
= (pILInst
->SrcReg
[src
].Swizzle
>> 3) & 0x7;
1238 pAsm
->S
[fld
].src
.swizzlez
= (pILInst
->SrcReg
[src
].Swizzle
>> 6) & 0x7;
1239 pAsm
->S
[fld
].src
.swizzlew
= (pILInst
->SrcReg
[src
].Swizzle
>> 9) & 0x7;
1241 pAsm
->S
[fld
].src
.negx
= pILInst
->SrcReg
[src
].Negate
& 0x1;
1242 pAsm
->S
[fld
].src
.negy
= (pILInst
->SrcReg
[src
].Negate
>> 1) & 0x1;
1243 pAsm
->S
[fld
].src
.negz
= (pILInst
->SrcReg
[src
].Negate
>> 2) & 0x1;
1244 pAsm
->S
[fld
].src
.negw
= (pILInst
->SrcReg
[src
].Negate
>> 3) & 0x1;
1249 GLboolean
assemble_dst(r700_AssemblerBase
*pAsm
)
1251 struct prog_instruction
*pILInst
= &(pAsm
->pILInst
[pAsm
->uiCurInst
]);
1252 switch (pILInst
->DstReg
.File
)
1254 case PROGRAM_TEMPORARY
:
1255 setaddrmode_PVSDST(&(pAsm
->D
.dst
), ADDR_ABSOLUTE
);
1256 pAsm
->D
.dst
.rtype
= DST_REG_TEMPORARY
;
1257 pAsm
->D
.dst
.reg
= pILInst
->DstReg
.Index
+ pAsm
->starting_temp_register_number
;
1259 case PROGRAM_ADDRESS
:
1260 setaddrmode_PVSDST(&(pAsm
->D
.dst
), ADDR_ABSOLUTE
);
1261 pAsm
->D
.dst
.rtype
= DST_REG_A0
;
1262 pAsm
->D
.dst
.reg
= 0;
1264 case PROGRAM_OUTPUT
:
1265 setaddrmode_PVSDST(&(pAsm
->D
.dst
), ADDR_ABSOLUTE
);
1266 pAsm
->D
.dst
.rtype
= DST_REG_OUT
;
1267 switch (pAsm
->currentShaderType
)
1270 pAsm
->D
.dst
.reg
= pAsm
->uiFP_OutputMap
[pILInst
->DstReg
.Index
];
1273 pAsm
->D
.dst
.reg
= pAsm
->ucVP_OutputMap
[pILInst
->DstReg
.Index
];
1278 radeon_error("Invalid destination output argument type\n");
1282 pAsm
->D
.dst
.writex
= pILInst
->DstReg
.WriteMask
& 0x1;
1283 pAsm
->D
.dst
.writey
= (pILInst
->DstReg
.WriteMask
>> 1) & 0x1;
1284 pAsm
->D
.dst
.writez
= (pILInst
->DstReg
.WriteMask
>> 2) & 0x1;
1285 pAsm
->D
.dst
.writew
= (pILInst
->DstReg
.WriteMask
>> 3) & 0x1;
1290 GLboolean
tex_dst(r700_AssemblerBase
*pAsm
)
1292 struct prog_instruction
*pILInst
= &(pAsm
->pILInst
[pAsm
->uiCurInst
]);
1294 if(PROGRAM_TEMPORARY
== pILInst
->DstReg
.File
)
1296 pAsm
->D
.dst
.rtype
= DST_REG_TEMPORARY
;
1297 pAsm
->D
.dst
.reg
= pAsm
->pILInst
[pAsm
->uiCurInst
].DstReg
.Index
+ pAsm
->starting_temp_register_number
;
1299 setaddrmode_PVSDST(&(pAsm
->D
.dst
), ADDR_ABSOLUTE
);
1301 else if(PROGRAM_OUTPUT
== pILInst
->DstReg
.File
)
1303 pAsm
->D
.dst
.rtype
= DST_REG_OUT
;
1304 switch (pAsm
->currentShaderType
)
1307 pAsm
->D
.dst
.reg
= pAsm
->uiFP_OutputMap
[pILInst
->DstReg
.Index
];
1310 pAsm
->D
.dst
.reg
= pAsm
->ucVP_OutputMap
[pILInst
->DstReg
.Index
];
1314 setaddrmode_PVSDST(&(pAsm
->D
.dst
), ADDR_ABSOLUTE
);
1318 radeon_error("Invalid destination output argument type\n");
1322 pAsm
->D
.dst
.writex
= pILInst
->DstReg
.WriteMask
& 0x1;
1323 pAsm
->D
.dst
.writey
= (pILInst
->DstReg
.WriteMask
>> 1) & 0x1;
1324 pAsm
->D
.dst
.writez
= (pILInst
->DstReg
.WriteMask
>> 2) & 0x1;
1325 pAsm
->D
.dst
.writew
= (pILInst
->DstReg
.WriteMask
>> 3) & 0x1;
1330 GLboolean
tex_src(r700_AssemblerBase
*pAsm
)
1332 struct prog_instruction
*pILInst
= &(pAsm
->pILInst
[pAsm
->uiCurInst
]);
1334 GLboolean bValidTexCoord
= GL_FALSE
;
1336 if(pAsm
->aArgSubst
[1] >= 0)
1338 bValidTexCoord
= GL_TRUE
;
1339 setaddrmode_PVSSRC(&(pAsm
->S
[0].src
), ADDR_ABSOLUTE
);
1340 pAsm
->S
[0].src
.rtype
= SRC_REG_TEMPORARY
;
1341 pAsm
->S
[0].src
.reg
= pAsm
->aArgSubst
[1];
1345 switch (pILInst
->SrcReg
[0].File
) {
1346 case PROGRAM_CONSTANT
:
1347 case PROGRAM_LOCAL_PARAM
:
1348 case PROGRAM_ENV_PARAM
:
1349 case PROGRAM_STATE_VAR
:
1351 case PROGRAM_TEMPORARY
:
1352 bValidTexCoord
= GL_TRUE
;
1353 pAsm
->S
[0].src
.reg
= pILInst
->SrcReg
[0].Index
+
1354 pAsm
->starting_temp_register_number
;
1355 pAsm
->S
[0].src
.rtype
= SRC_REG_TEMPORARY
;
1358 switch (pILInst
->SrcReg
[0].Index
)
1360 case FRAG_ATTRIB_WPOS
:
1361 case FRAG_ATTRIB_COL0
:
1362 case FRAG_ATTRIB_COL1
:
1363 case FRAG_ATTRIB_FOGC
:
1364 case FRAG_ATTRIB_TEX0
:
1365 case FRAG_ATTRIB_TEX1
:
1366 case FRAG_ATTRIB_TEX2
:
1367 case FRAG_ATTRIB_TEX3
:
1368 case FRAG_ATTRIB_TEX4
:
1369 case FRAG_ATTRIB_TEX5
:
1370 case FRAG_ATTRIB_TEX6
:
1371 case FRAG_ATTRIB_TEX7
:
1372 bValidTexCoord
= GL_TRUE
;
1373 pAsm
->S
[0].src
.reg
=
1374 pAsm
->uiFP_AttributeMap
[pILInst
->SrcReg
[0].Index
];
1375 pAsm
->S
[0].src
.rtype
= SRC_REG_INPUT
;
1377 case FRAG_ATTRIB_FACE
:
1378 fprintf(stderr
, "FRAG_ATTRIB_FACE unsupported\n");
1380 case FRAG_ATTRIB_PNTC
:
1381 fprintf(stderr
, "FRAG_ATTRIB_PNTC unsupported\n");
1383 case FRAG_ATTRIB_VAR0
:
1384 fprintf(stderr
, "FRAG_ATTRIB_VAR0 unsupported\n");
1388 if( (pILInst
->SrcReg
[0].Index
>= FRAG_ATTRIB_VAR0
) ||
1389 (pILInst
->SrcReg
[0].Index
< FRAG_ATTRIB_MAX
) )
1391 bValidTexCoord
= GL_TRUE
;
1392 pAsm
->S
[0].src
.reg
=
1393 pAsm
->uiFP_AttributeMap
[pILInst
->SrcReg
[0].Index
];
1394 pAsm
->S
[0].src
.rtype
= SRC_REG_INPUT
;
1401 if(GL_TRUE
== bValidTexCoord
)
1403 setaddrmode_PVSSRC(&(pAsm
->S
[0].src
), ADDR_ABSOLUTE
);
1407 radeon_error("Invalid source texcoord for TEX instruction\n");
1411 pAsm
->S
[0].src
.swizzlex
= pILInst
->SrcReg
[0].Swizzle
& 0x7;
1412 pAsm
->S
[0].src
.swizzley
= (pILInst
->SrcReg
[0].Swizzle
>> 3) & 0x7;
1413 pAsm
->S
[0].src
.swizzlez
= (pILInst
->SrcReg
[0].Swizzle
>> 6) & 0x7;
1414 pAsm
->S
[0].src
.swizzlew
= (pILInst
->SrcReg
[0].Swizzle
>> 9) & 0x7;
1416 pAsm
->S
[0].src
.negx
= pILInst
->SrcReg
[0].Negate
& 0x1;
1417 pAsm
->S
[0].src
.negy
= (pILInst
->SrcReg
[0].Negate
>> 1) & 0x1;
1418 pAsm
->S
[0].src
.negz
= (pILInst
->SrcReg
[0].Negate
>> 2) & 0x1;
1419 pAsm
->S
[0].src
.negw
= (pILInst
->SrcReg
[0].Negate
>> 3) & 0x1;
1424 GLboolean
assemble_tex_instruction(r700_AssemblerBase
*pAsm
, GLboolean normalized
)
1426 PVSSRC
* texture_coordinate_source
;
1427 PVSSRC
* texture_unit_source
;
1429 R700TextureInstruction
* tex_instruction_ptr
= (R700TextureInstruction
*) CALLOC_STRUCT(R700TextureInstruction
);
1430 if (tex_instruction_ptr
== NULL
)
1434 Init_R700TextureInstruction(tex_instruction_ptr
);
1436 texture_coordinate_source
= &(pAsm
->S
[0].src
);
1437 texture_unit_source
= &(pAsm
->S
[1].src
);
1439 tex_instruction_ptr
->m_Word0
.f
.tex_inst
= pAsm
->D
.dst
.opcode
;
1440 tex_instruction_ptr
->m_Word0
.f
.bc_frac_mode
= 0x0;
1441 tex_instruction_ptr
->m_Word0
.f
.fetch_whole_quad
= 0x0;
1443 tex_instruction_ptr
->m_Word0
.f
.resource_id
= texture_unit_source
->reg
;
1445 tex_instruction_ptr
->m_Word1
.f
.lod_bias
= 0x0;
1447 tex_instruction_ptr
->m_Word1
.f
.coord_type_x
= SQ_TEX_NORMALIZED
;
1448 tex_instruction_ptr
->m_Word1
.f
.coord_type_y
= SQ_TEX_NORMALIZED
;
1449 tex_instruction_ptr
->m_Word1
.f
.coord_type_z
= SQ_TEX_NORMALIZED
;
1450 tex_instruction_ptr
->m_Word1
.f
.coord_type_w
= SQ_TEX_NORMALIZED
;
1452 /* XXX: UNNORMALIZED tex coords have limited wrap modes */
1453 tex_instruction_ptr
->m_Word1
.f
.coord_type_x
= SQ_TEX_UNNORMALIZED
;
1454 tex_instruction_ptr
->m_Word1
.f
.coord_type_y
= SQ_TEX_UNNORMALIZED
;
1455 tex_instruction_ptr
->m_Word1
.f
.coord_type_z
= SQ_TEX_UNNORMALIZED
;
1456 tex_instruction_ptr
->m_Word1
.f
.coord_type_w
= SQ_TEX_UNNORMALIZED
;
1459 tex_instruction_ptr
->m_Word2
.f
.offset_x
= 0x0;
1460 tex_instruction_ptr
->m_Word2
.f
.offset_y
= 0x0;
1461 tex_instruction_ptr
->m_Word2
.f
.offset_z
= 0x0;
1463 tex_instruction_ptr
->m_Word2
.f
.sampler_id
= texture_unit_source
->reg
;
1466 if ( (pAsm
->D
.dst
.rtype
== DST_REG_TEMPORARY
) ||
1467 (pAsm
->D
.dst
.rtype
== DST_REG_OUT
) )
1469 tex_instruction_ptr
->m_Word0
.f
.src_gpr
= texture_coordinate_source
->reg
;
1470 tex_instruction_ptr
->m_Word0
.f
.src_rel
= SQ_ABSOLUTE
;
1472 tex_instruction_ptr
->m_Word1
.f
.dst_gpr
= pAsm
->D
.dst
.reg
;
1473 tex_instruction_ptr
->m_Word1
.f
.dst_rel
= SQ_ABSOLUTE
;
1475 tex_instruction_ptr
->m_Word1
.f
.dst_sel_x
= (pAsm
->D
.dst
.writex
? texture_unit_source
->swizzlex
: SQ_SEL_MASK
);
1476 tex_instruction_ptr
->m_Word1
.f
.dst_sel_y
= (pAsm
->D
.dst
.writey
? texture_unit_source
->swizzley
: SQ_SEL_MASK
);
1477 tex_instruction_ptr
->m_Word1
.f
.dst_sel_z
= (pAsm
->D
.dst
.writez
? texture_unit_source
->swizzlez
: SQ_SEL_MASK
);
1478 tex_instruction_ptr
->m_Word1
.f
.dst_sel_w
= (pAsm
->D
.dst
.writew
? texture_unit_source
->swizzlew
: SQ_SEL_MASK
);
1481 tex_instruction_ptr
->m_Word2
.f
.src_sel_x
= texture_coordinate_source
->swizzlex
;
1482 tex_instruction_ptr
->m_Word2
.f
.src_sel_y
= texture_coordinate_source
->swizzley
;
1483 tex_instruction_ptr
->m_Word2
.f
.src_sel_z
= texture_coordinate_source
->swizzlez
;
1484 tex_instruction_ptr
->m_Word2
.f
.src_sel_w
= texture_coordinate_source
->swizzlew
;
1488 radeon_error("Only temp destination registers supported for TEX dest regs.\n");
1492 if( GL_FALSE
== add_tex_instruction(pAsm
, tex_instruction_ptr
) )
1500 void initialize(r700_AssemblerBase
*pAsm
)
1502 GLuint cycle
, component
;
1504 for (cycle
=0; cycle
<NUMBER_OF_CYCLES
; cycle
++)
1506 for (component
=0; component
<NUMBER_OF_COMPONENTS
; component
++)
1508 pAsm
->hw_gpr
[cycle
][component
] = (-1);
1511 for (component
=0; component
<NUMBER_OF_COMPONENTS
; component
++)
1513 pAsm
->hw_cfile_addr
[component
] = (-1);
1514 pAsm
->hw_cfile_chan
[component
] = (-1);
1518 GLboolean
assemble_alu_src(R700ALUInstruction
* alu_instruction_ptr
,
1521 BITS scalar_channel_index
)
1528 //--------------------------------------------------------------------------
1529 // Source for operands src0, src1.
1530 // Values [0,127] correspond to GPR[0..127].
1531 // Values [256,511] correspond to cfile constants c[0..255].
1533 //--------------------------------------------------------------------------
1534 // Other special values are shown in the list below.
1536 // 248 SQ_ALU_SRC_0: special constant 0.0.
1537 // 249 SQ_ALU_SRC_1: special constant 1.0 float.
1539 // 250 SQ_ALU_SRC_1_INT: special constant 1 integer.
1540 // 251 SQ_ALU_SRC_M_1_INT: special constant -1 integer.
1542 // 252 SQ_ALU_SRC_0_5: special constant 0.5 float.
1543 // 253 SQ_ALU_SRC_LITERAL: literal constant.
1545 // 254 SQ_ALU_SRC_PV: previous vector result.
1546 // 255 SQ_ALU_SRC_PS: previous scalar result.
1547 //--------------------------------------------------------------------------
1549 BITS channel_swizzle
;
1550 switch (scalar_channel_index
)
1552 case 0: channel_swizzle
= pSource
->swizzlex
; break;
1553 case 1: channel_swizzle
= pSource
->swizzley
; break;
1554 case 2: channel_swizzle
= pSource
->swizzlez
; break;
1555 case 3: channel_swizzle
= pSource
->swizzlew
; break;
1556 default: channel_swizzle
= SQ_SEL_MASK
; break;
1559 if(channel_swizzle
== SQ_SEL_0
)
1561 src_sel
= SQ_ALU_SRC_0
;
1563 else if (channel_swizzle
== SQ_SEL_1
)
1565 src_sel
= SQ_ALU_SRC_1
;
1569 if ( (pSource
->rtype
== SRC_REG_TEMPORARY
) ||
1570 (pSource
->rtype
== SRC_REG_INPUT
)
1573 src_sel
= pSource
->reg
;
1575 else if (pSource
->rtype
== SRC_REG_CONSTANT
)
1577 src_sel
= pSource
->reg
+ CFILE_REGISTER_OFFSET
;
1579 else if (pSource
->rtype
== SRC_REC_LITERAL
)
1581 src_sel
= SQ_ALU_SRC_LITERAL
;
1585 radeon_error("Source (%d) register type (%d) not one of TEMP, INPUT, or CONSTANT.\n",
1586 source_index
, pSource
->rtype
);
1591 if( ADDR_ABSOLUTE
== addrmode_PVSSRC(pSource
) )
1593 src_rel
= SQ_ABSOLUTE
;
1597 src_rel
= SQ_RELATIVE
;
1600 switch (channel_swizzle
)
1603 src_chan
= SQ_CHAN_X
;
1606 src_chan
= SQ_CHAN_Y
;
1609 src_chan
= SQ_CHAN_Z
;
1612 src_chan
= SQ_CHAN_W
;
1616 // Does not matter since src_sel controls
1617 src_chan
= SQ_CHAN_X
;
1620 radeon_error("Unknown source select value (%d) in assemble_alu_src().\n", channel_swizzle
);
1625 switch (scalar_channel_index
)
1627 case 0: src_neg
= pSource
->negx
; break;
1628 case 1: src_neg
= pSource
->negy
; break;
1629 case 2: src_neg
= pSource
->negz
; break;
1630 case 3: src_neg
= pSource
->negw
; break;
1631 default: src_neg
= 0; break;
1634 switch (source_index
)
1637 alu_instruction_ptr
->m_Word0
.f
.src0_sel
= src_sel
;
1638 alu_instruction_ptr
->m_Word0
.f
.src0_rel
= src_rel
;
1639 alu_instruction_ptr
->m_Word0
.f
.src0_chan
= src_chan
;
1640 alu_instruction_ptr
->m_Word0
.f
.src0_neg
= src_neg
;
1643 alu_instruction_ptr
->m_Word0
.f
.src1_sel
= src_sel
;
1644 alu_instruction_ptr
->m_Word0
.f
.src1_rel
= src_rel
;
1645 alu_instruction_ptr
->m_Word0
.f
.src1_chan
= src_chan
;
1646 alu_instruction_ptr
->m_Word0
.f
.src1_neg
= src_neg
;
1649 alu_instruction_ptr
->m_Word1_OP3
.f
.src2_sel
= src_sel
;
1650 alu_instruction_ptr
->m_Word1_OP3
.f
.src2_rel
= src_rel
;
1651 alu_instruction_ptr
->m_Word1_OP3
.f
.src2_chan
= src_chan
;
1652 alu_instruction_ptr
->m_Word1_OP3
.f
.src2_neg
= src_neg
;
1655 radeon_error("Only three sources allowed in ALU opcodes.\n");
1663 GLboolean
add_alu_instruction(r700_AssemblerBase
* pAsm
,
1664 R700ALUInstruction
* alu_instruction_ptr
,
1665 GLuint contiguous_slots_needed
)
1667 if( GL_FALSE
== check_current_clause(pAsm
, CF_ALU_CLAUSE
) )
1672 if ( pAsm
->alu_x_opcode
!= 0 ||
1673 pAsm
->cf_current_alu_clause_ptr
== NULL
||
1674 ( (pAsm
->cf_current_alu_clause_ptr
!= NULL
) &&
1675 (pAsm
->cf_current_alu_clause_ptr
->m_Word1
.f
.count
>= (GetCFMaxInstructions(pAsm
->cf_current_alu_clause_ptr
->m_ShaderInstType
)-contiguous_slots_needed
-1) )
1679 //new cf inst for this clause
1680 pAsm
->cf_current_alu_clause_ptr
= (R700ControlFlowALUClause
*) CALLOC_STRUCT(R700ControlFlowALUClause
);
1682 // link the new cf to cf segment
1683 if(NULL
!= pAsm
->cf_current_alu_clause_ptr
)
1685 Init_R700ControlFlowALUClause(pAsm
->cf_current_alu_clause_ptr
);
1686 AddCFInstruction( pAsm
->pR700Shader
,
1687 (R700ControlFlowInstruction
*)pAsm
->cf_current_alu_clause_ptr
);
1691 radeon_error("Could not allocate a new ALU CF instruction.\n");
1695 pAsm
->cf_current_alu_clause_ptr
->m_Word0
.f
.kcache_bank0
= 0x0;
1696 pAsm
->cf_current_alu_clause_ptr
->m_Word0
.f
.kcache_bank1
= 0x0;
1697 pAsm
->cf_current_alu_clause_ptr
->m_Word0
.f
.kcache_mode0
= SQ_CF_KCACHE_NOP
;
1699 pAsm
->cf_current_alu_clause_ptr
->m_Word1
.f
.kcache_mode1
= SQ_CF_KCACHE_NOP
;
1700 pAsm
->cf_current_alu_clause_ptr
->m_Word1
.f
.kcache_addr0
= 0x0;
1701 pAsm
->cf_current_alu_clause_ptr
->m_Word1
.f
.kcache_addr1
= 0x0;
1703 pAsm
->cf_current_alu_clause_ptr
->m_Word1
.f
.count
= 0x0;
1705 if(pAsm
->alu_x_opcode
!= 0)
1707 pAsm
->cf_current_alu_clause_ptr
->m_Word1
.f
.cf_inst
= pAsm
->alu_x_opcode
;
1708 pAsm
->alu_x_opcode
= 0;
1712 pAsm
->cf_current_alu_clause_ptr
->m_Word1
.f
.cf_inst
= SQ_CF_INST_ALU
;
1715 pAsm
->cf_current_alu_clause_ptr
->m_Word1
.f
.whole_quad_mode
= 0x0;
1717 pAsm
->cf_current_alu_clause_ptr
->m_Word1
.f
.barrier
= 0x1;
1721 pAsm
->cf_current_alu_clause_ptr
->m_Word1
.f
.count
++;
1724 // If this clause constains any instruction that is forward dependent on a TEX instruction,
1725 // set the whole_quad_mode for this clause
1726 if ( pAsm
->pInstDeps
[pAsm
->uiCurInst
].nDstDep
> (-1) )
1728 pAsm
->cf_current_alu_clause_ptr
->m_Word1
.f
.whole_quad_mode
= 0x1;
1731 if (pAsm
->cf_current_alu_clause_ptr
->m_Word1
.f
.count
>= (GetCFMaxInstructions(pAsm
->cf_current_alu_clause_ptr
->m_ShaderInstType
)-1) )
1733 alu_instruction_ptr
->m_Word0
.f
.last
= 1;
1736 if(NULL
== pAsm
->cf_current_alu_clause_ptr
->m_pLinkedALUInstruction
)
1738 pAsm
->cf_current_alu_clause_ptr
->m_pLinkedALUInstruction
= alu_instruction_ptr
;
1739 alu_instruction_ptr
->m_pLinkedALUClause
= pAsm
->cf_current_alu_clause_ptr
;
1742 AddALUInstruction(pAsm
->pR700Shader
, alu_instruction_ptr
);
1747 void get_src_properties(R700ALUInstruction
* alu_instruction_ptr
,
1754 switch (source_index
)
1757 *psrc_sel
= alu_instruction_ptr
->m_Word0
.f
.src0_sel
;
1758 *psrc_rel
= alu_instruction_ptr
->m_Word0
.f
.src0_rel
;
1759 *psrc_chan
= alu_instruction_ptr
->m_Word0
.f
.src0_chan
;
1760 *psrc_neg
= alu_instruction_ptr
->m_Word0
.f
.src0_neg
;
1764 *psrc_sel
= alu_instruction_ptr
->m_Word0
.f
.src1_sel
;
1765 *psrc_rel
= alu_instruction_ptr
->m_Word0
.f
.src1_rel
;
1766 *psrc_chan
= alu_instruction_ptr
->m_Word0
.f
.src1_chan
;
1767 *psrc_neg
= alu_instruction_ptr
->m_Word0
.f
.src1_neg
;
1771 *psrc_sel
= alu_instruction_ptr
->m_Word1_OP3
.f
.src2_sel
;
1772 *psrc_rel
= alu_instruction_ptr
->m_Word1_OP3
.f
.src2_rel
;
1773 *psrc_chan
= alu_instruction_ptr
->m_Word1_OP3
.f
.src2_chan
;
1774 *psrc_neg
= alu_instruction_ptr
->m_Word1_OP3
.f
.src2_neg
;
1779 int is_cfile(BITS sel
)
1781 if (sel
> 255 && sel
< 512)
1788 int is_const(BITS sel
)
1794 else if(sel
>= SQ_ALU_SRC_0
&& sel
<= SQ_ALU_SRC_LITERAL
)
1801 int is_gpr(BITS sel
)
1803 if (sel
>= 0 && sel
< 128)
1810 const GLuint BANK_SWIZZLE_VEC
[8] = {SQ_ALU_VEC_210
, //000
1811 SQ_ALU_VEC_120
, //001
1812 SQ_ALU_VEC_102
, //010
1814 SQ_ALU_VEC_201
, //011
1815 SQ_ALU_VEC_012
, //100
1816 SQ_ALU_VEC_021
, //101
1818 SQ_ALU_VEC_012
, //110
1819 SQ_ALU_VEC_012
}; //111
1821 const GLuint BANK_SWIZZLE_SCL
[8] = {SQ_ALU_SCL_210
, //000
1822 SQ_ALU_SCL_122
, //001
1823 SQ_ALU_SCL_122
, //010
1825 SQ_ALU_SCL_221
, //011
1826 SQ_ALU_SCL_212
, //100
1827 SQ_ALU_SCL_122
, //101
1829 SQ_ALU_SCL_122
, //110
1830 SQ_ALU_SCL_122
}; //111
1832 GLboolean
reserve_cfile(r700_AssemblerBase
* pAsm
,
1836 int res_match
= (-1);
1837 int res_empty
= (-1);
1841 for (res
=3; res
>=0; res
--)
1843 if(pAsm
->hw_cfile_addr
[ res
] < 0)
1847 else if( (pAsm
->hw_cfile_addr
[res
] == (int)sel
)
1849 (pAsm
->hw_cfile_chan
[ res
] == (int) chan
) )
1857 // Read for this scalar component already reserved, nothing to do here.
1860 else if(res_empty
>= 0)
1862 pAsm
->hw_cfile_addr
[ res_empty
] = sel
;
1863 pAsm
->hw_cfile_chan
[ res_empty
] = chan
;
1867 radeon_error("All cfile read ports are used, cannot reference C$sel, channel $chan.\n");
1873 GLboolean
reserve_gpr(r700_AssemblerBase
* pAsm
, GLuint sel
, GLuint chan
, GLuint cycle
)
1875 if(pAsm
->hw_gpr
[cycle
][chan
] < 0)
1877 pAsm
->hw_gpr
[cycle
][chan
] = sel
;
1879 else if(pAsm
->hw_gpr
[cycle
][chan
] != (int)sel
)
1881 radeon_error("Another scalar operation has already used GPR read port for given channel\n");
1888 GLboolean
cycle_for_scalar_bank_swizzle(const int swiz
, const int sel
, GLuint
* pCycle
)
1892 case SQ_ALU_SCL_210
:
1894 int table
[3] = {2, 1, 0};
1895 *pCycle
= table
[sel
];
1899 case SQ_ALU_SCL_122
:
1901 int table
[3] = {1, 2, 2};
1902 *pCycle
= table
[sel
];
1906 case SQ_ALU_SCL_212
:
1908 int table
[3] = {2, 1, 2};
1909 *pCycle
= table
[sel
];
1913 case SQ_ALU_SCL_221
:
1915 int table
[3] = {2, 2, 1};
1916 *pCycle
= table
[sel
];
1921 radeon_error("Bad Scalar bank swizzle value\n");
1928 GLboolean
cycle_for_vector_bank_swizzle(const int swiz
, const int sel
, GLuint
* pCycle
)
1932 case SQ_ALU_VEC_012
:
1934 int table
[3] = {0, 1, 2};
1935 *pCycle
= table
[sel
];
1938 case SQ_ALU_VEC_021
:
1940 int table
[3] = {0, 2, 1};
1941 *pCycle
= table
[sel
];
1944 case SQ_ALU_VEC_120
:
1946 int table
[3] = {1, 2, 0};
1947 *pCycle
= table
[sel
];
1950 case SQ_ALU_VEC_102
:
1952 int table
[3] = {1, 0, 2};
1953 *pCycle
= table
[sel
];
1956 case SQ_ALU_VEC_201
:
1958 int table
[3] = {2, 0, 1};
1959 *pCycle
= table
[sel
];
1962 case SQ_ALU_VEC_210
:
1964 int table
[3] = {2, 1, 0};
1965 *pCycle
= table
[sel
];
1969 radeon_error("Bad Vec bank swizzle value\n");
1977 GLboolean
check_scalar(r700_AssemblerBase
* pAsm
,
1978 R700ALUInstruction
* alu_instruction_ptr
)
1981 GLuint bank_swizzle
;
1982 GLuint const_count
= 0;
1991 BITS src_sel
[3] = {0,0,0};
1992 BITS src_chan
[3] = {0,0,0};
1993 BITS src_rel
[3] = {0,0,0};
1994 BITS src_neg
[3] = {0,0,0};
1998 GLuint number_of_operands
= r700GetNumOperands(pAsm
);
2000 for (src
=0; src
<number_of_operands
; src
++)
2002 get_src_properties(alu_instruction_ptr
,
2011 swizzle_key
= ( (is_const( src_sel
[0] ) ? 4 : 0) +
2012 (is_const( src_sel
[1] ) ? 2 : 0) +
2013 (is_const( src_sel
[2] ) ? 1 : 0) );
2015 alu_instruction_ptr
->m_Word1
.f
.bank_swizzle
= BANK_SWIZZLE_SCL
[ swizzle_key
];
2017 for (src
=0; src
<number_of_operands
; src
++)
2019 sel
= src_sel
[src
];
2020 chan
= src_chan
[src
];
2021 rel
= src_rel
[src
];
2022 neg
= src_neg
[src
];
2024 if (is_const( sel
))
2026 // Any constant, including literal and inline constants
2029 if (is_cfile( sel
))
2031 reserve_cfile(pAsm
, sel
, chan
);
2037 for (src
=0; src
<number_of_operands
; src
++)
2039 sel
= src_sel
[src
];
2040 chan
= src_chan
[src
];
2041 rel
= src_rel
[src
];
2042 neg
= src_neg
[src
];
2046 bank_swizzle
= alu_instruction_ptr
->m_Word1
.f
.bank_swizzle
;
2048 if( GL_FALSE
== cycle_for_scalar_bank_swizzle(bank_swizzle
, src
, &cycle
) )
2053 if(cycle
< const_count
)
2055 if( GL_FALSE
== reserve_gpr(pAsm
, sel
, chan
, cycle
) )
2066 GLboolean
check_vector(r700_AssemblerBase
* pAsm
,
2067 R700ALUInstruction
* alu_instruction_ptr
)
2070 GLuint bank_swizzle
;
2071 GLuint const_count
= 0;
2080 BITS src_sel
[3] = {0,0,0};
2081 BITS src_chan
[3] = {0,0,0};
2082 BITS src_rel
[3] = {0,0,0};
2083 BITS src_neg
[3] = {0,0,0};
2087 GLuint number_of_operands
= r700GetNumOperands(pAsm
);
2089 for (src
=0; src
<number_of_operands
; src
++)
2091 get_src_properties(alu_instruction_ptr
,
2100 swizzle_key
= ( (is_const( src_sel
[0] ) ? 4 : 0) +
2101 (is_const( src_sel
[1] ) ? 2 : 0) +
2102 (is_const( src_sel
[2] ) ? 1 : 0)
2105 alu_instruction_ptr
->m_Word1
.f
.bank_swizzle
= BANK_SWIZZLE_VEC
[swizzle_key
];
2107 for (src
=0; src
<number_of_operands
; src
++)
2109 sel
= src_sel
[src
];
2110 chan
= src_chan
[src
];
2111 rel
= src_rel
[src
];
2112 neg
= src_neg
[src
];
2115 bank_swizzle
= alu_instruction_ptr
->m_Word1
.f
.bank_swizzle
;
2119 if( GL_FALSE
== cycle_for_vector_bank_swizzle(bank_swizzle
, src
, &cycle
) )
2125 (sel
== src_sel
[0]) &&
2126 (chan
== src_chan
[0]) )
2131 if( GL_FALSE
== reserve_gpr(pAsm
, sel
, chan
, cycle
) )
2137 else if( is_const(sel
) )
2143 if( GL_FALSE
== reserve_cfile(pAsm
, sel
, chan
) )
2154 GLboolean
assemble_alu_instruction(r700_AssemblerBase
*pAsm
)
2156 GLuint number_of_scalar_operations
;
2157 GLboolean is_single_scalar_operation
;
2158 GLuint scalar_channel_index
;
2160 PVSSRC
* pcurrent_source
;
2161 int current_source_index
;
2162 GLuint contiguous_slots_needed
;
2164 GLuint uNumSrc
= r700GetNumOperands(pAsm
);
2165 //GLuint channel_swizzle, j;
2166 //GLuint chan_counter[4] = {0, 0, 0, 0};
2167 //PVSSRC * pSource[3];
2168 GLboolean bSplitInst
= GL_FALSE
;
2170 if (1 == pAsm
->D
.dst
.math
)
2172 is_single_scalar_operation
= GL_TRUE
;
2173 number_of_scalar_operations
= 1;
2177 is_single_scalar_operation
= GL_FALSE
;
2178 number_of_scalar_operations
= 4;
2180 /* current assembler doesn't do more than 1 register per source */
2182 /* check read port, only very preliminary algorithm, not count in
2183 src0/1 same comp case and prev slot repeat case; also not count relative
2184 addressing. TODO: improve performance. */
2185 for(j
=0; j
<uNumSrc
; j
++)
2187 pSource
[j
] = &(pAsm
->S
[j
].src
);
2189 for(scalar_channel_index
=0; scalar_channel_index
<4; scalar_channel_index
++)
2191 for(j
=0; j
<uNumSrc
; j
++)
2193 switch (scalar_channel_index
)
2195 case 0: channel_swizzle
= pSource
[j
]->swizzlex
; break;
2196 case 1: channel_swizzle
= pSource
[j
]->swizzley
; break;
2197 case 2: channel_swizzle
= pSource
[j
]->swizzlez
; break;
2198 case 3: channel_swizzle
= pSource
[j
]->swizzlew
; break;
2199 default: channel_swizzle
= SQ_SEL_MASK
; break;
2201 if ( ((pSource
[j
]->rtype
== SRC_REG_TEMPORARY
) ||
2202 (pSource
[j
]->rtype
== SRC_REG_INPUT
))
2203 && (channel_swizzle
<= SQ_SEL_W
) )
2205 chan_counter
[channel_swizzle
]++;
2209 if( (chan_counter
[SQ_SEL_X
] > 3)
2210 || (chan_counter
[SQ_SEL_Y
] > 3)
2211 || (chan_counter
[SQ_SEL_Z
] > 3)
2212 || (chan_counter
[SQ_SEL_W
] > 3) ) /* each chan bank has only 3 ports. */
2214 bSplitInst
= GL_TRUE
;
2219 contiguous_slots_needed
= 0;
2221 if(GL_TRUE
== is_reduction_opcode(&(pAsm
->D
)) )
2223 contiguous_slots_needed
= 4;
2228 for (scalar_channel_index
=0;
2229 scalar_channel_index
< number_of_scalar_operations
;
2230 scalar_channel_index
++)
2232 R700ALUInstruction
* alu_instruction_ptr
= (R700ALUInstruction
*) CALLOC_STRUCT(R700ALUInstruction
);
2233 if (alu_instruction_ptr
== NULL
)
2237 Init_R700ALUInstruction(alu_instruction_ptr
);
2240 current_source_index
= 0;
2241 pcurrent_source
= &(pAsm
->S
[0].src
);
2243 if (GL_FALSE
== assemble_alu_src(alu_instruction_ptr
,
2244 current_source_index
,
2246 scalar_channel_index
) )
2254 current_source_index
= 1;
2255 pcurrent_source
= &(pAsm
->S
[current_source_index
].src
);
2257 if (GL_FALSE
== assemble_alu_src(alu_instruction_ptr
,
2258 current_source_index
,
2260 scalar_channel_index
) )
2267 alu_instruction_ptr
->m_Word0
.f
.index_mode
= SQ_INDEX_AR_X
;
2269 if( (is_single_scalar_operation
== GL_TRUE
)
2270 || (GL_TRUE
== bSplitInst
) )
2272 alu_instruction_ptr
->m_Word0
.f
.last
= 1;
2276 alu_instruction_ptr
->m_Word0
.f
.last
= (scalar_channel_index
== 3) ? 1 : 0;
2279 alu_instruction_ptr
->m_Word0
.f
.pred_sel
= 0x0;
2280 alu_instruction_ptr
->m_Word1_OP2
.f
.update_pred
= 0x0;
2281 alu_instruction_ptr
->m_Word1_OP2
.f
.update_execute_mask
= 0x0;
2284 if( (pAsm
->D
.dst
.rtype
== DST_REG_TEMPORARY
) ||
2285 (pAsm
->D
.dst
.rtype
== DST_REG_OUT
) )
2287 alu_instruction_ptr
->m_Word1
.f
.dst_gpr
= pAsm
->D
.dst
.reg
;
2291 radeon_error("Only temp destination registers supported for ALU dest regs.\n");
2295 alu_instruction_ptr
->m_Word1
.f
.dst_rel
= SQ_ABSOLUTE
; //D.rtype
2297 if ( is_single_scalar_operation
== GL_TRUE
)
2299 // Override scalar_channel_index since only one scalar value will be written
2300 if(pAsm
->D
.dst
.writex
)
2302 scalar_channel_index
= 0;
2304 else if(pAsm
->D
.dst
.writey
)
2306 scalar_channel_index
= 1;
2308 else if(pAsm
->D
.dst
.writez
)
2310 scalar_channel_index
= 2;
2312 else if(pAsm
->D
.dst
.writew
)
2314 scalar_channel_index
= 3;
2318 alu_instruction_ptr
->m_Word1
.f
.dst_chan
= scalar_channel_index
;
2320 alu_instruction_ptr
->m_Word1
.f
.clamp
= pAsm
->pILInst
[pAsm
->uiCurInst
].SaturateMode
;
2322 if (pAsm
->D
.dst
.op3
)
2326 alu_instruction_ptr
->m_Word1_OP3
.f
.alu_inst
= pAsm
->D
.dst
.opcode
;
2328 //There's 3rd src for op3
2329 current_source_index
= 2;
2330 pcurrent_source
= &(pAsm
->S
[current_source_index
].src
);
2332 if ( GL_FALSE
== assemble_alu_src(alu_instruction_ptr
,
2333 current_source_index
,
2335 scalar_channel_index
) )
2345 alu_instruction_ptr
->m_Word1_OP2
.f6
.alu_inst
= pAsm
->D
.dst
.opcode
;
2347 alu_instruction_ptr
->m_Word1_OP2
.f6
.src0_abs
= 0x0;
2348 alu_instruction_ptr
->m_Word1_OP2
.f6
.src1_abs
= 0x0;
2350 //alu_instruction_ptr->m_Word1_OP2.f6.update_execute_mask = 0x0;
2351 //alu_instruction_ptr->m_Word1_OP2.f6.update_pred = 0x0;
2352 switch (scalar_channel_index
)
2355 alu_instruction_ptr
->m_Word1_OP2
.f6
.write_mask
= pAsm
->D
.dst
.writex
;
2358 alu_instruction_ptr
->m_Word1_OP2
.f6
.write_mask
= pAsm
->D
.dst
.writey
;
2361 alu_instruction_ptr
->m_Word1_OP2
.f6
.write_mask
= pAsm
->D
.dst
.writez
;
2364 alu_instruction_ptr
->m_Word1_OP2
.f6
.write_mask
= pAsm
->D
.dst
.writew
;
2367 alu_instruction_ptr
->m_Word1_OP2
.f6
.write_mask
= 1; //SQ_SEL_MASK;
2370 alu_instruction_ptr
->m_Word1_OP2
.f6
.omod
= SQ_ALU_OMOD_OFF
;
2374 alu_instruction_ptr
->m_Word1_OP2
.f
.alu_inst
= pAsm
->D
.dst
.opcode
;
2376 alu_instruction_ptr
->m_Word1_OP2
.f
.src0_abs
= 0x0;
2377 alu_instruction_ptr
->m_Word1_OP2
.f
.src1_abs
= 0x0;
2379 //alu_instruction_ptr->m_Word1_OP2.f.update_execute_mask = 0x0;
2380 //alu_instruction_ptr->m_Word1_OP2.f.update_pred = 0x0;
2381 switch (scalar_channel_index
)
2384 alu_instruction_ptr
->m_Word1_OP2
.f
.write_mask
= pAsm
->D
.dst
.writex
;
2387 alu_instruction_ptr
->m_Word1_OP2
.f
.write_mask
= pAsm
->D
.dst
.writey
;
2390 alu_instruction_ptr
->m_Word1_OP2
.f
.write_mask
= pAsm
->D
.dst
.writez
;
2393 alu_instruction_ptr
->m_Word1_OP2
.f
.write_mask
= pAsm
->D
.dst
.writew
;
2396 alu_instruction_ptr
->m_Word1_OP2
.f
.write_mask
= 1; //SQ_SEL_MASK;
2399 alu_instruction_ptr
->m_Word1_OP2
.f
.omod
= SQ_ALU_OMOD_OFF
;
2403 if(GL_FALSE
== add_alu_instruction(pAsm
, alu_instruction_ptr
, contiguous_slots_needed
) )
2409 * Judge the type of current instruction, is it vector or scalar
2412 if (is_single_scalar_operation
)
2414 if(GL_FALSE
== check_scalar(pAsm
, alu_instruction_ptr
) )
2421 if(GL_FALSE
== check_vector(pAsm
, alu_instruction_ptr
) )
2427 contiguous_slots_needed
= 0;
2433 GLboolean
assemble_alu_instruction2(r700_AssemblerBase
*pAsm
)
2435 GLuint number_of_scalar_operations
;
2436 GLboolean is_single_scalar_operation
;
2437 GLuint scalar_channel_index
;
2439 PVSSRC
* pcurrent_source
;
2440 int current_source_index
;
2441 GLuint contiguous_slots_needed
;
2443 GLuint uNumSrc
= r700GetNumOperands(pAsm
);
2445 GLboolean bSplitInst
= GL_FALSE
;
2447 if (1 == pAsm
->D
.dst
.math
)
2449 is_single_scalar_operation
= GL_TRUE
;
2450 number_of_scalar_operations
= 1;
2454 is_single_scalar_operation
= GL_FALSE
;
2455 number_of_scalar_operations
= 4;
2458 contiguous_slots_needed
= 0;
2460 if(GL_TRUE
== is_reduction_opcode(&(pAsm
->D
)) )
2462 contiguous_slots_needed
= 4;
2467 for (scalar_channel_index
=0;
2468 scalar_channel_index
< number_of_scalar_operations
;
2469 scalar_channel_index
++)
2471 R700ALUInstruction
* alu_instruction_ptr
= (R700ALUInstruction
*) CALLOC_STRUCT(R700ALUInstruction
);
2472 if (alu_instruction_ptr
== NULL
)
2476 Init_R700ALUInstruction(alu_instruction_ptr
);
2479 current_source_index
= 0;
2480 pcurrent_source
= &(pAsm
->S
[0].src
);
2482 if (GL_FALSE
== assemble_alu_src(alu_instruction_ptr
,
2483 current_source_index
,
2485 scalar_channel_index
) )
2493 current_source_index
= 1;
2494 pcurrent_source
= &(pAsm
->S
[current_source_index
].src
);
2496 if (GL_FALSE
== assemble_alu_src(alu_instruction_ptr
,
2497 current_source_index
,
2499 scalar_channel_index
) )
2506 alu_instruction_ptr
->m_Word0
.f
.index_mode
= SQ_INDEX_LOOP
;
2508 if( (is_single_scalar_operation
== GL_TRUE
)
2509 || (GL_TRUE
== bSplitInst
) )
2511 alu_instruction_ptr
->m_Word0
.f
.last
= 1;
2515 alu_instruction_ptr
->m_Word0
.f
.last
= (scalar_channel_index
== 3) ? 1 : 0;
2518 alu_instruction_ptr
->m_Word0
.f
.pred_sel
= (pAsm
->D
.dst
.pred_inv
> 0) ? 1 : 0;
2519 if(1 == pAsm
->D
.dst
.predicated
)
2521 alu_instruction_ptr
->m_Word1_OP2
.f
.update_pred
= 0x1;
2522 alu_instruction_ptr
->m_Word1_OP2
.f
.update_execute_mask
= 0x1;
2526 alu_instruction_ptr
->m_Word1_OP2
.f
.update_pred
= 0x0;
2527 alu_instruction_ptr
->m_Word1_OP2
.f
.update_execute_mask
= 0x0;
2531 if( (pAsm
->D
.dst
.rtype
== DST_REG_TEMPORARY
) ||
2532 (pAsm
->D
.dst
.rtype
== DST_REG_OUT
) )
2534 alu_instruction_ptr
->m_Word1
.f
.dst_gpr
= pAsm
->D
.dst
.reg
;
2538 radeon_error("Only temp destination registers supported for ALU dest regs.\n");
2542 alu_instruction_ptr
->m_Word1
.f
.dst_rel
= SQ_ABSOLUTE
; //D.rtype
2544 if ( is_single_scalar_operation
== GL_TRUE
)
2546 // Override scalar_channel_index since only one scalar value will be written
2547 if(pAsm
->D
.dst
.writex
)
2549 scalar_channel_index
= 0;
2551 else if(pAsm
->D
.dst
.writey
)
2553 scalar_channel_index
= 1;
2555 else if(pAsm
->D
.dst
.writez
)
2557 scalar_channel_index
= 2;
2559 else if(pAsm
->D
.dst
.writew
)
2561 scalar_channel_index
= 3;
2565 alu_instruction_ptr
->m_Word1
.f
.dst_chan
= scalar_channel_index
;
2567 alu_instruction_ptr
->m_Word1
.f
.clamp
= pAsm
->D2
.dst2
.SaturateMode
;
2569 if (pAsm
->D
.dst
.op3
)
2573 alu_instruction_ptr
->m_Word1_OP3
.f
.alu_inst
= pAsm
->D
.dst
.opcode
;
2575 //There's 3rd src for op3
2576 current_source_index
= 2;
2577 pcurrent_source
= &(pAsm
->S
[current_source_index
].src
);
2579 if ( GL_FALSE
== assemble_alu_src(alu_instruction_ptr
,
2580 current_source_index
,
2582 scalar_channel_index
) )
2592 alu_instruction_ptr
->m_Word1_OP2
.f6
.alu_inst
= pAsm
->D
.dst
.opcode
;
2594 alu_instruction_ptr
->m_Word1_OP2
.f6
.src0_abs
= 0x0;
2595 alu_instruction_ptr
->m_Word1_OP2
.f6
.src1_abs
= 0x0;
2597 //alu_instruction_ptr->m_Word1_OP2.f6.update_execute_mask = 0x0;
2598 //alu_instruction_ptr->m_Word1_OP2.f6.update_pred = 0x0;
2599 switch (scalar_channel_index
)
2602 alu_instruction_ptr
->m_Word1_OP2
.f6
.write_mask
= pAsm
->D
.dst
.writex
;
2605 alu_instruction_ptr
->m_Word1_OP2
.f6
.write_mask
= pAsm
->D
.dst
.writey
;
2608 alu_instruction_ptr
->m_Word1_OP2
.f6
.write_mask
= pAsm
->D
.dst
.writez
;
2611 alu_instruction_ptr
->m_Word1_OP2
.f6
.write_mask
= pAsm
->D
.dst
.writew
;
2614 alu_instruction_ptr
->m_Word1_OP2
.f6
.write_mask
= 1; //SQ_SEL_MASK;
2617 alu_instruction_ptr
->m_Word1_OP2
.f6
.omod
= SQ_ALU_OMOD_OFF
;
2621 alu_instruction_ptr
->m_Word1_OP2
.f
.alu_inst
= pAsm
->D
.dst
.opcode
;
2623 alu_instruction_ptr
->m_Word1_OP2
.f
.src0_abs
= 0x0;
2624 alu_instruction_ptr
->m_Word1_OP2
.f
.src1_abs
= 0x0;
2626 //alu_instruction_ptr->m_Word1_OP2.f.update_execute_mask = 0x0;
2627 //alu_instruction_ptr->m_Word1_OP2.f.update_pred = 0x0;
2628 switch (scalar_channel_index
)
2631 alu_instruction_ptr
->m_Word1_OP2
.f
.write_mask
= pAsm
->D
.dst
.writex
;
2634 alu_instruction_ptr
->m_Word1_OP2
.f
.write_mask
= pAsm
->D
.dst
.writey
;
2637 alu_instruction_ptr
->m_Word1_OP2
.f
.write_mask
= pAsm
->D
.dst
.writez
;
2640 alu_instruction_ptr
->m_Word1_OP2
.f
.write_mask
= pAsm
->D
.dst
.writew
;
2643 alu_instruction_ptr
->m_Word1_OP2
.f
.write_mask
= 1; //SQ_SEL_MASK;
2646 alu_instruction_ptr
->m_Word1_OP2
.f
.omod
= SQ_ALU_OMOD_OFF
;
2650 if(GL_FALSE
== add_alu_instruction(pAsm
, alu_instruction_ptr
, contiguous_slots_needed
) )
2656 * Judge the type of current instruction, is it vector or scalar
2659 if (is_single_scalar_operation
)
2661 if(GL_FALSE
== check_scalar(pAsm
, alu_instruction_ptr
) )
2668 if(GL_FALSE
== check_vector(pAsm
, alu_instruction_ptr
) )
2674 contiguous_slots_needed
= 0;
2680 GLboolean
assemble_alu_instruction_literal(r700_AssemblerBase
*pAsm
, GLfloat
* pLiteral
)
2682 R700ALUInstruction
* alu_instruction_ptr
;
2683 R700ALUInstructionHalfLiteral
* alu_instruction_ptr_hl
;
2684 R700ALUInstructionFullLiteral
* alu_instruction_ptr_fl
;
2686 GLuint number_of_scalar_operations
;
2687 GLboolean is_single_scalar_operation
;
2688 GLuint scalar_channel_index
;
2690 GLuint contiguous_slots_needed
;
2691 GLuint lastInstruction
;
2692 GLuint not_masked
[4];
2694 GLuint uNumSrc
= r700GetNumOperands(pAsm
);
2696 GLboolean bSplitInst
= GL_FALSE
;
2698 number_of_scalar_operations
= 0;
2699 contiguous_slots_needed
= 0;
2701 if(1 == pAsm
->D
.dst
.writew
)
2703 lastInstruction
= 3;
2704 number_of_scalar_operations
++;
2711 if(1 == pAsm
->D
.dst
.writez
)
2713 lastInstruction
= 2;
2714 number_of_scalar_operations
++;
2721 if(1 == pAsm
->D
.dst
.writey
)
2723 lastInstruction
= 1;
2724 number_of_scalar_operations
++;
2731 if(1 == pAsm
->D
.dst
.writex
)
2733 lastInstruction
= 0;
2734 number_of_scalar_operations
++;
2742 if(GL_TRUE
== is_reduction_opcode(&(pAsm
->D
)) )
2744 contiguous_slots_needed
= 4;
2748 contiguous_slots_needed
= number_of_scalar_operations
;
2751 if(1 == pAsm
->D2
.dst2
.literal
)
2753 contiguous_slots_needed
+= 1;
2755 else if(2 == pAsm
->D2
.dst2
.literal
)
2757 contiguous_slots_needed
+= 2;
2762 for (scalar_channel_index
=0; scalar_channel_index
< 4; scalar_channel_index
++)
2764 if(0 == not_masked
[scalar_channel_index
])
2769 if(scalar_channel_index
== lastInstruction
)
2771 switch (pAsm
->D2
.dst2
.literal
)
2774 alu_instruction_ptr
= (R700ALUInstruction
*) CALLOC_STRUCT(R700ALUInstruction
);
2775 if (alu_instruction_ptr
== NULL
)
2779 Init_R700ALUInstruction(alu_instruction_ptr
);
2782 alu_instruction_ptr_hl
= (R700ALUInstructionHalfLiteral
*) CALLOC_STRUCT(R700ALUInstructionHalfLiteral
);
2783 if (alu_instruction_ptr_hl
== NULL
)
2787 Init_R700ALUInstructionHalfLiteral(alu_instruction_ptr_hl
, pLiteral
[0], pLiteral
[1]);
2788 alu_instruction_ptr
= (R700ALUInstruction
*)alu_instruction_ptr_hl
;
2791 alu_instruction_ptr_fl
= (R700ALUInstructionFullLiteral
*) CALLOC_STRUCT(R700ALUInstructionFullLiteral
);
2792 if (alu_instruction_ptr_fl
== NULL
)
2796 Init_R700ALUInstructionFullLiteral(alu_instruction_ptr_fl
, pLiteral
[0], pLiteral
[1], pLiteral
[2], pLiteral
[3]);
2797 alu_instruction_ptr
= (R700ALUInstruction
*)alu_instruction_ptr_fl
;
2805 alu_instruction_ptr
= (R700ALUInstruction
*) CALLOC_STRUCT(R700ALUInstruction
);
2806 if (alu_instruction_ptr
== NULL
)
2810 Init_R700ALUInstruction(alu_instruction_ptr
);
2814 if (GL_FALSE
== assemble_alu_src(alu_instruction_ptr
,
2817 scalar_channel_index
) )
2825 if (GL_FALSE
== assemble_alu_src(alu_instruction_ptr
,
2828 scalar_channel_index
) )
2835 alu_instruction_ptr
->m_Word0
.f
.index_mode
= SQ_INDEX_LOOP
;
2837 if(scalar_channel_index
== lastInstruction
)
2839 alu_instruction_ptr
->m_Word0
.f
.last
= 1;
2842 alu_instruction_ptr
->m_Word0
.f
.pred_sel
= 0x0;
2843 if(1 == pAsm
->D
.dst
.predicated
)
2845 alu_instruction_ptr
->m_Word1_OP2
.f
.update_pred
= 0x1;
2846 alu_instruction_ptr
->m_Word1_OP2
.f
.update_execute_mask
= 0x1;
2850 alu_instruction_ptr
->m_Word1_OP2
.f
.update_pred
= 0;
2851 alu_instruction_ptr
->m_Word1_OP2
.f
.update_execute_mask
= 0;
2855 if( (pAsm
->D
.dst
.rtype
== DST_REG_TEMPORARY
) ||
2856 (pAsm
->D
.dst
.rtype
== DST_REG_OUT
) )
2858 alu_instruction_ptr
->m_Word1
.f
.dst_gpr
= pAsm
->D
.dst
.reg
;
2862 radeon_error("Only temp destination registers supported for ALU dest regs.\n");
2866 alu_instruction_ptr
->m_Word1
.f
.dst_rel
= SQ_ABSOLUTE
; //D.rtype
2868 alu_instruction_ptr
->m_Word1
.f
.dst_chan
= scalar_channel_index
;
2870 alu_instruction_ptr
->m_Word1
.f
.clamp
= pAsm
->D2
.dst2
.SaturateMode
;
2872 if (pAsm
->D
.dst
.op3
)
2875 alu_instruction_ptr
->m_Word1_OP3
.f
.alu_inst
= pAsm
->D
.dst
.opcode
;
2877 //There's 3rd src for op3
2878 if ( GL_FALSE
== assemble_alu_src(alu_instruction_ptr
,
2881 scalar_channel_index
) )
2891 alu_instruction_ptr
->m_Word1_OP2
.f6
.alu_inst
= pAsm
->D
.dst
.opcode
;
2892 alu_instruction_ptr
->m_Word1_OP2
.f6
.src0_abs
= 0x0;
2893 alu_instruction_ptr
->m_Word1_OP2
.f6
.src1_abs
= 0x0;
2894 alu_instruction_ptr
->m_Word1_OP2
.f6
.write_mask
= 1;
2895 alu_instruction_ptr
->m_Word1_OP2
.f6
.omod
= SQ_ALU_OMOD_OFF
;
2899 alu_instruction_ptr
->m_Word1_OP2
.f
.alu_inst
= pAsm
->D
.dst
.opcode
;
2900 alu_instruction_ptr
->m_Word1_OP2
.f
.src0_abs
= 0x0;
2901 alu_instruction_ptr
->m_Word1_OP2
.f
.src1_abs
= 0x0;
2902 alu_instruction_ptr
->m_Word1_OP2
.f
.write_mask
= 1;
2903 alu_instruction_ptr
->m_Word1_OP2
.f
.omod
= SQ_ALU_OMOD_OFF
;
2907 if(GL_FALSE
== add_alu_instruction(pAsm
, alu_instruction_ptr
, contiguous_slots_needed
) )
2912 if (1 == number_of_scalar_operations
)
2914 if(GL_FALSE
== check_scalar(pAsm
, alu_instruction_ptr
) )
2921 if(GL_FALSE
== check_vector(pAsm
, alu_instruction_ptr
) )
2927 contiguous_slots_needed
-= 2;
2933 GLboolean
next_ins(r700_AssemblerBase
*pAsm
)
2935 struct prog_instruction
*pILInst
= &(pAsm
->pILInst
[pAsm
->uiCurInst
]);
2937 if( GL_TRUE
== pAsm
->is_tex
)
2939 if (pILInst
->TexSrcTarget
== TEXTURE_RECT_INDEX
) {
2940 if( GL_FALSE
== assemble_tex_instruction(pAsm
, GL_FALSE
) )
2942 radeon_error("Error assembling TEX instruction\n");
2946 if( GL_FALSE
== assemble_tex_instruction(pAsm
, GL_TRUE
) )
2948 radeon_error("Error assembling TEX instruction\n");
2955 if( GL_FALSE
== assemble_alu_instruction(pAsm
) )
2957 radeon_error("Error assembling ALU instruction\n");
2962 if(pAsm
->D
.dst
.rtype
== DST_REG_OUT
)
2966 // There is no mask for OP3 instructions, so all channels are written
2967 pAsm
->pucOutMask
[pAsm
->D
.dst
.reg
- pAsm
->starting_export_register_number
] = 0xF;
2971 pAsm
->pucOutMask
[pAsm
->D
.dst
.reg
- pAsm
->starting_export_register_number
]
2972 |= (unsigned char)pAsm
->pILInst
[pAsm
->uiCurInst
].DstReg
.WriteMask
;
2976 //reset for next inst.
2979 pAsm
->S
[0].bits
= 0;
2980 pAsm
->S
[1].bits
= 0;
2981 pAsm
->S
[2].bits
= 0;
2982 pAsm
->is_tex
= GL_FALSE
;
2983 pAsm
->need_tex_barrier
= GL_FALSE
;
2988 GLboolean
next_ins2(r700_AssemblerBase
*pAsm
)
2990 struct prog_instruction
*pILInst
= &(pAsm
->pILInst
[pAsm
->uiCurInst
]);
2993 if( GL_FALSE
== assemble_alu_instruction2(pAsm
) )
2995 radeon_error("Error assembling ALU instruction\n");
2999 if(pAsm
->D
.dst
.rtype
== DST_REG_OUT
)
3003 // There is no mask for OP3 instructions, so all channels are written
3004 pAsm
->pucOutMask
[pAsm
->D
.dst
.reg
- pAsm
->starting_export_register_number
] = 0xF;
3008 pAsm
->pucOutMask
[pAsm
->D
.dst
.reg
- pAsm
->starting_export_register_number
]
3009 |= (unsigned char)pAsm
->pILInst
[pAsm
->uiCurInst
].DstReg
.WriteMask
;
3013 //reset for next inst.
3016 pAsm
->S
[0].bits
= 0;
3017 pAsm
->S
[1].bits
= 0;
3018 pAsm
->S
[2].bits
= 0;
3019 pAsm
->is_tex
= GL_FALSE
;
3020 pAsm
->need_tex_barrier
= GL_FALSE
;
3022 //richard nov.16 glsl
3029 GLboolean
next_ins_literal(r700_AssemblerBase
*pAsm
, GLfloat
* pLiteral
)
3031 struct prog_instruction
*pILInst
= &(pAsm
->pILInst
[pAsm
->uiCurInst
]);
3034 if( GL_FALSE
== assemble_alu_instruction_literal(pAsm
, pLiteral
) )
3036 radeon_error("Error assembling ALU instruction\n");
3040 //reset for next inst.
3043 pAsm
->S
[0].bits
= 0;
3044 pAsm
->S
[1].bits
= 0;
3045 pAsm
->S
[2].bits
= 0;
3046 pAsm
->is_tex
= GL_FALSE
;
3047 pAsm
->need_tex_barrier
= GL_FALSE
;
3051 GLboolean
assemble_math_function(r700_AssemblerBase
* pAsm
, BITS opcode
)
3057 tmp
= gethelpr(pAsm
);
3059 // opcode tmp.x, a.x
3062 pAsm
->D
.dst
.opcode
= opcode
;
3063 pAsm
->D
.dst
.math
= 1;
3065 setaddrmode_PVSDST(&(pAsm
->D
.dst
), ADDR_ABSOLUTE
);
3066 pAsm
->D
.dst
.rtype
= DST_REG_TEMPORARY
;
3067 pAsm
->D
.dst
.reg
= tmp
;
3068 pAsm
->D
.dst
.writex
= 1;
3070 if( GL_FALSE
== assemble_src(pAsm
, 0, -1) )
3075 if ( GL_FALSE
== next_ins(pAsm
) )
3080 // Now replicate result to all necessary channels in destination
3081 pAsm
->D
.dst
.opcode
= SQ_OP2_INST_MOV
;
3083 if( GL_FALSE
== assemble_dst(pAsm
) )
3088 setaddrmode_PVSSRC(&(pAsm
->S
[0].src
), ADDR_ABSOLUTE
);
3089 pAsm
->S
[0].src
.rtype
= DST_REG_TEMPORARY
;
3090 pAsm
->S
[0].src
.reg
= tmp
;
3092 setswizzle_PVSSRC(&(pAsm
->S
[0].src
), SQ_SEL_X
);
3093 noneg_PVSSRC(&(pAsm
->S
[0].src
));
3095 if( GL_FALSE
== next_ins(pAsm
) )
3103 GLboolean
assemble_ABS(r700_AssemblerBase
*pAsm
)
3107 pAsm
->D
.dst
.opcode
= SQ_OP2_INST_MAX
;
3109 if( GL_FALSE
== assemble_dst(pAsm
) )
3113 if( GL_FALSE
== assemble_src(pAsm
, 0, -1) )
3118 pAsm
->S
[1].bits
= pAsm
->S
[0].bits
;
3119 flipneg_PVSSRC(&(pAsm
->S
[1].src
));
3121 if ( GL_FALSE
== next_ins(pAsm
) )
3129 GLboolean
assemble_ADD(r700_AssemblerBase
*pAsm
)
3131 if( GL_FALSE
== checkop2(pAsm
) )
3136 pAsm
->D
.dst
.opcode
= SQ_OP2_INST_ADD
;
3138 if( GL_FALSE
== assemble_dst(pAsm
) )
3143 if( GL_FALSE
== assemble_src(pAsm
, 0, -1) )
3148 if( GL_FALSE
== assemble_src(pAsm
, 1, -1) )
3153 if(pAsm
->pILInst
[pAsm
->uiCurInst
].Opcode
== OPCODE_SUB
)
3155 flipneg_PVSSRC(&(pAsm
->S
[1].src
));
3158 if( GL_FALSE
== next_ins(pAsm
) )
3166 GLboolean
assemble_ARL(r700_AssemblerBase
*pAsm
)
3167 { /* TODO: ar values dont' persist between clauses */
3168 if( GL_FALSE
== checkop1(pAsm
) )
3173 pAsm
->D
.dst
.opcode
= SQ_OP2_INST_MOVA_FLOOR
;
3174 setaddrmode_PVSDST(&(pAsm
->D
.dst
), ADDR_ABSOLUTE
);
3175 pAsm
->D
.dst
.rtype
= DST_REG_TEMPORARY
;
3176 pAsm
->D
.dst
.reg
= 0;
3177 pAsm
->D
.dst
.writex
= 0;
3178 pAsm
->D
.dst
.writey
= 0;
3179 pAsm
->D
.dst
.writez
= 0;
3180 pAsm
->D
.dst
.writew
= 0;
3182 if( GL_FALSE
== assemble_src(pAsm
, 0, -1) )
3187 if( GL_FALSE
== next_ins(pAsm
) )
3195 GLboolean
assemble_BAD(char *opcode_str
)
3197 radeon_error("Not yet implemented instruction (%s)\n", opcode_str
);
3201 GLboolean
assemble_CMP(r700_AssemblerBase
*pAsm
)
3205 if( GL_FALSE
== checkop3(pAsm
) )
3210 pAsm
->D
.dst
.opcode
= SQ_OP3_INST_CNDGE
;
3211 pAsm
->D
.dst
.op3
= 1;
3215 if(0xF != pAsm
->pILInst
[pAsm
->uiCurInst
].DstReg
.WriteMask
)
3217 //OP3 has no support for write mask
3218 tmp
= gethelpr(pAsm
);
3220 setaddrmode_PVSDST(&(pAsm
->D
.dst
), ADDR_ABSOLUTE
);
3221 pAsm
->D
.dst
.rtype
= DST_REG_TEMPORARY
;
3222 pAsm
->D
.dst
.reg
= tmp
;
3224 nomask_PVSDST(&(pAsm
->D
.dst
));
3228 if( GL_FALSE
== assemble_dst(pAsm
) )
3234 if( GL_FALSE
== assemble_src(pAsm
, 0, -1) )
3239 if( GL_FALSE
== assemble_src(pAsm
, 2, 1) )
3244 if( GL_FALSE
== assemble_src(pAsm
, 1, 2) )
3249 if ( GL_FALSE
== next_ins(pAsm
) )
3254 if (0xF != pAsm
->pILInst
[pAsm
->uiCurInst
].DstReg
.WriteMask
)
3256 if( GL_FALSE
== assemble_dst(pAsm
) )
3261 pAsm
->D
.dst
.opcode
= SQ_OP2_INST_MOV
;
3264 setaddrmode_PVSSRC(&(pAsm
->S
[0].src
), ADDR_ABSOLUTE
);
3265 pAsm
->S
[0].src
.rtype
= SRC_REG_TEMPORARY
;
3266 pAsm
->S
[0].src
.reg
= tmp
;
3268 noneg_PVSSRC(&(pAsm
->S
[0].src
));
3269 noswizzle_PVSSRC(&(pAsm
->S
[0].src
));
3271 if( GL_FALSE
== next_ins(pAsm
) )
3280 GLboolean
assemble_COS(r700_AssemblerBase
*pAsm
)
3282 return assemble_math_function(pAsm
, SQ_OP2_INST_COS
);
3285 GLboolean
assemble_DOT(r700_AssemblerBase
*pAsm
)
3287 if( GL_FALSE
== checkop2(pAsm
) )
3292 pAsm
->D
.dst
.opcode
= SQ_OP2_INST_DOT4
;
3294 if( GL_FALSE
== assemble_dst(pAsm
) )
3299 if( GL_FALSE
== assemble_src(pAsm
, 0, -1) )
3304 if( GL_FALSE
== assemble_src(pAsm
, 1, -1) )
3309 if(OPCODE_DP3
== pAsm
->pILInst
[pAsm
->uiCurInst
].Opcode
)
3311 zerocomp_PVSSRC(&(pAsm
->S
[0].src
), 3);
3312 zerocomp_PVSSRC(&(pAsm
->S
[1].src
), 3);
3314 else if(pAsm
->pILInst
[pAsm
->uiCurInst
].Opcode
== OPCODE_DPH
)
3316 onecomp_PVSSRC(&(pAsm
->S
[0].src
), 3);
3319 if ( GL_FALSE
== next_ins(pAsm
) )
3327 GLboolean
assemble_DST(r700_AssemblerBase
*pAsm
)
3329 if( GL_FALSE
== checkop2(pAsm
) )
3334 pAsm
->D
.dst
.opcode
= SQ_OP2_INST_MUL
;
3336 if( GL_FALSE
== assemble_dst(pAsm
) )
3341 if( GL_FALSE
== assemble_src(pAsm
, 0, -1) )
3346 if( GL_FALSE
== assemble_src(pAsm
, 1, -1) )
3351 onecomp_PVSSRC(&(pAsm
->S
[0].src
), 0);
3352 onecomp_PVSSRC(&(pAsm
->S
[0].src
), 3);
3354 onecomp_PVSSRC(&(pAsm
->S
[1].src
), 0);
3355 onecomp_PVSSRC(&(pAsm
->S
[1].src
), 2);
3357 if ( GL_FALSE
== next_ins(pAsm
) )
3365 GLboolean
assemble_EX2(r700_AssemblerBase
*pAsm
)
3367 return assemble_math_function(pAsm
, SQ_OP2_INST_EXP_IEEE
);
3370 GLboolean
assemble_EXP(r700_AssemblerBase
*pAsm
)
3376 tmp
= gethelpr(pAsm
);
3381 if (pAsm
->pILInst
->DstReg
.WriteMask
& 0x1) {
3382 pAsm
->D
.dst
.opcode
= SQ_OP2_INST_FLOOR
;
3384 setaddrmode_PVSDST(&(pAsm
->D
.dst
), ADDR_ABSOLUTE
);
3385 pAsm
->D
.dst
.rtype
= DST_REG_TEMPORARY
;
3386 pAsm
->D
.dst
.reg
= tmp
;
3387 pAsm
->D
.dst
.writex
= 1;
3389 if( GL_FALSE
== assemble_src(pAsm
, 0, -1) )
3394 if( GL_FALSE
== next_ins(pAsm
) )
3399 pAsm
->D
.dst
.opcode
= SQ_OP2_INST_EXP_IEEE
;
3400 pAsm
->D
.dst
.math
= 1;
3402 if( GL_FALSE
== assemble_dst(pAsm
) )
3407 pAsm
->D
.dst
.writey
= pAsm
->D
.dst
.writez
= pAsm
->D
.dst
.writew
= 0;
3409 setaddrmode_PVSSRC(&(pAsm
->S
[0].src
), ADDR_ABSOLUTE
);
3410 pAsm
->S
[0].src
.rtype
= DST_REG_TEMPORARY
;
3411 pAsm
->S
[0].src
.reg
= tmp
;
3413 setswizzle_PVSSRC(&(pAsm
->S
[0].src
), SQ_SEL_X
);
3414 noneg_PVSSRC(&(pAsm
->S
[0].src
));
3416 if( GL_FALSE
== next_ins(pAsm
) )
3424 if ((pAsm
->pILInst
->DstReg
.WriteMask
>> 1) & 0x1) {
3425 pAsm
->D
.dst
.opcode
= SQ_OP2_INST_FRACT
;
3427 if( GL_FALSE
== assemble_dst(pAsm
) )
3432 if( GL_FALSE
== assemble_src(pAsm
, 0, -1) )
3437 pAsm
->D
.dst
.writex
= pAsm
->D
.dst
.writez
= pAsm
->D
.dst
.writew
= 0;
3439 if( GL_FALSE
== next_ins(pAsm
) )
3447 if ((pAsm
->pILInst
->DstReg
.WriteMask
>> 2) & 0x1) {
3448 pAsm
->D
.dst
.opcode
= SQ_OP2_INST_EXP_IEEE
;
3449 pAsm
->D
.dst
.math
= 1;
3451 if( GL_FALSE
== assemble_dst(pAsm
) )
3456 if( GL_FALSE
== assemble_src(pAsm
, 0, -1) )
3461 pAsm
->D
.dst
.writex
= pAsm
->D
.dst
.writey
= pAsm
->D
.dst
.writew
= 0;
3463 if( GL_FALSE
== next_ins(pAsm
) )
3471 if ((pAsm
->pILInst
->DstReg
.WriteMask
>> 3) & 0x1) {
3472 pAsm
->D
.dst
.opcode
= SQ_OP2_INST_MOV
;
3474 if( GL_FALSE
== assemble_dst(pAsm
) )
3479 pAsm
->D
.dst
.writex
= pAsm
->D
.dst
.writey
= pAsm
->D
.dst
.writez
= 0;
3481 setaddrmode_PVSSRC(&(pAsm
->S
[0].src
), ADDR_ABSOLUTE
);
3482 pAsm
->S
[0].src
.rtype
= SRC_REG_TEMPORARY
;
3483 pAsm
->S
[0].src
.reg
= tmp
;
3485 setswizzle_PVSSRC(&(pAsm
->S
[0].src
), SQ_SEL_1
);
3486 noneg_PVSSRC(&(pAsm
->S
[0].src
));
3488 if( GL_FALSE
== next_ins(pAsm
) )
3497 GLboolean
assemble_FLR(r700_AssemblerBase
*pAsm
)
3501 pAsm
->D
.dst
.opcode
= SQ_OP2_INST_FLOOR
;
3503 if ( GL_FALSE
== assemble_dst(pAsm
) )
3508 if ( GL_FALSE
== assemble_src(pAsm
, 0, -1) )
3513 if ( GL_FALSE
== next_ins(pAsm
) )
3521 GLboolean
assemble_FLR_INT(r700_AssemblerBase
*pAsm
)
3523 return assemble_math_function(pAsm
, SQ_OP2_INST_FLT_TO_INT
);
3526 GLboolean
assemble_FRC(r700_AssemblerBase
*pAsm
)
3530 pAsm
->D
.dst
.opcode
= SQ_OP2_INST_FRACT
;
3532 if ( GL_FALSE
== assemble_dst(pAsm
) )
3537 if ( GL_FALSE
== assemble_src(pAsm
, 0, -1) )
3542 if ( GL_FALSE
== next_ins(pAsm
) )
3550 GLboolean
assemble_KIL(r700_AssemblerBase
*pAsm
)
3552 /* TODO: doc says KILL has to be last(end) ALU clause */
3556 pAsm
->D
.dst
.opcode
= SQ_OP2_INST_KILLGT
;
3558 setaddrmode_PVSDST(&(pAsm
->D
.dst
), ADDR_ABSOLUTE
);
3559 pAsm
->D
.dst
.rtype
= DST_REG_TEMPORARY
;
3560 pAsm
->D
.dst
.reg
= 0;
3561 pAsm
->D
.dst
.writex
= 0;
3562 pAsm
->D
.dst
.writey
= 0;
3563 pAsm
->D
.dst
.writez
= 0;
3564 pAsm
->D
.dst
.writew
= 0;
3566 setaddrmode_PVSSRC(&(pAsm
->S
[0].src
), ADDR_ABSOLUTE
);
3567 pAsm
->S
[0].src
.rtype
= SRC_REG_TEMPORARY
;
3568 pAsm
->S
[0].src
.reg
= 0;
3570 setswizzle_PVSSRC(&(pAsm
->S
[0].src
), SQ_SEL_0
);
3571 noneg_PVSSRC(&(pAsm
->S
[0].src
));
3573 if ( GL_FALSE
== assemble_src(pAsm
, 0, 1) )
3578 if ( GL_FALSE
== next_ins(pAsm
) )
3583 pAsm
->pR700Shader
->killIsUsed
= GL_TRUE
;
3588 GLboolean
assemble_LG2(r700_AssemblerBase
*pAsm
)
3590 return assemble_math_function(pAsm
, SQ_OP2_INST_LOG_IEEE
);
3593 GLboolean
assemble_LRP(r700_AssemblerBase
*pAsm
)
3597 if( GL_FALSE
== checkop3(pAsm
) )
3602 tmp
= gethelpr(pAsm
);
3604 pAsm
->D
.dst
.opcode
= SQ_OP2_INST_ADD
;
3606 pAsm
->D
.dst
.rtype
= DST_REG_TEMPORARY
;
3607 pAsm
->D
.dst
.reg
= tmp
;
3608 setaddrmode_PVSDST(&(pAsm
->D
.dst
), ADDR_ABSOLUTE
);
3609 nomask_PVSDST(&(pAsm
->D
.dst
));
3612 if( GL_FALSE
== assemble_src(pAsm
, 1, 0) )
3617 if ( GL_FALSE
== assemble_src(pAsm
, 2, 1) )
3622 neg_PVSSRC(&(pAsm
->S
[1].src
));
3624 if( GL_FALSE
== next_ins(pAsm
) )
3629 pAsm
->D
.dst
.opcode
= SQ_OP3_INST_MULADD
;
3630 pAsm
->D
.dst
.op3
= 1;
3632 pAsm
->D
.dst
.rtype
= DST_REG_TEMPORARY
;
3633 pAsm
->D
.dst
.reg
= tmp
;
3634 nomask_PVSDST(&(pAsm
->D
.dst
));
3635 setaddrmode_PVSDST(&(pAsm
->D
.dst
), ADDR_ABSOLUTE
);
3637 setaddrmode_PVSSRC(&(pAsm
->S
[0].src
), ADDR_ABSOLUTE
);
3638 pAsm
->S
[0].src
.rtype
= SRC_REG_TEMPORARY
;
3639 pAsm
->S
[0].src
.reg
= tmp
;
3640 noswizzle_PVSSRC(&(pAsm
->S
[0].src
));
3643 if( GL_FALSE
== assemble_src(pAsm
, 0, 1) )
3647 if( GL_FALSE
== assemble_src(pAsm
, 2, -1) )
3652 if( GL_FALSE
== next_ins(pAsm
) )
3657 pAsm
->D
.dst
.opcode
= SQ_OP2_INST_MOV
;
3659 if( GL_FALSE
== assemble_dst(pAsm
) )
3664 setaddrmode_PVSSRC(&(pAsm
->S
[0].src
), ADDR_ABSOLUTE
);
3665 pAsm
->S
[0].src
.rtype
= SRC_REG_TEMPORARY
;
3666 pAsm
->S
[0].src
.reg
= tmp
;
3667 noswizzle_PVSSRC(&(pAsm
->S
[0].src
));
3669 if( GL_FALSE
== next_ins(pAsm
) )
3677 GLboolean
assemble_LOG(r700_AssemblerBase
*pAsm
)
3679 BITS tmp1
, tmp2
, tmp3
;
3683 tmp1
= gethelpr(pAsm
);
3684 tmp2
= gethelpr(pAsm
);
3685 tmp3
= gethelpr(pAsm
);
3687 // FIXME: The hardware can do fabs() directly on input
3688 // elements, but the compiler doesn't have the
3689 // capability to use that.
3691 // MAX tmp1.x, a.x, -a.x (fabs(a.x))
3693 pAsm
->D
.dst
.opcode
= SQ_OP2_INST_MAX
;
3695 setaddrmode_PVSDST(&(pAsm
->D
.dst
), ADDR_ABSOLUTE
);
3696 pAsm
->D
.dst
.rtype
= DST_REG_TEMPORARY
;
3697 pAsm
->D
.dst
.reg
= tmp1
;
3698 pAsm
->D
.dst
.writex
= 1;
3700 if( GL_FALSE
== assemble_src(pAsm
, 0, -1) )
3705 pAsm
->S
[1].bits
= pAsm
->S
[0].bits
;
3706 flipneg_PVSSRC(&(pAsm
->S
[1].src
));
3708 if ( GL_FALSE
== next_ins(pAsm
) )
3715 // LG2 tmp2.x, tmp1.x
3716 // FLOOR tmp3.x, tmp2.x
3717 // MOV dst.x, tmp3.x
3718 // ADD tmp3.x, tmp2.x, -tmp3.x
3719 // EX2 dst.y, tmp3.x
3720 // MOV dst.z, tmp2.x
3723 // LG2 tmp2.x, tmp1.x
3724 // FLOOR tmp3.x, tmp2.x
3726 pAsm
->D
.dst
.opcode
= SQ_OP2_INST_LOG_IEEE
;
3727 pAsm
->D
.dst
.math
= 1;
3729 setaddrmode_PVSDST(&(pAsm
->D
.dst
), ADDR_ABSOLUTE
);
3730 pAsm
->D
.dst
.rtype
= DST_REG_TEMPORARY
;
3731 pAsm
->D
.dst
.reg
= tmp2
;
3732 pAsm
->D
.dst
.writex
= 1;
3734 setaddrmode_PVSSRC(&(pAsm
->S
[0].src
), ADDR_ABSOLUTE
);
3735 pAsm
->S
[0].src
.rtype
= DST_REG_TEMPORARY
;
3736 pAsm
->S
[0].src
.reg
= tmp1
;
3738 setswizzle_PVSSRC(&(pAsm
->S
[0].src
), SQ_SEL_X
);
3739 noneg_PVSSRC(&(pAsm
->S
[0].src
));
3741 if( GL_FALSE
== next_ins(pAsm
) )
3746 pAsm
->D
.dst
.opcode
= SQ_OP2_INST_FLOOR
;
3748 setaddrmode_PVSDST(&(pAsm
->D
.dst
), ADDR_ABSOLUTE
);
3749 pAsm
->D
.dst
.rtype
= DST_REG_TEMPORARY
;
3750 pAsm
->D
.dst
.reg
= tmp3
;
3751 pAsm
->D
.dst
.writex
= 1;
3753 setaddrmode_PVSSRC(&(pAsm
->S
[0].src
), ADDR_ABSOLUTE
);
3754 pAsm
->S
[0].src
.rtype
= DST_REG_TEMPORARY
;
3755 pAsm
->S
[0].src
.reg
= tmp2
;
3757 setswizzle_PVSSRC(&(pAsm
->S
[0].src
), SQ_SEL_X
);
3758 noneg_PVSSRC(&(pAsm
->S
[0].src
));
3760 if( GL_FALSE
== next_ins(pAsm
) )
3765 // MOV dst.x, tmp3.x
3767 pAsm
->D
.dst
.opcode
= SQ_OP2_INST_MOV
;
3769 if( GL_FALSE
== assemble_dst(pAsm
) )
3774 pAsm
->D
.dst
.writey
= pAsm
->D
.dst
.writez
= pAsm
->D
.dst
.writew
= 0;
3776 setaddrmode_PVSSRC(&(pAsm
->S
[0].src
), ADDR_ABSOLUTE
);
3777 pAsm
->S
[0].src
.rtype
= DST_REG_TEMPORARY
;
3778 pAsm
->S
[0].src
.reg
= tmp3
;
3780 setswizzle_PVSSRC(&(pAsm
->S
[0].src
), SQ_SEL_X
);
3781 noneg_PVSSRC(&(pAsm
->S
[0].src
));
3783 if( GL_FALSE
== next_ins(pAsm
) )
3788 // ADD tmp3.x, tmp2.x, -tmp3.x
3789 // EX2 dst.y, tmp3.x
3791 pAsm
->D
.dst
.opcode
= SQ_OP2_INST_ADD
;
3793 setaddrmode_PVSDST(&(pAsm
->D
.dst
), ADDR_ABSOLUTE
);
3794 pAsm
->D
.dst
.rtype
= DST_REG_TEMPORARY
;
3795 pAsm
->D
.dst
.reg
= tmp3
;
3796 pAsm
->D
.dst
.writex
= 1;
3798 setaddrmode_PVSSRC(&(pAsm
->S
[0].src
), ADDR_ABSOLUTE
);
3799 pAsm
->S
[0].src
.rtype
= DST_REG_TEMPORARY
;
3800 pAsm
->S
[0].src
.reg
= tmp2
;
3802 setswizzle_PVSSRC(&(pAsm
->S
[0].src
), SQ_SEL_X
);
3803 noneg_PVSSRC(&(pAsm
->S
[0].src
));
3805 setaddrmode_PVSSRC(&(pAsm
->S
[1].src
), ADDR_ABSOLUTE
);
3806 pAsm
->S
[1].src
.rtype
= DST_REG_TEMPORARY
;
3807 pAsm
->S
[1].src
.reg
= tmp3
;
3809 setswizzle_PVSSRC(&(pAsm
->S
[1].src
), SQ_SEL_X
);
3810 neg_PVSSRC(&(pAsm
->S
[1].src
));
3812 if( GL_FALSE
== next_ins(pAsm
) )
3817 pAsm
->D
.dst
.opcode
= SQ_OP2_INST_EXP_IEEE
;
3818 pAsm
->D
.dst
.math
= 1;
3820 if( GL_FALSE
== assemble_dst(pAsm
) )
3825 pAsm
->D
.dst
.writex
= pAsm
->D
.dst
.writez
= pAsm
->D
.dst
.writew
= 0;
3827 setaddrmode_PVSSRC(&(pAsm
->S
[0].src
), ADDR_ABSOLUTE
);
3828 pAsm
->S
[0].src
.rtype
= DST_REG_TEMPORARY
;
3829 pAsm
->S
[0].src
.reg
= tmp3
;
3831 setswizzle_PVSSRC(&(pAsm
->S
[0].src
), SQ_SEL_X
);
3832 noneg_PVSSRC(&(pAsm
->S
[0].src
));
3834 if( GL_FALSE
== next_ins(pAsm
) )
3839 // MOV dst.z, tmp2.x
3841 pAsm
->D
.dst
.opcode
= SQ_OP2_INST_MOV
;
3843 if( GL_FALSE
== assemble_dst(pAsm
) )
3848 pAsm
->D
.dst
.writex
= pAsm
->D
.dst
.writey
= pAsm
->D
.dst
.writew
= 0;
3850 setaddrmode_PVSSRC(&(pAsm
->S
[0].src
), ADDR_ABSOLUTE
);
3851 pAsm
->S
[0].src
.rtype
= DST_REG_TEMPORARY
;
3852 pAsm
->S
[0].src
.reg
= tmp2
;
3854 setswizzle_PVSSRC(&(pAsm
->S
[0].src
), SQ_SEL_X
);
3855 noneg_PVSSRC(&(pAsm
->S
[0].src
));
3857 if( GL_FALSE
== next_ins(pAsm
) )
3864 pAsm
->D
.dst
.opcode
= SQ_OP2_INST_MOV
;
3866 if( GL_FALSE
== assemble_dst(pAsm
) )
3871 pAsm
->D
.dst
.writex
= pAsm
->D
.dst
.writey
= pAsm
->D
.dst
.writez
= 0;
3873 setaddrmode_PVSSRC(&(pAsm
->S
[0].src
), ADDR_ABSOLUTE
);
3874 pAsm
->S
[0].src
.rtype
= SRC_REG_TEMPORARY
;
3875 pAsm
->S
[0].src
.reg
= tmp1
;
3877 setswizzle_PVSSRC(&(pAsm
->S
[0].src
), SQ_SEL_1
);
3878 noneg_PVSSRC(&(pAsm
->S
[0].src
));
3880 if( GL_FALSE
== next_ins(pAsm
) )
3888 GLboolean
assemble_MAD(struct r700_AssemblerBase
*pAsm
)
3891 GLboolean bReplaceDst
= GL_FALSE
;
3892 struct prog_instruction
*pILInst
= &(pAsm
->pILInst
[pAsm
->uiCurInst
]);
3894 if( GL_FALSE
== checkop3(pAsm
) )
3899 pAsm
->D
.dst
.opcode
= SQ_OP3_INST_MULADD
;
3900 pAsm
->D
.dst
.op3
= 1;
3904 if(PROGRAM_TEMPORARY
== pILInst
->DstReg
.File
)
3905 { /* TODO : more investigation on MAD src and dst using same register */
3906 for(ii
=0; ii
<3; ii
++)
3908 if( (PROGRAM_TEMPORARY
== pILInst
->SrcReg
[ii
].File
)
3909 && (pILInst
->DstReg
.Index
== pILInst
->SrcReg
[ii
].Index
) )
3911 bReplaceDst
= GL_TRUE
;
3916 if(0xF != pILInst
->DstReg
.WriteMask
)
3917 { /* OP3 has no support for write mask */
3918 bReplaceDst
= GL_TRUE
;
3921 if(GL_TRUE
== bReplaceDst
)
3923 tmp
= gethelpr(pAsm
);
3925 setaddrmode_PVSDST(&(pAsm
->D
.dst
), ADDR_ABSOLUTE
);
3926 pAsm
->D
.dst
.rtype
= DST_REG_TEMPORARY
;
3927 pAsm
->D
.dst
.reg
= tmp
;
3929 nomask_PVSDST(&(pAsm
->D
.dst
));
3933 if( GL_FALSE
== assemble_dst(pAsm
) )
3939 if( GL_FALSE
== assemble_src(pAsm
, 0, -1) )
3944 if( GL_FALSE
== assemble_src(pAsm
, 1, -1) )
3949 if( GL_FALSE
== assemble_src(pAsm
, 2, -1) )
3954 if ( GL_FALSE
== next_ins(pAsm
) )
3959 if (GL_TRUE
== bReplaceDst
)
3961 if( GL_FALSE
== assemble_dst(pAsm
) )
3966 pAsm
->D
.dst
.opcode
= SQ_OP2_INST_MOV
;
3969 setaddrmode_PVSSRC(&(pAsm
->S
[0].src
), ADDR_ABSOLUTE
);
3970 pAsm
->S
[0].src
.rtype
= SRC_REG_TEMPORARY
;
3971 pAsm
->S
[0].src
.reg
= tmp
;
3973 noneg_PVSSRC(&(pAsm
->S
[0].src
));
3974 noswizzle_PVSSRC(&(pAsm
->S
[0].src
));
3976 if( GL_FALSE
== next_ins(pAsm
) )
3986 GLboolean
assemble_LIT(r700_AssemblerBase
*pAsm
)
3988 unsigned int dstReg
;
3989 unsigned int dstType
;
3990 unsigned int srcReg
;
3991 unsigned int srcType
;
3993 int tmp
= gethelpr(pAsm
);
3995 if( GL_FALSE
== assemble_dst(pAsm
) )
3999 if( GL_FALSE
== assemble_src(pAsm
, 0, -1) )
4003 dstReg
= pAsm
->D
.dst
.reg
;
4004 dstType
= pAsm
->D
.dst
.rtype
;
4005 srcReg
= pAsm
->S
[0].src
.reg
;
4006 srcType
= pAsm
->S
[0].src
.rtype
;
4008 /* dst.xw, <- 1.0 */
4009 pAsm
->D
.dst
.opcode
= SQ_OP2_INST_MOV
;
4010 pAsm
->D
.dst
.rtype
= dstType
;
4011 pAsm
->D
.dst
.reg
= dstReg
;
4012 pAsm
->D
.dst
.writex
= 1;
4013 pAsm
->D
.dst
.writey
= 0;
4014 pAsm
->D
.dst
.writez
= 0;
4015 pAsm
->D
.dst
.writew
= 1;
4016 pAsm
->S
[0].src
.rtype
= SRC_REG_TEMPORARY
;
4017 pAsm
->S
[0].src
.reg
= tmp
;
4018 setaddrmode_PVSSRC(&(pAsm
->S
[0].src
), ADDR_ABSOLUTE
);
4019 noneg_PVSSRC(&(pAsm
->S
[0].src
));
4020 pAsm
->S
[0].src
.swizzlex
= SQ_SEL_1
;
4021 pAsm
->S
[0].src
.swizzley
= SQ_SEL_1
;
4022 pAsm
->S
[0].src
.swizzlez
= SQ_SEL_1
;
4023 pAsm
->S
[0].src
.swizzlew
= SQ_SEL_1
;
4024 if( GL_FALSE
== next_ins(pAsm
) )
4029 if( GL_FALSE
== assemble_src(pAsm
, 0, -1) )
4034 /* dst.y = max(src.x, 0.0) */
4035 pAsm
->D
.dst
.opcode
= SQ_OP2_INST_MAX
;
4036 pAsm
->D
.dst
.rtype
= dstType
;
4037 pAsm
->D
.dst
.reg
= dstReg
;
4038 pAsm
->D
.dst
.writex
= 0;
4039 pAsm
->D
.dst
.writey
= 1;
4040 pAsm
->D
.dst
.writez
= 0;
4041 pAsm
->D
.dst
.writew
= 0;
4042 pAsm
->S
[0].src
.rtype
= srcType
;
4043 pAsm
->S
[0].src
.reg
= srcReg
;
4044 setaddrmode_PVSSRC(&(pAsm
->S
[0].src
), ADDR_ABSOLUTE
);
4045 swizzleagain_PVSSRC(&(pAsm
->S
[0].src
), SQ_SEL_X
, SQ_SEL_X
, SQ_SEL_X
, SQ_SEL_X
);
4046 pAsm
->S
[1].src
.rtype
= SRC_REG_TEMPORARY
;
4047 pAsm
->S
[1].src
.reg
= tmp
;
4048 setaddrmode_PVSSRC(&(pAsm
->S
[1].src
), ADDR_ABSOLUTE
);
4049 noneg_PVSSRC(&(pAsm
->S
[1].src
));
4050 pAsm
->S
[1].src
.swizzlex
= SQ_SEL_0
;
4051 pAsm
->S
[1].src
.swizzley
= SQ_SEL_0
;
4052 pAsm
->S
[1].src
.swizzlez
= SQ_SEL_0
;
4053 pAsm
->S
[1].src
.swizzlew
= SQ_SEL_0
;
4054 if( GL_FALSE
== next_ins(pAsm
) )
4059 if( GL_FALSE
== assemble_src(pAsm
, 0, -1) )
4064 swizzleagain_PVSSRC(&(pAsm
->S
[0].src
), SQ_SEL_Y
, SQ_SEL_Y
, SQ_SEL_Y
, SQ_SEL_Y
);
4066 /* dst.z = log(src.y) */
4067 pAsm
->D
.dst
.opcode
= SQ_OP2_INST_LOG_CLAMPED
;
4068 pAsm
->D
.dst
.math
= 1;
4069 pAsm
->D
.dst
.rtype
= dstType
;
4070 pAsm
->D
.dst
.reg
= dstReg
;
4071 pAsm
->D
.dst
.writex
= 0;
4072 pAsm
->D
.dst
.writey
= 0;
4073 pAsm
->D
.dst
.writez
= 1;
4074 pAsm
->D
.dst
.writew
= 0;
4075 pAsm
->S
[0].src
.rtype
= srcType
;
4076 pAsm
->S
[0].src
.reg
= srcReg
;
4077 setaddrmode_PVSSRC(&(pAsm
->S
[0].src
), ADDR_ABSOLUTE
);
4078 if( GL_FALSE
== next_ins(pAsm
) )
4083 if( GL_FALSE
== assemble_src(pAsm
, 0, -1) )
4088 if( GL_FALSE
== assemble_src(pAsm
, 0, 2) )
4093 swizzleagain_PVSSRC(&(pAsm
->S
[0].src
), SQ_SEL_W
, SQ_SEL_W
, SQ_SEL_W
, SQ_SEL_W
);
4095 swizzleagain_PVSSRC(&(pAsm
->S
[2].src
), SQ_SEL_X
, SQ_SEL_X
, SQ_SEL_X
, SQ_SEL_X
);
4097 /* tmp.x = amd MUL_LIT(src.w, dst.z, src.x ) */
4098 pAsm
->D
.dst
.opcode
= SQ_OP3_INST_MUL_LIT
;
4099 pAsm
->D
.dst
.math
= 1;
4100 pAsm
->D
.dst
.op3
= 1;
4101 pAsm
->D
.dst
.rtype
= DST_REG_TEMPORARY
;
4102 pAsm
->D
.dst
.reg
= tmp
;
4103 pAsm
->D
.dst
.writex
= 1;
4104 pAsm
->D
.dst
.writey
= 0;
4105 pAsm
->D
.dst
.writez
= 0;
4106 pAsm
->D
.dst
.writew
= 0;
4108 pAsm
->S
[0].src
.rtype
= srcType
;
4109 pAsm
->S
[0].src
.reg
= srcReg
;
4110 setaddrmode_PVSSRC(&(pAsm
->S
[0].src
), ADDR_ABSOLUTE
);
4112 pAsm
->S
[1].src
.rtype
= SRC_REG_TEMPORARY
;
4113 pAsm
->S
[1].src
.reg
= dstReg
;
4114 setaddrmode_PVSSRC(&(pAsm
->S
[1].src
), ADDR_ABSOLUTE
);
4115 noneg_PVSSRC(&(pAsm
->S
[1].src
));
4116 pAsm
->S
[1].src
.swizzlex
= SQ_SEL_Z
;
4117 pAsm
->S
[1].src
.swizzley
= SQ_SEL_Z
;
4118 pAsm
->S
[1].src
.swizzlez
= SQ_SEL_Z
;
4119 pAsm
->S
[1].src
.swizzlew
= SQ_SEL_Z
;
4121 pAsm
->S
[2].src
.rtype
= srcType
;
4122 pAsm
->S
[2].src
.reg
= srcReg
;
4123 setaddrmode_PVSSRC(&(pAsm
->S
[2].src
), ADDR_ABSOLUTE
);
4125 if( GL_FALSE
== next_ins(pAsm
) )
4130 /* dst.z = exp(tmp.x) */
4131 pAsm
->D
.dst
.opcode
= SQ_OP2_INST_EXP_IEEE
;
4132 pAsm
->D
.dst
.math
= 1;
4133 pAsm
->D
.dst
.rtype
= dstType
;
4134 pAsm
->D
.dst
.reg
= dstReg
;
4135 pAsm
->D
.dst
.writex
= 0;
4136 pAsm
->D
.dst
.writey
= 0;
4137 pAsm
->D
.dst
.writez
= 1;
4138 pAsm
->D
.dst
.writew
= 0;
4140 pAsm
->S
[0].src
.rtype
= SRC_REG_TEMPORARY
;
4141 pAsm
->S
[0].src
.reg
= tmp
;
4142 setaddrmode_PVSSRC(&(pAsm
->S
[0].src
), ADDR_ABSOLUTE
);
4143 noneg_PVSSRC(&(pAsm
->S
[0].src
));
4144 pAsm
->S
[0].src
.swizzlex
= SQ_SEL_X
;
4145 pAsm
->S
[0].src
.swizzley
= SQ_SEL_X
;
4146 pAsm
->S
[0].src
.swizzlez
= SQ_SEL_X
;
4147 pAsm
->S
[0].src
.swizzlew
= SQ_SEL_X
;
4149 if( GL_FALSE
== next_ins(pAsm
) )
4157 GLboolean
assemble_MAX(r700_AssemblerBase
*pAsm
)
4159 if( GL_FALSE
== checkop2(pAsm
) )
4164 pAsm
->D
.dst
.opcode
= SQ_OP2_INST_MAX
;
4166 if( GL_FALSE
== assemble_dst(pAsm
) )
4171 if( GL_FALSE
== assemble_src(pAsm
, 0, -1) )
4176 if( GL_FALSE
== assemble_src(pAsm
, 1, -1) )
4181 if( GL_FALSE
== next_ins(pAsm
) )
4189 GLboolean
assemble_MIN(r700_AssemblerBase
*pAsm
)
4191 if( GL_FALSE
== checkop2(pAsm
) )
4196 pAsm
->D
.dst
.opcode
= SQ_OP2_INST_MIN
;
4198 if( GL_FALSE
== assemble_dst(pAsm
) )
4203 if( GL_FALSE
== assemble_src(pAsm
, 0, -1) )
4208 if( GL_FALSE
== assemble_src(pAsm
, 1, -1) )
4213 if( GL_FALSE
== next_ins(pAsm
) )
4221 GLboolean
assemble_MOV(r700_AssemblerBase
*pAsm
)
4225 pAsm
->D
.dst
.opcode
= SQ_OP2_INST_MOV
;
4227 if (GL_FALSE
== assemble_dst(pAsm
))
4232 if (GL_FALSE
== assemble_src(pAsm
, 0, -1))
4237 if ( GL_FALSE
== next_ins(pAsm
) )
4245 GLboolean
assemble_MUL(r700_AssemblerBase
*pAsm
)
4247 if( GL_FALSE
== checkop2(pAsm
) )
4252 pAsm
->D
.dst
.opcode
= SQ_OP2_INST_MUL
;
4254 if( GL_FALSE
== assemble_dst(pAsm
) )
4259 if( GL_FALSE
== assemble_src(pAsm
, 0, -1) )
4264 if( GL_FALSE
== assemble_src(pAsm
, 1, -1) )
4269 if( GL_FALSE
== next_ins(pAsm
) )
4277 GLboolean
assemble_POW(r700_AssemblerBase
*pAsm
)
4283 tmp
= gethelpr(pAsm
);
4285 // LG2 tmp.x, a.swizzle
4286 pAsm
->D
.dst
.opcode
= SQ_OP2_INST_LOG_IEEE
;
4287 pAsm
->D
.dst
.math
= 1;
4289 setaddrmode_PVSDST(&(pAsm
->D
.dst
), ADDR_ABSOLUTE
);
4290 pAsm
->D
.dst
.rtype
= DST_REG_TEMPORARY
;
4291 pAsm
->D
.dst
.reg
= tmp
;
4292 nomask_PVSDST(&(pAsm
->D
.dst
));
4294 if( GL_FALSE
== assemble_src(pAsm
, 0, -1) )
4299 if( GL_FALSE
== next_ins(pAsm
) )
4304 // MUL tmp.x, tmp.x, b.swizzle
4305 pAsm
->D
.dst
.opcode
= SQ_OP2_INST_MUL
;
4307 setaddrmode_PVSDST(&(pAsm
->D
.dst
), ADDR_ABSOLUTE
);
4308 pAsm
->D
.dst
.rtype
= DST_REG_TEMPORARY
;
4309 pAsm
->D
.dst
.reg
= tmp
;
4310 nomask_PVSDST(&(pAsm
->D
.dst
));
4312 setaddrmode_PVSSRC(&(pAsm
->S
[0].src
), ADDR_ABSOLUTE
);
4313 pAsm
->S
[0].src
.rtype
= SRC_REG_TEMPORARY
;
4314 pAsm
->S
[0].src
.reg
= tmp
;
4315 setswizzle_PVSSRC(&(pAsm
->S
[0].src
), SQ_SEL_X
);
4316 noneg_PVSSRC(&(pAsm
->S
[0].src
));
4318 if( GL_FALSE
== assemble_src(pAsm
, 1, -1) )
4323 if( GL_FALSE
== next_ins(pAsm
) )
4328 // EX2 dst.mask, tmp.x
4330 pAsm
->D
.dst
.opcode
= SQ_OP2_INST_EXP_IEEE
;
4331 pAsm
->D
.dst
.math
= 1;
4333 setaddrmode_PVSDST(&(pAsm
->D
.dst
), ADDR_ABSOLUTE
);
4334 pAsm
->D
.dst
.rtype
= DST_REG_TEMPORARY
;
4335 pAsm
->D
.dst
.reg
= tmp
;
4336 nomask_PVSDST(&(pAsm
->D
.dst
));
4338 setaddrmode_PVSSRC(&(pAsm
->S
[0].src
), ADDR_ABSOLUTE
);
4339 pAsm
->S
[0].src
.rtype
= SRC_REG_TEMPORARY
;
4340 pAsm
->S
[0].src
.reg
= tmp
;
4341 setswizzle_PVSSRC(&(pAsm
->S
[0].src
), SQ_SEL_X
);
4342 noneg_PVSSRC(&(pAsm
->S
[0].src
));
4344 if( GL_FALSE
== next_ins(pAsm
) )
4349 // Now replicate result to all necessary channels in destination
4350 pAsm
->D
.dst
.opcode
= SQ_OP2_INST_MOV
;
4352 if( GL_FALSE
== assemble_dst(pAsm
) )
4357 setaddrmode_PVSSRC(&(pAsm
->S
[0].src
), ADDR_ABSOLUTE
);
4358 pAsm
->S
[0].src
.rtype
= DST_REG_TEMPORARY
;
4359 pAsm
->S
[0].src
.reg
= tmp
;
4361 setswizzle_PVSSRC(&(pAsm
->S
[0].src
), SQ_SEL_X
);
4362 noneg_PVSSRC(&(pAsm
->S
[0].src
));
4364 if( GL_FALSE
== next_ins(pAsm
) )
4372 GLboolean
assemble_RCP(r700_AssemblerBase
*pAsm
)
4374 return assemble_math_function(pAsm
, SQ_OP2_INST_RECIP_IEEE
);
4377 GLboolean
assemble_RSQ(r700_AssemblerBase
*pAsm
)
4379 return assemble_math_function(pAsm
, SQ_OP2_INST_RECIPSQRT_IEEE
);
4382 GLboolean
assemble_SIN(r700_AssemblerBase
*pAsm
)
4384 return assemble_math_function(pAsm
, SQ_OP2_INST_SIN
);
4387 GLboolean
assemble_SCS(r700_AssemblerBase
*pAsm
)
4393 tmp
= gethelpr(pAsm
);
4396 pAsm
->D
.dst
.opcode
= SQ_OP2_INST_COS
;
4397 pAsm
->D
.dst
.math
= 1;
4399 setaddrmode_PVSDST(&(pAsm
->D
.dst
), ADDR_ABSOLUTE
);
4400 pAsm
->D
.dst
.rtype
= DST_REG_TEMPORARY
;
4401 pAsm
->D
.dst
.reg
= tmp
;
4402 pAsm
->D
.dst
.writex
= 1;
4404 if( GL_FALSE
== assemble_src(pAsm
, 0, -1) )
4409 if ( GL_FALSE
== next_ins(pAsm
) )
4415 pAsm
->D
.dst
.opcode
= SQ_OP2_INST_SIN
;
4416 pAsm
->D
.dst
.math
= 1;
4418 setaddrmode_PVSDST(&(pAsm
->D
.dst
), ADDR_ABSOLUTE
);
4419 pAsm
->D
.dst
.rtype
= DST_REG_TEMPORARY
;
4420 pAsm
->D
.dst
.reg
= tmp
;
4421 pAsm
->D
.dst
.writey
= 1;
4423 if( GL_FALSE
== assemble_src(pAsm
, 0, -1) )
4428 if( GL_FALSE
== next_ins(pAsm
) )
4433 // MOV dst.mask, tmp
4434 pAsm
->D
.dst
.opcode
= SQ_OP2_INST_MOV
;
4436 if( GL_FALSE
== assemble_dst(pAsm
) )
4441 setaddrmode_PVSSRC(&(pAsm
->S
[0].src
), ADDR_ABSOLUTE
);
4442 pAsm
->S
[0].src
.rtype
= DST_REG_TEMPORARY
;
4443 pAsm
->S
[0].src
.reg
= tmp
;
4445 noswizzle_PVSSRC(&(pAsm
->S
[0].src
));
4446 pAsm
->S
[0].src
.swizzlez
= SQ_SEL_0
;
4447 pAsm
->S
[0].src
.swizzlew
= SQ_SEL_0
;
4449 if ( GL_FALSE
== next_ins(pAsm
) )
4457 GLboolean
assemble_LOGIC(r700_AssemblerBase
*pAsm
, BITS opcode
)
4459 if( GL_FALSE
== checkop2(pAsm
) )
4464 pAsm
->D
.dst
.opcode
= opcode
;
4465 pAsm
->D
.dst
.math
= 1;
4467 if( GL_FALSE
== assemble_dst(pAsm
) )
4472 if( GL_FALSE
== assemble_src(pAsm
, 0, -1) )
4477 if( GL_FALSE
== assemble_src(pAsm
, 1, -1) )
4482 if( GL_FALSE
== next_ins(pAsm
) )
4490 GLboolean
assemble_LOGIC_PRED(r700_AssemblerBase
*pAsm
, BITS opcode
)
4492 if( GL_FALSE
== checkop2(pAsm
) )
4497 pAsm
->D
.dst
.opcode
= opcode
;
4498 pAsm
->D
.dst
.math
= 1;
4499 pAsm
->D
.dst
.predicated
= 1;
4500 pAsm
->D2
.dst2
.SaturateMode
= pAsm
->pILInst
[pAsm
->uiCurInst
].SaturateMode
;
4502 if( GL_FALSE
== assemble_dst(pAsm
) )
4507 if( GL_FALSE
== assemble_src(pAsm
, 0, -1) )
4512 if( GL_FALSE
== assemble_src(pAsm
, 1, -1) )
4517 if( GL_FALSE
== next_ins2(pAsm
) )
4525 GLboolean
assemble_SGE(r700_AssemblerBase
*pAsm
)
4527 if( GL_FALSE
== checkop2(pAsm
) )
4532 pAsm
->D
.dst
.opcode
= SQ_OP2_INST_SETGE
;
4534 if( GL_FALSE
== assemble_dst(pAsm
) )
4539 if( GL_FALSE
== assemble_src(pAsm
, 0, -1) )
4544 if( GL_FALSE
== assemble_src(pAsm
, 1, -1) )
4549 if( GL_FALSE
== next_ins(pAsm
) )
4557 GLboolean
assemble_SLT(r700_AssemblerBase
*pAsm
)
4559 if( GL_FALSE
== checkop2(pAsm
) )
4564 pAsm
->D
.dst
.opcode
= SQ_OP2_INST_SETGT
;
4566 if( GL_FALSE
== assemble_dst(pAsm
) )
4571 if( GL_FALSE
== assemble_src(pAsm
, 0, 1) )
4576 if( GL_FALSE
== assemble_src(pAsm
, 1, 0) )
4581 if( GL_FALSE
== next_ins(pAsm
) )
4589 GLboolean
assemble_STP(r700_AssemblerBase
*pAsm
)
4594 GLboolean
assemble_TEX(r700_AssemblerBase
*pAsm
)
4596 GLboolean src_const
;
4597 GLboolean need_barrier
= GL_FALSE
;
4601 switch (pAsm
->pILInst
[pAsm
->uiCurInst
].SrcReg
[0].File
)
4603 case PROGRAM_CONSTANT
:
4604 case PROGRAM_LOCAL_PARAM
:
4605 case PROGRAM_ENV_PARAM
:
4606 case PROGRAM_STATE_VAR
:
4607 src_const
= GL_TRUE
;
4609 case PROGRAM_TEMPORARY
:
4612 src_const
= GL_FALSE
;
4616 if (GL_TRUE
== src_const
)
4618 if ( GL_FALSE
== mov_temp(pAsm
, 0) )
4620 need_barrier
= GL_TRUE
;
4623 switch (pAsm
->pILInst
[pAsm
->uiCurInst
].Opcode
)
4628 radeon_error("do not support TXB yet\n");
4634 radeon_error("Internal error: bad texture op (not TEX)\n");
4639 if (pAsm
->pILInst
[pAsm
->uiCurInst
].Opcode
== OPCODE_TXP
)
4641 GLuint tmp
= gethelpr(pAsm
);
4642 pAsm
->D
.dst
.opcode
= SQ_OP2_INST_RECIP_IEEE
;
4643 pAsm
->D
.dst
.math
= 1;
4644 setaddrmode_PVSDST(&(pAsm
->D
.dst
), ADDR_ABSOLUTE
);
4645 pAsm
->D
.dst
.rtype
= DST_REG_TEMPORARY
;
4646 pAsm
->D
.dst
.reg
= tmp
;
4647 pAsm
->D
.dst
.writew
= 1;
4649 if( GL_FALSE
== assemble_src(pAsm
, 0, -1) )
4653 swizzleagain_PVSSRC(&(pAsm
->S
[0].src
), SQ_SEL_W
, SQ_SEL_W
, SQ_SEL_W
, SQ_SEL_W
);
4654 if( GL_FALSE
== next_ins(pAsm
) )
4659 pAsm
->D
.dst
.opcode
= SQ_OP2_INST_MUL
;
4660 setaddrmode_PVSDST(&(pAsm
->D
.dst
), ADDR_ABSOLUTE
);
4661 pAsm
->D
.dst
.rtype
= DST_REG_TEMPORARY
;
4662 pAsm
->D
.dst
.reg
= tmp
;
4663 pAsm
->D
.dst
.writex
= 1;
4664 pAsm
->D
.dst
.writey
= 1;
4665 pAsm
->D
.dst
.writez
= 1;
4666 pAsm
->D
.dst
.writew
= 0;
4668 if( GL_FALSE
== assemble_src(pAsm
, 0, -1) )
4672 setaddrmode_PVSSRC(&(pAsm
->S
[1].src
), ADDR_ABSOLUTE
);
4673 pAsm
->S
[1].src
.rtype
= SRC_REG_TEMPORARY
;
4674 pAsm
->S
[1].src
.reg
= tmp
;
4675 setswizzle_PVSSRC(&(pAsm
->S
[1].src
), SQ_SEL_W
);
4677 if( GL_FALSE
== next_ins(pAsm
) )
4682 pAsm
->aArgSubst
[1] = tmp
;
4683 need_barrier
= GL_TRUE
;
4686 if (pAsm
->pILInst
[pAsm
->uiCurInst
].TexSrcTarget
== TEXTURE_CUBE_INDEX
)
4688 GLuint tmp1
= gethelpr(pAsm
);
4689 GLuint tmp2
= gethelpr(pAsm
);
4691 /* tmp1.xyzw = CUBE(R0.zzxy, R0.yxzz) */
4692 pAsm
->D
.dst
.opcode
= SQ_OP2_INST_CUBE
;
4693 setaddrmode_PVSDST(&(pAsm
->D
.dst
), ADDR_ABSOLUTE
);
4694 pAsm
->D
.dst
.rtype
= DST_REG_TEMPORARY
;
4695 pAsm
->D
.dst
.reg
= tmp1
;
4696 nomask_PVSDST(&(pAsm
->D
.dst
));
4698 if( GL_FALSE
== assemble_src(pAsm
, 0, -1) )
4703 if( GL_FALSE
== assemble_src(pAsm
, 0, 1) )
4708 swizzleagain_PVSSRC(&(pAsm
->S
[0].src
), SQ_SEL_Z
, SQ_SEL_Z
, SQ_SEL_X
, SQ_SEL_Y
);
4709 swizzleagain_PVSSRC(&(pAsm
->S
[1].src
), SQ_SEL_Y
, SQ_SEL_X
, SQ_SEL_Z
, SQ_SEL_Z
);
4711 if( GL_FALSE
== next_ins(pAsm
) )
4716 /* tmp1.z = ABS(tmp1.z) dont have abs support in assembler currently
4717 * have to do explicit instruction
4719 pAsm
->D
.dst
.opcode
= SQ_OP2_INST_MAX
;
4720 setaddrmode_PVSDST(&(pAsm
->D
.dst
), ADDR_ABSOLUTE
);
4721 pAsm
->D
.dst
.rtype
= DST_REG_TEMPORARY
;
4722 pAsm
->D
.dst
.reg
= tmp1
;
4723 pAsm
->D
.dst
.writez
= 1;
4725 setaddrmode_PVSSRC(&(pAsm
->S
[0].src
), ADDR_ABSOLUTE
);
4726 pAsm
->S
[0].src
.rtype
= SRC_REG_TEMPORARY
;
4727 pAsm
->S
[0].src
.reg
= tmp1
;
4728 noswizzle_PVSSRC(&(pAsm
->S
[0].src
));
4729 pAsm
->S
[1].bits
= pAsm
->S
[0].bits
;
4730 flipneg_PVSSRC(&(pAsm
->S
[1].src
));
4734 /* tmp1.z = RCP_e(|tmp1.z|) */
4735 pAsm
->D
.dst
.opcode
= SQ_OP2_INST_RECIP_IEEE
;
4736 pAsm
->D
.dst
.math
= 1;
4737 setaddrmode_PVSDST(&(pAsm
->D
.dst
), ADDR_ABSOLUTE
);
4738 pAsm
->D
.dst
.rtype
= DST_REG_TEMPORARY
;
4739 pAsm
->D
.dst
.reg
= tmp1
;
4740 pAsm
->D
.dst
.writez
= 1;
4742 setaddrmode_PVSSRC(&(pAsm
->S
[0].src
), ADDR_ABSOLUTE
);
4743 pAsm
->S
[0].src
.rtype
= SRC_REG_TEMPORARY
;
4744 pAsm
->S
[0].src
.reg
= tmp1
;
4745 pAsm
->S
[0].src
.swizzlex
= SQ_SEL_Z
;
4749 /* MULADD R0.x, R0.x, PS1, (0x3FC00000, 1.5f).x
4750 * MULADD R0.y, R0.y, PS1, (0x3FC00000, 1.5f).x
4751 * muladd has no writemask, have to use another temp
4752 * also no support for imm constants, so add 1 here
4754 pAsm
->D
.dst
.opcode
= SQ_OP3_INST_MULADD
;
4755 pAsm
->D
.dst
.op3
= 1;
4756 setaddrmode_PVSDST(&(pAsm
->D
.dst
), ADDR_ABSOLUTE
);
4757 pAsm
->D
.dst
.rtype
= DST_REG_TEMPORARY
;
4758 pAsm
->D
.dst
.reg
= tmp2
;
4760 setaddrmode_PVSSRC(&(pAsm
->S
[0].src
), ADDR_ABSOLUTE
);
4761 pAsm
->S
[0].src
.rtype
= SRC_REG_TEMPORARY
;
4762 pAsm
->S
[0].src
.reg
= tmp1
;
4763 noswizzle_PVSSRC(&(pAsm
->S
[0].src
));
4764 setaddrmode_PVSSRC(&(pAsm
->S
[1].src
), ADDR_ABSOLUTE
);
4765 pAsm
->S
[1].src
.rtype
= SRC_REG_TEMPORARY
;
4766 pAsm
->S
[1].src
.reg
= tmp1
;
4767 setswizzle_PVSSRC(&(pAsm
->S
[1].src
), SQ_SEL_Z
);
4768 setaddrmode_PVSSRC(&(pAsm
->S
[2].src
), ADDR_ABSOLUTE
);
4769 pAsm
->S
[2].src
.rtype
= SRC_REG_TEMPORARY
;
4770 pAsm
->S
[2].src
.reg
= tmp1
;
4771 setswizzle_PVSSRC(&(pAsm
->S
[2].src
), SQ_SEL_1
);
4775 /* ADD the remaining .5 */
4776 pAsm
->D
.dst
.opcode
= SQ_OP2_INST_ADD
;
4777 setaddrmode_PVSDST(&(pAsm
->D
.dst
), ADDR_ABSOLUTE
);
4778 pAsm
->D
.dst
.rtype
= DST_REG_TEMPORARY
;
4779 pAsm
->D
.dst
.reg
= tmp2
;
4780 pAsm
->D
.dst
.writex
= 1;
4781 pAsm
->D
.dst
.writey
= 1;
4782 pAsm
->D
.dst
.writez
= 0;
4783 pAsm
->D
.dst
.writew
= 0;
4785 setaddrmode_PVSSRC(&(pAsm
->S
[0].src
), ADDR_ABSOLUTE
);
4786 pAsm
->S
[0].src
.rtype
= SRC_REG_TEMPORARY
;
4787 pAsm
->S
[0].src
.reg
= tmp2
;
4788 noswizzle_PVSSRC(&(pAsm
->S
[0].src
));
4789 setaddrmode_PVSSRC(&(pAsm
->S
[1].src
), ADDR_ABSOLUTE
);
4790 pAsm
->S
[1].src
.rtype
= SRC_REG_TEMPORARY
;
4791 pAsm
->S
[1].src
.reg
= 252; // SQ_ALU_SRC_0_5
4792 noswizzle_PVSSRC(&(pAsm
->S
[1].src
));
4796 /* tmp1.xy = temp2.xy */
4797 pAsm
->D
.dst
.opcode
= SQ_OP2_INST_MOV
;
4798 setaddrmode_PVSDST(&(pAsm
->D
.dst
), ADDR_ABSOLUTE
);
4799 pAsm
->D
.dst
.rtype
= DST_REG_TEMPORARY
;
4800 pAsm
->D
.dst
.reg
= tmp1
;
4801 pAsm
->D
.dst
.writex
= 1;
4802 pAsm
->D
.dst
.writey
= 1;
4803 pAsm
->D
.dst
.writez
= 0;
4804 pAsm
->D
.dst
.writew
= 0;
4806 setaddrmode_PVSSRC(&(pAsm
->S
[0].src
), ADDR_ABSOLUTE
);
4807 pAsm
->S
[0].src
.rtype
= SRC_REG_TEMPORARY
;
4808 pAsm
->S
[0].src
.reg
= tmp2
;
4809 noswizzle_PVSSRC(&(pAsm
->S
[0].src
));
4812 pAsm
->aArgSubst
[1] = tmp1
;
4813 need_barrier
= GL_TRUE
;
4817 pAsm
->D
.dst
.opcode
= SQ_TEX_INST_SAMPLE
;
4818 pAsm
->is_tex
= GL_TRUE
;
4819 if ( GL_TRUE
== need_barrier
)
4821 pAsm
->need_tex_barrier
= GL_TRUE
;
4823 // Set src1 to tex unit id
4824 pAsm
->S
[1].src
.reg
= pAsm
->pILInst
[pAsm
->uiCurInst
].TexSrcUnit
;
4825 pAsm
->S
[1].src
.rtype
= SRC_REG_TEMPORARY
;
4827 //No sw info from mesa compiler, so hard code here.
4828 pAsm
->S
[1].src
.swizzlex
= SQ_SEL_X
;
4829 pAsm
->S
[1].src
.swizzley
= SQ_SEL_Y
;
4830 pAsm
->S
[1].src
.swizzlez
= SQ_SEL_Z
;
4831 pAsm
->S
[1].src
.swizzlew
= SQ_SEL_W
;
4833 if( GL_FALSE
== tex_dst(pAsm
) )
4838 if( GL_FALSE
== tex_src(pAsm
) )
4843 if(pAsm
->pILInst
[pAsm
->uiCurInst
].Opcode
== OPCODE_TXP
)
4845 /* hopefully did swizzles before */
4846 noswizzle_PVSSRC(&(pAsm
->S
[0].src
));
4849 if(pAsm
->pILInst
[pAsm
->uiCurInst
].TexSrcTarget
== TEXTURE_CUBE_INDEX
)
4851 /* SAMPLE dst, tmp.yxwy, CUBE */
4852 pAsm
->S
[0].src
.swizzlex
= SQ_SEL_Y
;
4853 pAsm
->S
[0].src
.swizzley
= SQ_SEL_X
;
4854 pAsm
->S
[0].src
.swizzlez
= SQ_SEL_W
;
4855 pAsm
->S
[0].src
.swizzlew
= SQ_SEL_Y
;
4858 if ( GL_FALSE
== next_ins(pAsm
) )
4866 GLboolean
assemble_XPD(r700_AssemblerBase
*pAsm
)
4870 if( GL_FALSE
== checkop2(pAsm
) )
4875 tmp
= gethelpr(pAsm
);
4877 pAsm
->D
.dst
.opcode
= SQ_OP2_INST_MUL
;
4879 setaddrmode_PVSDST(&(pAsm
->D
.dst
), ADDR_ABSOLUTE
);
4880 pAsm
->D
.dst
.rtype
= DST_REG_TEMPORARY
;
4881 pAsm
->D
.dst
.reg
= tmp
;
4882 nomask_PVSDST(&(pAsm
->D
.dst
));
4884 if( GL_FALSE
== assemble_src(pAsm
, 0, -1) )
4889 if( GL_FALSE
== assemble_src(pAsm
, 1, -1) )
4894 swizzleagain_PVSSRC(&(pAsm
->S
[0].src
), SQ_SEL_Z
, SQ_SEL_X
, SQ_SEL_Y
, SQ_SEL_0
);
4895 swizzleagain_PVSSRC(&(pAsm
->S
[1].src
), SQ_SEL_Y
, SQ_SEL_Z
, SQ_SEL_X
, SQ_SEL_0
);
4897 if( GL_FALSE
== next_ins(pAsm
) )
4902 pAsm
->D
.dst
.opcode
= SQ_OP3_INST_MULADD
;
4903 pAsm
->D
.dst
.op3
= 1;
4905 if(0xF != pAsm
->pILInst
[pAsm
->uiCurInst
].DstReg
.WriteMask
)
4907 tmp
= gethelpr(pAsm
);
4909 setaddrmode_PVSDST(&(pAsm
->D
.dst
), ADDR_ABSOLUTE
);
4910 pAsm
->D
.dst
.rtype
= DST_REG_TEMPORARY
;
4911 pAsm
->D
.dst
.reg
= tmp
;
4913 nomask_PVSDST(&(pAsm
->D
.dst
));
4917 if( GL_FALSE
== assemble_dst(pAsm
) )
4923 if( GL_FALSE
== assemble_src(pAsm
, 0, -1) )
4928 if( GL_FALSE
== assemble_src(pAsm
, 1, -1) )
4933 swizzleagain_PVSSRC(&(pAsm
->S
[0].src
), SQ_SEL_Y
, SQ_SEL_Z
, SQ_SEL_X
, SQ_SEL_0
);
4934 swizzleagain_PVSSRC(&(pAsm
->S
[1].src
), SQ_SEL_Z
, SQ_SEL_X
, SQ_SEL_Y
, SQ_SEL_0
);
4936 // result1 + (neg) result0
4937 setaddrmode_PVSSRC(&(pAsm
->S
[2].src
),ADDR_ABSOLUTE
);
4938 pAsm
->S
[2].src
.rtype
= SRC_REG_TEMPORARY
;
4939 pAsm
->S
[2].src
.reg
= tmp
;
4941 neg_PVSSRC(&(pAsm
->S
[2].src
));
4942 noswizzle_PVSSRC(&(pAsm
->S
[2].src
));
4944 if( GL_FALSE
== next_ins(pAsm
) )
4950 if(0xF != pAsm
->pILInst
[pAsm
->uiCurInst
].DstReg
.WriteMask
)
4952 if( GL_FALSE
== assemble_dst(pAsm
) )
4957 pAsm
->D
.dst
.opcode
= SQ_OP2_INST_MOV
;
4959 // Use tmp as source
4960 setaddrmode_PVSSRC(&(pAsm
->S
[0].src
), ADDR_ABSOLUTE
);
4961 pAsm
->S
[0].src
.rtype
= SRC_REG_TEMPORARY
;
4962 pAsm
->S
[0].src
.reg
= tmp
;
4964 noneg_PVSSRC(&(pAsm
->S
[0].src
));
4965 noswizzle_PVSSRC(&(pAsm
->S
[0].src
));
4967 if( GL_FALSE
== next_ins(pAsm
) )
4976 GLboolean
assemble_EXPORT(r700_AssemblerBase
*pAsm
)
4981 GLboolean
jumpToOffest(r700_AssemblerBase
*pAsm
, GLuint pops
, GLint offset
)
4983 if(GL_FALSE
== add_cf_instruction(pAsm
) )
4988 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.pop_count
= pops
;
4989 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.cf_const
= 0x0;
4990 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.cond
= SQ_CF_COND_ACTIVE
;
4992 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.end_of_program
= 0x0;
4993 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.valid_pixel_mode
= 0x0;
4994 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.cf_inst
= SQ_CF_INST_JUMP
;
4995 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.whole_quad_mode
= 0x0;
4997 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.barrier
= 0x1;
4999 pAsm
->cf_current_cf_clause_ptr
->m_Word0
.f
.addr
= pAsm
->cf_current_cf_clause_ptr
->m_uIndex
+ offset
;
5004 GLboolean
pops(r700_AssemblerBase
*pAsm
, GLuint pops
)
5006 if(GL_FALSE
== add_cf_instruction(pAsm
) )
5011 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.pop_count
= pops
;
5012 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.cf_const
= 0x0;
5013 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.cond
= SQ_CF_COND_ACTIVE
;
5015 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.end_of_program
= 0x0;
5016 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.valid_pixel_mode
= 0x0;
5017 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.cf_inst
= SQ_CF_INST_POP
;
5019 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.whole_quad_mode
= 0x0;
5021 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.barrier
= 0x1;
5022 pAsm
->cf_current_cf_clause_ptr
->m_Word0
.f
.addr
= pAsm
->cf_current_cf_clause_ptr
->m_uIndex
+ 1;
5027 GLboolean
assemble_IF(r700_AssemblerBase
*pAsm
)
5029 if(GL_FALSE
== add_cf_instruction(pAsm
) )
5034 if(GL_TRUE
!= bHasElse
)
5036 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.pop_count
= 1;
5040 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.pop_count
= 0;
5042 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.cf_const
= 0x0;
5043 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.cond
= SQ_CF_COND_ACTIVE
;
5045 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.end_of_program
= 0x0;
5046 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.valid_pixel_mode
= 0x0;
5047 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.cf_inst
= SQ_CF_INST_JUMP
;
5048 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.whole_quad_mode
= 0x0;
5050 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.barrier
= 0x1;
5053 pAsm
->fc_stack
[pAsm
->FCSP
].type
= FC_IF
;
5054 pAsm
->fc_stack
[pAsm
->FCSP
].bpush
= 0;
5055 pAsm
->fc_stack
[pAsm
->FCSP
].mid
= NULL
;
5056 pAsm
->fc_stack
[pAsm
->FCSP
].midLen
= 0;
5057 pAsm
->fc_stack
[pAsm
->FCSP
].first
= pAsm
->cf_current_cf_clause_ptr
;
5059 if(GL_TRUE
!= bHasElse
)
5061 pAsm
->alu_x_opcode
= SQ_CF_INST_ALU_POP_AFTER
;
5064 pAsm
->branch_depth
++;
5066 if(pAsm
->branch_depth
> pAsm
->max_branch_depth
)
5068 pAsm
->max_branch_depth
= pAsm
->branch_depth
;
5073 GLboolean
assemble_ELSE(r700_AssemblerBase
*pAsm
)
5075 if(GL_FALSE
== add_cf_instruction(pAsm
) )
5080 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.pop_count
= 1; ///
5081 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.cf_const
= 0x0;
5082 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.cond
= SQ_CF_COND_ACTIVE
;
5084 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.end_of_program
= 0x0;
5085 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.valid_pixel_mode
= 0x0;
5086 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.cf_inst
= SQ_CF_INST_ELSE
;
5087 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.whole_quad_mode
= 0x0;
5089 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.barrier
= 0x1;
5091 pAsm
->fc_stack
[pAsm
->FCSP
].mid
= (R700ControlFlowGenericClause
**)_mesa_realloc( (void *)pAsm
->fc_stack
[pAsm
->FCSP
].mid
,
5093 sizeof(R700ControlFlowGenericClause
*) );
5094 pAsm
->fc_stack
[pAsm
->FCSP
].mid
[0] = pAsm
->cf_current_cf_clause_ptr
;
5095 //pAsm->fc_stack[pAsm->FCSP].unNumMid = 1;
5097 pAsm
->alu_x_opcode
= SQ_CF_INST_ALU_POP_AFTER
;
5099 pAsm
->fc_stack
[pAsm
->FCSP
].first
->m_Word0
.f
.addr
= pAsm
->pR700Shader
->plstCFInstructions_active
->uNumOfNode
- 1;
5104 GLboolean
assemble_ENDIF(r700_AssemblerBase
*pAsm
)
5106 pAsm
->alu_x_opcode
= SQ_CF_INST_ALU
;
5108 if(NULL
== pAsm
->fc_stack
[pAsm
->FCSP
].mid
)
5110 /* no else in between */
5111 pAsm
->fc_stack
[pAsm
->FCSP
].first
->m_Word0
.f
.addr
= pAsm
->pR700Shader
->plstCFInstructions_active
->uNumOfNode
;
5115 pAsm
->fc_stack
[pAsm
->FCSP
].mid
[0]->m_Word0
.f
.addr
= pAsm
->pR700Shader
->plstCFInstructions_active
->uNumOfNode
;
5118 if(NULL
!= pAsm
->fc_stack
[pAsm
->FCSP
].mid
)
5120 FREE(pAsm
->fc_stack
[pAsm
->FCSP
].mid
);
5123 if(pAsm
->fc_stack
[pAsm
->FCSP
].type
!= FC_IF
)
5125 radeon_error("if/endif in shader code are not paired. \n");
5128 pAsm
->branch_depth
--;
5134 GLboolean
assemble_BGNLOOP(r700_AssemblerBase
*pAsm
)
5136 if(GL_FALSE
== add_cf_instruction(pAsm
) )
5142 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.pop_count
= 0;
5143 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.cf_const
= 0x0;
5144 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.cond
= SQ_CF_COND_ACTIVE
;
5146 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.end_of_program
= 0x0;
5147 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.valid_pixel_mode
= 0x0;
5148 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.cf_inst
= SQ_CF_INST_LOOP_START_NO_AL
;
5149 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.whole_quad_mode
= 0x0;
5151 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.barrier
= 0x1;
5154 pAsm
->fc_stack
[pAsm
->FCSP
].type
= FC_LOOP
;
5155 pAsm
->fc_stack
[pAsm
->FCSP
].bpush
= 1;
5156 pAsm
->fc_stack
[pAsm
->FCSP
].mid
= NULL
;
5157 pAsm
->fc_stack
[pAsm
->FCSP
].unNumMid
= 0;
5158 pAsm
->fc_stack
[pAsm
->FCSP
].midLen
= 0;
5159 pAsm
->fc_stack
[pAsm
->FCSP
].first
= pAsm
->cf_current_cf_clause_ptr
;
5161 pAsm
->branch_depth
++;
5163 if(pAsm
->branch_depth
> pAsm
->max_branch_depth
)
5165 pAsm
->max_branch_depth
= pAsm
->branch_depth
;
5170 GLboolean
assemble_BRK(r700_AssemblerBase
*pAsm
)
5172 #ifdef USE_CF_FOR_CONTINUE_BREAK
5173 unsigned int unFCSP
;
5174 for(unFCSP
=pAsm
->FCSP
; unFCSP
>0; unFCSP
--)
5176 if(FC_LOOP
== pAsm
->fc_stack
[unFCSP
].type
)
5183 radeon_error("Break is not inside loop/endloop pair.\n");
5187 if(GL_FALSE
== add_cf_instruction(pAsm
) )
5193 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.pop_count
= 1;
5194 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.cf_const
= 0x0;
5195 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.cond
= SQ_CF_COND_ACTIVE
;
5197 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.end_of_program
= 0x0;
5198 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.valid_pixel_mode
= 0x0;
5199 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.cf_inst
= SQ_CF_INST_LOOP_BREAK
;
5201 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.whole_quad_mode
= 0x0;
5203 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.barrier
= 0x1;
5205 pAsm
->fc_stack
[unFCSP
].mid
= (R700ControlFlowGenericClause
**)_mesa_realloc(
5206 (void *)pAsm
->fc_stack
[unFCSP
].mid
,
5207 sizeof(R700ControlFlowGenericClause
*) * pAsm
->fc_stack
[unFCSP
].unNumMid
,
5208 sizeof(R700ControlFlowGenericClause
*) * (pAsm
->fc_stack
[unFCSP
].unNumMid
+ 1) );
5209 pAsm
->fc_stack
[unFCSP
].mid
[pAsm
->fc_stack
[unFCSP
].unNumMid
] = pAsm
->cf_current_cf_clause_ptr
;
5210 pAsm
->fc_stack
[unFCSP
].unNumMid
++;
5212 if(GL_FALSE
== add_cf_instruction(pAsm
) )
5217 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.pop_count
= 1;
5218 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.cf_const
= 0x0;
5219 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.cond
= SQ_CF_COND_ACTIVE
;
5221 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.end_of_program
= 0x0;
5222 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.valid_pixel_mode
= 0x0;
5223 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.cf_inst
= SQ_CF_INST_POP
;
5225 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.whole_quad_mode
= 0x0;
5227 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.barrier
= 0x1;
5228 pAsm
->cf_current_cf_clause_ptr
->m_Word0
.f
.addr
= pAsm
->cf_current_cf_clause_ptr
->m_uIndex
+ 1;
5230 #endif //USE_CF_FOR_CONTINUE_BREAK
5234 GLboolean
assemble_CONT(r700_AssemblerBase
*pAsm
)
5236 #ifdef USE_CF_FOR_CONTINUE_BREAK
5237 unsigned int unFCSP
;
5238 for(unFCSP
=pAsm
->FCSP
; unFCSP
>0; unFCSP
--)
5240 if(FC_LOOP
== pAsm
->fc_stack
[unFCSP
].type
)
5247 radeon_error("Continue is not inside loop/endloop pair.\n");
5251 if(GL_FALSE
== add_cf_instruction(pAsm
) )
5257 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.pop_count
= 1;
5258 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.cf_const
= 0x0;
5259 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.cond
= SQ_CF_COND_ACTIVE
;
5261 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.end_of_program
= 0x0;
5262 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.valid_pixel_mode
= 0x0;
5263 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.cf_inst
= SQ_CF_INST_LOOP_CONTINUE
;
5265 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.whole_quad_mode
= 0x0;
5267 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.barrier
= 0x1;
5269 pAsm
->fc_stack
[unFCSP
].mid
= (R700ControlFlowGenericClause
**)_mesa_realloc(
5270 (void *)pAsm
->fc_stack
[unFCSP
].mid
,
5271 sizeof(R700ControlFlowGenericClause
*) * pAsm
->fc_stack
[unFCSP
].unNumMid
,
5272 sizeof(R700ControlFlowGenericClause
*) * (pAsm
->fc_stack
[unFCSP
].unNumMid
+ 1) );
5273 pAsm
->fc_stack
[unFCSP
].mid
[pAsm
->fc_stack
[unFCSP
].unNumMid
] = pAsm
->cf_current_cf_clause_ptr
;
5274 pAsm
->fc_stack
[unFCSP
].unNumMid
++;
5276 if(GL_FALSE
== add_cf_instruction(pAsm
) )
5281 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.pop_count
= 1;
5282 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.cf_const
= 0x0;
5283 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.cond
= SQ_CF_COND_ACTIVE
;
5285 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.end_of_program
= 0x0;
5286 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.valid_pixel_mode
= 0x0;
5287 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.cf_inst
= SQ_CF_INST_POP
;
5289 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.whole_quad_mode
= 0x0;
5291 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.barrier
= 0x1;
5292 pAsm
->cf_current_cf_clause_ptr
->m_Word0
.f
.addr
= pAsm
->cf_current_cf_clause_ptr
->m_uIndex
+ 1;
5294 #endif /* USE_CF_FOR_CONTINUE_BREAK */
5299 GLboolean
assemble_ENDLOOP(r700_AssemblerBase
*pAsm
)
5303 if(GL_FALSE
== add_cf_instruction(pAsm
) )
5309 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.pop_count
= 0;
5310 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.cf_const
= 0x0;
5311 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.cond
= SQ_CF_COND_ACTIVE
;
5313 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.end_of_program
= 0x0;
5314 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.valid_pixel_mode
= 0x0;
5315 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.cf_inst
= SQ_CF_INST_LOOP_END
;
5316 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.whole_quad_mode
= 0x0;
5318 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.barrier
= 0x1;
5320 pAsm
->cf_current_cf_clause_ptr
->m_Word0
.f
.addr
= pAsm
->fc_stack
[pAsm
->FCSP
].first
->m_uIndex
+ 1;
5321 pAsm
->fc_stack
[pAsm
->FCSP
].first
->m_Word0
.f
.addr
= pAsm
->cf_current_cf_clause_ptr
->m_uIndex
+ 1;
5323 #ifdef USE_CF_FOR_CONTINUE_BREAK
5324 for(i
=0; i
<pAsm
->fc_stack
[pAsm
->FCSP
].unNumMid
; i
++)
5326 pAsm
->fc_stack
[pAsm
->FCSP
].mid
[i
]->m_Word0
.f
.addr
= pAsm
->cf_current_cf_clause_ptr
->m_uIndex
;
5328 if(NULL
!= pAsm
->fc_stack
[pAsm
->FCSP
].mid
)
5330 FREE(pAsm
->fc_stack
[pAsm
->FCSP
].mid
);
5334 if(pAsm
->fc_stack
[pAsm
->FCSP
].type
!= FC_LOOP
)
5336 radeon_error("loop/endloop in shader code are not paired. \n");
5340 unsigned int unFCSP
= 0;
5341 if((pAsm
->unCFflags
& HAS_CURRENT_LOOPRET
) > 0)
5343 for(unFCSP
=(pAsm
->FCSP
-1); unFCSP
>pAsm
->CALLSTACK
[pAsm
->CALLSP
].FCSP_BeforeEntry
; unFCSP
--)
5345 if(FC_LOOP
== pAsm
->fc_stack
[unFCSP
].type
)
5350 if(unFCSP
<= pAsm
->CALLSTACK
[pAsm
->CALLSP
].FCSP_BeforeEntry
)
5355 pAsm
->unCFflags
&= ~HAS_CURRENT_LOOPRET
;
5359 pAsm
->branch_depth
--;
5364 breakLoopOnFlag(pAsm
, unFCSP
);
5370 void add_return_inst(r700_AssemblerBase
*pAsm
)
5372 if(GL_FALSE
== add_cf_instruction(pAsm
) )
5376 //pAsm->cf_current_cf_clause_ptr->m_Word1.f.pop_count = 1;
5377 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.pop_count
= 0;
5378 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.cf_const
= 0x0;
5379 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.cond
= SQ_CF_COND_ACTIVE
;
5381 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.end_of_program
= 0x0;
5382 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.valid_pixel_mode
= 0x0;
5383 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.cf_inst
= SQ_CF_INST_RETURN
;
5384 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.whole_quad_mode
= 0x0;
5386 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.barrier
= 0x1;
5389 GLboolean
assemble_BGNSUB(r700_AssemblerBase
*pAsm
, GLint nILindex
)
5392 if( (pAsm
->unSubArrayPointer
+ 1) > pAsm
->unSubArraySize
)
5394 pAsm
->subs
= (SUB_OFFSET
*)_mesa_realloc( (void *)pAsm
->subs
,
5395 sizeof(SUB_OFFSET
) * pAsm
->unSubArraySize
,
5396 sizeof(SUB_OFFSET
) * (pAsm
->unSubArraySize
+ 10) );
5397 if(NULL
== pAsm
->subs
)
5401 pAsm
->unSubArraySize
+= 10;
5404 pAsm
->subs
[pAsm
->unSubArrayPointer
].subIL_Offset
= nILindex
;
5405 pAsm
->subs
[pAsm
->unSubArrayPointer
].lstCFInstructions_local
.pHead
=NULL
;
5406 pAsm
->subs
[pAsm
->unSubArrayPointer
].lstCFInstructions_local
.pTail
=NULL
;
5407 pAsm
->subs
[pAsm
->unSubArrayPointer
].lstCFInstructions_local
.uNumOfNode
=0;
5410 pAsm
->CALLSTACK
[pAsm
->CALLSP
].FCSP_BeforeEntry
= pAsm
->FCSP
;
5411 pAsm
->CALLSTACK
[pAsm
->CALLSP
].plstCFInstructions_local
5412 = &(pAsm
->subs
[pAsm
->unSubArrayPointer
].lstCFInstructions_local
);
5413 SetActiveCFlist(pAsm
->pR700Shader
,
5414 pAsm
->CALLSTACK
[pAsm
->CALLSP
].plstCFInstructions_local
);
5416 pAsm
->unSubArrayPointer
++;
5419 pAsm
->alu_x_opcode
= SQ_CF_INST_ALU
;
5424 GLboolean
assemble_ENDSUB(r700_AssemblerBase
*pAsm
)
5427 SetActiveCFlist(pAsm
->pR700Shader
,
5428 pAsm
->CALLSTACK
[pAsm
->CALLSP
].plstCFInstructions_local
);
5430 pAsm
->alu_x_opcode
= SQ_CF_INST_ALU
;
5435 GLboolean
assemble_RET(r700_AssemblerBase
*pAsm
)
5437 if(pAsm
->CALLSP
> 0)
5439 unsigned int unFCSP
;
5440 for(unFCSP
=pAsm
->FCSP
; unFCSP
>pAsm
->CALLSTACK
[pAsm
->CALLSP
].FCSP_BeforeEntry
; unFCSP
--)
5442 if(FC_LOOP
== pAsm
->fc_stack
[unFCSP
].type
)
5444 setRetInLoopFlag(pAsm
, SQ_SEL_1
);
5445 breakLoopOnFlag(pAsm
, unFCSP
);
5446 pAsm
->unCFflags
|= LOOPRET_FLAGS
;
5453 add_return_inst(pAsm
);
5458 GLboolean
assemble_CAL(r700_AssemblerBase
*pAsm
,
5460 GLuint uiNumberInsts
,
5461 struct prog_instruction
*pILInst
)
5463 pAsm
->alu_x_opcode
= SQ_CF_INST_ALU
;
5465 if(GL_FALSE
== add_cf_instruction(pAsm
) )
5470 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.call_count
= 1;
5471 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.pop_count
= 0;
5472 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.cf_const
= 0x0;
5473 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.cond
= SQ_CF_COND_ACTIVE
;
5475 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.end_of_program
= 0x0;
5476 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.valid_pixel_mode
= 0x0;
5477 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.cf_inst
= SQ_CF_INST_CALL
;
5478 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.whole_quad_mode
= 0x0;
5480 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.barrier
= 0x1;
5483 if( (pAsm
->unCallerArrayPointer
+ 1) > pAsm
->unCallerArraySize
)
5485 pAsm
->callers
= (CALLER_POINTER
*)_mesa_realloc( (void *)pAsm
->callers
,
5486 sizeof(CALLER_POINTER
) * pAsm
->unCallerArraySize
,
5487 sizeof(CALLER_POINTER
) * (pAsm
->unCallerArraySize
+ 10) );
5488 if(NULL
== pAsm
->callers
)
5492 pAsm
->unCallerArraySize
+= 10;
5495 pAsm
->callers
[pAsm
->unCallerArrayPointer
].subIL_Offset
= nILindex
;
5496 pAsm
->callers
[pAsm
->unCallerArrayPointer
].cf_ptr
= pAsm
->cf_current_cf_clause_ptr
;
5498 pAsm
->unCallerArrayPointer
++;
5501 for(j
=0; j
<pAsm
->unSubArrayPointer
; j
++)
5503 if(nILindex
== pAsm
->subs
[j
].subIL_Offset
)
5504 { /* compiled before */
5505 pAsm
->callers
[pAsm
->unCallerArrayPointer
- 1].subDescIndex
= j
;
5510 pAsm
->callers
[pAsm
->unCallerArrayPointer
- 1].subDescIndex
= pAsm
->unSubArrayPointer
;
5512 return AssembleInstr(nILindex
, uiNumberInsts
, pILInst
, pAsm
);
5515 GLboolean
setRetInLoopFlag(r700_AssemblerBase
*pAsm
, GLuint flagValue
)
5517 GLfloat fLiteral
[2] = {0.1, 0.0};
5519 pAsm
->D
.dst
.opcode
= SQ_OP2_INST_MOV
;
5520 pAsm
->D
.dst
.op3
= 0;
5521 pAsm
->D
.dst
.rtype
= DST_REG_TEMPORARY
;
5522 pAsm
->D
.dst
.reg
= pAsm
->flag_reg_index
;
5523 pAsm
->D
.dst
.writex
= 1;
5524 pAsm
->D
.dst
.writey
= 0;
5525 pAsm
->D
.dst
.writez
= 0;
5526 pAsm
->D
.dst
.writew
= 0;
5527 pAsm
->D2
.dst2
.literal
= 1;
5528 pAsm
->D2
.dst2
.SaturateMode
= SATURATE_OFF
;
5529 pAsm
->D
.dst
.predicated
= 0;
5531 pAsm
->S
[0].src
.rtype
= SRC_REC_LITERAL
;
5532 //pAsm->S[0].src.reg = 0;
5533 setaddrmode_PVSSRC(&(pAsm
->S
[0].src
), ADDR_ABSOLUTE
);
5534 noneg_PVSSRC(&(pAsm
->S
[0].src
));
5535 pAsm
->S
[0].src
.swizzlex
= SQ_SEL_X
;
5536 pAsm
->S
[0].src
.swizzley
= SQ_SEL_Y
;
5537 pAsm
->S
[0].src
.swizzlez
= SQ_SEL_Z
;
5538 pAsm
->S
[0].src
.swizzlew
= SQ_SEL_W
;
5540 if( GL_FALSE
== next_ins_literal(pAsm
, &(fLiteral
[0])) )
5545 pAsm
->S
[0].src
.rtype
= DST_REG_TEMPORARY
;
5546 pAsm
->S
[0].src
.reg
= 0;
5547 setaddrmode_PVSSRC(&(pAsm
->S
[0].src
), ADDR_ABSOLUTE
);
5548 noneg_PVSSRC(&(pAsm
->S
[0].src
));
5549 pAsm
->S
[0].src
.swizzlex
= flagValue
;
5550 pAsm
->S
[0].src
.swizzley
= flagValue
;
5551 pAsm
->S
[0].src
.swizzlez
= flagValue
;
5552 pAsm
->S
[0].src
.swizzlew
= flagValue
;
5554 if( GL_FALSE
== next_ins2(pAsm
) )
5563 GLboolean
testFlag(r700_AssemblerBase
*pAsm
)
5565 GLfloat fLiteral
[2] = {0.1, 0.0};
5568 GLuint tmp
= gethelpr(pAsm
);
5569 pAsm
->alu_x_opcode
= SQ_CF_INST_ALU_PUSH_BEFORE
;
5571 pAsm
->D
.dst
.opcode
= SQ_OP2_INST_PRED_SETE
;
5572 pAsm
->D
.dst
.math
= 1;
5573 pAsm
->D
.dst
.rtype
= DST_REG_TEMPORARY
;
5574 pAsm
->D
.dst
.reg
= tmp
;
5575 pAsm
->D
.dst
.writex
= 1;
5576 pAsm
->D
.dst
.writey
= 0;
5577 pAsm
->D
.dst
.writez
= 0;
5578 pAsm
->D
.dst
.writew
= 0;
5579 pAsm
->D2
.dst2
.literal
= 1;
5580 pAsm
->D2
.dst2
.SaturateMode
= SATURATE_OFF
;
5581 pAsm
->D
.dst
.predicated
= 1;
5583 pAsm
->S
[0].src
.rtype
= DST_REG_TEMPORARY
;
5584 pAsm
->S
[0].src
.reg
= pAsm
->flag_reg_index
;
5585 setaddrmode_PVSSRC(&(pAsm
->S
[0].src
), ADDR_ABSOLUTE
);
5586 noneg_PVSSRC(&(pAsm
->S
[0].src
));
5587 pAsm
->S
[0].src
.swizzlex
= SQ_SEL_X
;
5588 pAsm
->S
[0].src
.swizzley
= SQ_SEL_Y
;
5589 pAsm
->S
[0].src
.swizzlez
= SQ_SEL_Z
;
5590 pAsm
->S
[0].src
.swizzlew
= SQ_SEL_W
;
5592 pAsm
->S
[1].src
.rtype
= SRC_REC_LITERAL
;
5593 //pAsm->S[1].src.reg = 0;
5594 setaddrmode_PVSSRC(&(pAsm
->S
[1].src
), ADDR_ABSOLUTE
);
5595 noneg_PVSSRC(&(pAsm
->S
[1].src
));
5596 pAsm
->S
[1].src
.swizzlex
= SQ_SEL_X
;
5597 pAsm
->S
[1].src
.swizzley
= SQ_SEL_Y
;
5598 pAsm
->S
[1].src
.swizzlez
= SQ_SEL_Z
;
5599 pAsm
->S
[1].src
.swizzlew
= SQ_SEL_W
;
5601 if( GL_FALSE
== next_ins_literal(pAsm
, &(fLiteral
[0])) )
5606 pAsm
->S
[1].src
.rtype
= DST_REG_TEMPORARY
;
5607 pAsm
->S
[1].src
.reg
= 0;
5608 setaddrmode_PVSSRC(&(pAsm
->S
[1].src
), ADDR_ABSOLUTE
);
5609 noneg_PVSSRC(&(pAsm
->S
[1].src
));
5610 pAsm
->S
[1].src
.swizzlex
= SQ_SEL_1
;
5611 pAsm
->S
[1].src
.swizzley
= SQ_SEL_1
;
5612 pAsm
->S
[1].src
.swizzlez
= SQ_SEL_1
;
5613 pAsm
->S
[1].src
.swizzlew
= SQ_SEL_1
;
5615 if( GL_FALSE
== next_ins2(pAsm
) )
5624 GLboolean
returnOnFlag(r700_AssemblerBase
*pAsm
)
5627 jumpToOffest(pAsm
, 1, 4);
5628 setRetInLoopFlag(pAsm
, SQ_SEL_0
);
5630 add_return_inst(pAsm
);
5635 GLboolean
breakLoopOnFlag(r700_AssemblerBase
*pAsm
, GLuint unFCSP
)
5640 if(GL_FALSE
== add_cf_instruction(pAsm
) )
5645 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.pop_count
= 1;
5646 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.cf_const
= 0x0;
5647 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.cond
= SQ_CF_COND_ACTIVE
;
5649 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.end_of_program
= 0x0;
5650 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.valid_pixel_mode
= 0x0;
5651 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.cf_inst
= SQ_CF_INST_LOOP_BREAK
;
5652 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.whole_quad_mode
= 0x0;
5654 pAsm
->cf_current_cf_clause_ptr
->m_Word1
.f
.barrier
= 0x1;
5656 pAsm
->fc_stack
[unFCSP
].mid
= (R700ControlFlowGenericClause
**)_mesa_realloc(
5657 (void *)pAsm
->fc_stack
[unFCSP
].mid
,
5658 sizeof(R700ControlFlowGenericClause
*) * pAsm
->fc_stack
[unFCSP
].unNumMid
,
5659 sizeof(R700ControlFlowGenericClause
*) * (pAsm
->fc_stack
[unFCSP
].unNumMid
+ 1) );
5660 pAsm
->fc_stack
[unFCSP
].mid
[pAsm
->fc_stack
[unFCSP
].unNumMid
] = pAsm
->cf_current_cf_clause_ptr
;
5661 pAsm
->fc_stack
[unFCSP
].unNumMid
++;
5668 GLboolean
AssembleInstr(GLuint uiFirstInst
,
5669 GLuint uiNumberInsts
,
5670 struct prog_instruction
*pILInst
,
5671 r700_AssemblerBase
*pR700AsmCode
)
5675 pR700AsmCode
->pILInst
= pILInst
;
5676 for(i
=uiFirstInst
; i
<uiNumberInsts
; i
++)
5678 pR700AsmCode
->uiCurInst
= i
;
5680 #ifndef USE_CF_FOR_CONTINUE_BREAK
5681 if(OPCODE_BRK
== pILInst
[i
+1].Opcode
)
5683 switch(pILInst
[i
].Opcode
)
5686 pILInst
[i
].Opcode
= OPCODE_SGT
;
5689 pILInst
[i
].Opcode
= OPCODE_SGE
;
5692 pILInst
[i
].Opcode
= OPCODE_SLT
;
5695 pILInst
[i
].Opcode
= OPCODE_SLE
;
5698 pILInst
[i
].Opcode
= OPCODE_SNE
;
5701 pILInst
[i
].Opcode
= OPCODE_SEQ
;
5709 switch (pILInst
[i
].Opcode
)
5712 if ( GL_FALSE
== assemble_ABS(pR700AsmCode
) )
5717 if ( GL_FALSE
== assemble_ADD(pR700AsmCode
) )
5722 if ( GL_FALSE
== assemble_ARL(pR700AsmCode
) )
5726 radeon_error("Not yet implemented instruction OPCODE_ARR \n");
5727 //if ( GL_FALSE == assemble_BAD("ARR") )
5732 if ( GL_FALSE
== assemble_CMP(pR700AsmCode
) )
5736 if ( GL_FALSE
== assemble_COS(pR700AsmCode
) )
5743 if ( GL_FALSE
== assemble_DOT(pR700AsmCode
) )
5748 if ( GL_FALSE
== assemble_DST(pR700AsmCode
) )
5753 if ( GL_FALSE
== assemble_EX2(pR700AsmCode
) )
5757 if ( GL_FALSE
== assemble_EXP(pR700AsmCode
) )
5762 if ( GL_FALSE
== assemble_FLR(pR700AsmCode
) )
5766 // if ( GL_FALSE == assemble_FLR_INT() )
5771 if ( GL_FALSE
== assemble_FRC(pR700AsmCode
) )
5776 if ( GL_FALSE
== assemble_KIL(pR700AsmCode
) )
5780 if ( GL_FALSE
== assemble_LG2(pR700AsmCode
) )
5784 if ( GL_FALSE
== assemble_LIT(pR700AsmCode
) )
5788 if ( GL_FALSE
== assemble_LRP(pR700AsmCode
) )
5792 if ( GL_FALSE
== assemble_LOG(pR700AsmCode
) )
5797 if ( GL_FALSE
== assemble_MAD(pR700AsmCode
) )
5801 if ( GL_FALSE
== assemble_MAX(pR700AsmCode
) )
5805 if ( GL_FALSE
== assemble_MIN(pR700AsmCode
) )
5810 if ( GL_FALSE
== assemble_MOV(pR700AsmCode
) )
5814 if ( GL_FALSE
== assemble_MUL(pR700AsmCode
) )
5819 if ( GL_FALSE
== assemble_POW(pR700AsmCode
) )
5823 if ( GL_FALSE
== assemble_RCP(pR700AsmCode
) )
5827 if ( GL_FALSE
== assemble_RSQ(pR700AsmCode
) )
5831 if ( GL_FALSE
== assemble_SIN(pR700AsmCode
) )
5835 if ( GL_FALSE
== assemble_SCS(pR700AsmCode
) )
5840 if(OPCODE_IF
== pILInst
[i
+1].Opcode
)
5842 pR700AsmCode
->alu_x_opcode
= SQ_CF_INST_ALU_PUSH_BEFORE
;
5843 if ( GL_FALSE
== assemble_LOGIC_PRED(pR700AsmCode
, SQ_OP2_INST_PRED_SETE
) )
5848 else if(OPCODE_BRK
== pILInst
[i
+1].Opcode
)
5850 #ifdef USE_CF_FOR_CONTINUE_BREAK
5851 pR700AsmCode
->alu_x_opcode
= SQ_CF_INST_ALU_PUSH_BEFORE
;
5853 pR700AsmCode
->alu_x_opcode
= SQ_CF_INST_ALU_BREAK
;
5855 if ( GL_FALSE
== assemble_LOGIC_PRED(pR700AsmCode
, SQ_OP2_INST_PRED_SETE
) )
5860 else if(OPCODE_CONT
== pILInst
[i
+1].Opcode
)
5862 #ifdef USE_CF_FOR_CONTINUE_BREAK
5863 pR700AsmCode
->alu_x_opcode
= SQ_CF_INST_ALU_PUSH_BEFORE
;
5865 pR700AsmCode
->alu_x_opcode
= SQ_CF_INST_ALU_CONTINUE
;
5867 if ( GL_FALSE
== assemble_LOGIC_PRED(pR700AsmCode
, SQ_OP2_INST_PRED_SETE
) )
5874 if ( GL_FALSE
== assemble_LOGIC(pR700AsmCode
, SQ_OP2_INST_SETE
) )
5882 if(OPCODE_IF
== pILInst
[i
+1].Opcode
)
5884 pR700AsmCode
->alu_x_opcode
= SQ_CF_INST_ALU_PUSH_BEFORE
;
5885 if ( GL_FALSE
== assemble_LOGIC_PRED(pR700AsmCode
, SQ_OP2_INST_PRED_SETGT
) )
5890 else if(OPCODE_BRK
== pILInst
[i
+1].Opcode
)
5892 #ifdef USE_CF_FOR_CONTINUE_BREAK
5893 pR700AsmCode
->alu_x_opcode
= SQ_CF_INST_ALU_PUSH_BEFORE
;
5895 pR700AsmCode
->alu_x_opcode
= SQ_CF_INST_ALU_BREAK
;
5897 if ( GL_FALSE
== assemble_LOGIC_PRED(pR700AsmCode
, SQ_OP2_INST_PRED_SETGT
) )
5902 else if(OPCODE_CONT
== pILInst
[i
+1].Opcode
)
5904 #ifdef USE_CF_FOR_CONTINUE_BREAK
5905 pR700AsmCode
->alu_x_opcode
= SQ_CF_INST_ALU_PUSH_BEFORE
;
5907 pR700AsmCode
->alu_x_opcode
= SQ_CF_INST_ALU_CONTINUE
;
5910 if ( GL_FALSE
== assemble_LOGIC_PRED(pR700AsmCode
, SQ_OP2_INST_PRED_SETGT
) )
5917 if ( GL_FALSE
== assemble_LOGIC(pR700AsmCode
, SQ_OP2_INST_SETGT
) )
5925 if(OPCODE_IF
== pILInst
[i
+1].Opcode
)
5927 pR700AsmCode
->alu_x_opcode
= SQ_CF_INST_ALU_PUSH_BEFORE
;
5928 if ( GL_FALSE
== assemble_LOGIC_PRED(pR700AsmCode
, SQ_OP2_INST_PRED_SETGE
) )
5933 else if(OPCODE_BRK
== pILInst
[i
+1].Opcode
)
5935 #ifdef USE_CF_FOR_CONTINUE_BREAK
5936 pR700AsmCode
->alu_x_opcode
= SQ_CF_INST_ALU_PUSH_BEFORE
;
5938 pR700AsmCode
->alu_x_opcode
= SQ_CF_INST_ALU_BREAK
;
5940 if ( GL_FALSE
== assemble_LOGIC_PRED(pR700AsmCode
, SQ_OP2_INST_PRED_SETGE
) )
5945 else if(OPCODE_CONT
== pILInst
[i
+1].Opcode
)
5947 #ifdef USE_CF_FOR_CONTINUE_BREAK
5948 pR700AsmCode
->alu_x_opcode
= SQ_CF_INST_ALU_PUSH_BEFORE
;
5950 pR700AsmCode
->alu_x_opcode
= SQ_CF_INST_ALU_CONTINUE
;
5953 if ( GL_FALSE
== assemble_LOGIC_PRED(pR700AsmCode
, SQ_OP2_INST_PRED_SETGE
) )
5960 if ( GL_FALSE
== assemble_SGE(pR700AsmCode
) )
5967 /* NO LT, LE, TODO : use GE => LE, GT => LT : reverse 2 src order would be simpliest. Or use SQ_CF_COND_FALSE for SQ_CF_COND_ACTIVE.*/
5970 struct prog_src_register SrcRegSave
[2];
5971 SrcRegSave
[0] = pILInst
[i
].SrcReg
[0];
5972 SrcRegSave
[1] = pILInst
[i
].SrcReg
[1];
5973 pILInst
[i
].SrcReg
[0] = SrcRegSave
[1];
5974 pILInst
[i
].SrcReg
[1] = SrcRegSave
[0];
5975 if(OPCODE_IF
== pILInst
[i
+1].Opcode
)
5977 pR700AsmCode
->alu_x_opcode
= SQ_CF_INST_ALU_PUSH_BEFORE
;
5978 if ( GL_FALSE
== assemble_LOGIC_PRED(pR700AsmCode
, SQ_OP2_INST_PRED_SETGT
) )
5980 pILInst
[i
].SrcReg
[0] = SrcRegSave
[0];
5981 pILInst
[i
].SrcReg
[1] = SrcRegSave
[1];
5985 else if(OPCODE_BRK
== pILInst
[i
+1].Opcode
)
5987 #ifdef USE_CF_FOR_CONTINUE_BREAK
5988 pR700AsmCode
->alu_x_opcode
= SQ_CF_INST_ALU_PUSH_BEFORE
;
5990 pR700AsmCode
->alu_x_opcode
= SQ_CF_INST_ALU_BREAK
;
5992 if ( GL_FALSE
== assemble_LOGIC_PRED(pR700AsmCode
, SQ_OP2_INST_PRED_SETGT
) )
5994 pILInst
[i
].SrcReg
[0] = SrcRegSave
[0];
5995 pILInst
[i
].SrcReg
[1] = SrcRegSave
[1];
5999 else if(OPCODE_CONT
== pILInst
[i
+1].Opcode
)
6001 #ifdef USE_CF_FOR_CONTINUE_BREAK
6002 pR700AsmCode
->alu_x_opcode
= SQ_CF_INST_ALU_PUSH_BEFORE
;
6004 pR700AsmCode
->alu_x_opcode
= SQ_CF_INST_ALU_CONTINUE
;
6007 if ( GL_FALSE
== assemble_LOGIC_PRED(pR700AsmCode
, SQ_OP2_INST_PRED_SETGT
) )
6009 pILInst
[i
].SrcReg
[0] = SrcRegSave
[0];
6010 pILInst
[i
].SrcReg
[1] = SrcRegSave
[1];
6016 if ( GL_FALSE
== assemble_LOGIC(pR700AsmCode
, SQ_OP2_INST_SETGT
) )
6018 pILInst
[i
].SrcReg
[0] = SrcRegSave
[0];
6019 pILInst
[i
].SrcReg
[1] = SrcRegSave
[1];
6023 pILInst
[i
].SrcReg
[0] = SrcRegSave
[0];
6024 pILInst
[i
].SrcReg
[1] = SrcRegSave
[1];
6030 struct prog_src_register SrcRegSave
[2];
6031 SrcRegSave
[0] = pILInst
[i
].SrcReg
[0];
6032 SrcRegSave
[1] = pILInst
[i
].SrcReg
[1];
6033 pILInst
[i
].SrcReg
[0] = SrcRegSave
[1];
6034 pILInst
[i
].SrcReg
[1] = SrcRegSave
[0];
6035 if(OPCODE_IF
== pILInst
[i
+1].Opcode
)
6037 pR700AsmCode
->alu_x_opcode
= SQ_CF_INST_ALU_PUSH_BEFORE
;
6038 if ( GL_FALSE
== assemble_LOGIC_PRED(pR700AsmCode
, SQ_OP2_INST_PRED_SETGE
) )
6040 pILInst
[i
].SrcReg
[0] = SrcRegSave
[0];
6041 pILInst
[i
].SrcReg
[1] = SrcRegSave
[1];
6045 else if(OPCODE_BRK
== pILInst
[i
+1].Opcode
)
6047 #ifdef USE_CF_FOR_CONTINUE_BREAK
6048 pR700AsmCode
->alu_x_opcode
= SQ_CF_INST_ALU_PUSH_BEFORE
;
6050 pR700AsmCode
->alu_x_opcode
= SQ_CF_INST_ALU_BREAK
;
6052 if ( GL_FALSE
== assemble_LOGIC_PRED(pR700AsmCode
, SQ_OP2_INST_PRED_SETGE
) )
6054 pILInst
[i
].SrcReg
[0] = SrcRegSave
[0];
6055 pILInst
[i
].SrcReg
[1] = SrcRegSave
[1];
6059 else if(OPCODE_CONT
== pILInst
[i
+1].Opcode
)
6061 #ifdef USE_CF_FOR_CONTINUE_BREAK
6062 pR700AsmCode
->alu_x_opcode
= SQ_CF_INST_ALU_PUSH_BEFORE
;
6064 pR700AsmCode
->alu_x_opcode
= SQ_CF_INST_ALU_CONTINUE
;
6067 if ( GL_FALSE
== assemble_LOGIC_PRED(pR700AsmCode
, SQ_OP2_INST_PRED_SETGE
) )
6069 pILInst
[i
].SrcReg
[0] = SrcRegSave
[0];
6070 pILInst
[i
].SrcReg
[1] = SrcRegSave
[1];
6076 if ( GL_FALSE
== assemble_LOGIC(pR700AsmCode
, SQ_OP2_INST_SETGE
) )
6078 pILInst
[i
].SrcReg
[0] = SrcRegSave
[0];
6079 pILInst
[i
].SrcReg
[1] = SrcRegSave
[1];
6083 pILInst
[i
].SrcReg
[0] = SrcRegSave
[0];
6084 pILInst
[i
].SrcReg
[1] = SrcRegSave
[1];
6089 if(OPCODE_IF
== pILInst
[i
+1].Opcode
)
6091 pR700AsmCode
->alu_x_opcode
= SQ_CF_INST_ALU_PUSH_BEFORE
;
6092 if ( GL_FALSE
== assemble_LOGIC_PRED(pR700AsmCode
, SQ_OP2_INST_PRED_SETNE
) )
6097 else if(OPCODE_BRK
== pILInst
[i
+1].Opcode
)
6099 #ifdef USE_CF_FOR_CONTINUE_BREAK
6100 pR700AsmCode
->alu_x_opcode
= SQ_CF_INST_ALU_PUSH_BEFORE
;
6102 pR700AsmCode
->alu_x_opcode
= SQ_CF_INST_ALU_BREAK
;
6104 if ( GL_FALSE
== assemble_LOGIC_PRED(pR700AsmCode
, SQ_OP2_INST_PRED_SETNE
) )
6109 else if(OPCODE_CONT
== pILInst
[i
+1].Opcode
)
6111 #ifdef USE_CF_FOR_CONTINUE_BREAK
6112 pR700AsmCode
->alu_x_opcode
= SQ_CF_INST_ALU_PUSH_BEFORE
;
6114 pR700AsmCode
->alu_x_opcode
= SQ_CF_INST_ALU_CONTINUE
;
6116 if ( GL_FALSE
== assemble_LOGIC_PRED(pR700AsmCode
, SQ_OP2_INST_PRED_SETNE
) )
6123 if ( GL_FALSE
== assemble_LOGIC(pR700AsmCode
, SQ_OP2_INST_SETNE
) )
6131 // if ( GL_FALSE == assemble_STP(pR700AsmCode) )
6136 if ( GL_FALSE
== assemble_MOV(pR700AsmCode
) )
6142 if( (i
+1)<uiNumberInsts
)
6144 if(OPCODE_END
!= pILInst
[i
+1].Opcode
)
6146 if( GL_TRUE
== IsTex(pILInst
[i
+1].Opcode
) )
6148 pR700AsmCode
->pInstDeps
[i
+1].nDstDep
= i
+1; //=1?
6158 if ( GL_FALSE
== assemble_TEX(pR700AsmCode
) )
6163 if ( GL_FALSE
== assemble_XPD(pR700AsmCode
) )
6169 GLboolean bHasElse
= GL_FALSE
;
6171 if(pILInst
[pILInst
[i
].BranchTarget
- 1].Opcode
== OPCODE_ELSE
)
6176 if ( GL_FALSE
== assemble_IF(pR700AsmCode
, bHasElse
) )
6184 if ( GL_FALSE
== assemble_ELSE(pR700AsmCode
) )
6189 if ( GL_FALSE
== assemble_ENDIF(pR700AsmCode
) )
6193 case OPCODE_BGNLOOP
:
6194 if( GL_FALSE
== assemble_BGNLOOP(pR700AsmCode
) )
6201 if( GL_FALSE
== assemble_BRK(pR700AsmCode
) )
6208 if( GL_FALSE
== assemble_CONT(pR700AsmCode
) )
6214 case OPCODE_ENDLOOP
:
6215 if( GL_FALSE
== assemble_ENDLOOP(pR700AsmCode
) )
6222 if( GL_FALSE
== assemble_BGNSUB(pR700AsmCode
, i
) )
6229 if( GL_FALSE
== assemble_RET(pR700AsmCode
) )
6236 if( GL_FALSE
== assemble_CAL(pR700AsmCode
,
6237 pILInst
[i
].BranchTarget
,
6245 //case OPCODE_EXPORT:
6246 // if ( GL_FALSE == assemble_EXPORT() )
6251 return assemble_ENDSUB(pR700AsmCode
);
6254 //pR700AsmCode->uiCurInst = i;
6255 //This is to remaind that if in later exoort there is depth/stencil
6256 //export, we need a mov to re-arrange DST channel, where using a
6257 //psuedo inst, we will use this end inst to do it.
6261 radeon_error("internal: unknown instruction\n");
6269 GLboolean
InitShaderProgram(r700_AssemblerBase
* pAsm
)
6271 setRetInLoopFlag(pAsm
, SQ_SEL_0
);
6275 GLboolean
RelocProgram(r700_AssemblerBase
* pAsm
)
6279 TypedShaderList
* plstCFmain
;
6280 TypedShaderList
* plstCFsub
;
6282 R700ShaderInstruction
* pInst
;
6283 R700ControlFlowGenericClause
* pCFInst
;
6285 if(0 == pAsm
->unSubArrayPointer
)
6290 plstCFmain
= pAsm
->CALLSTACK
[0].plstCFInstructions_local
;
6291 unCFoffset
= plstCFmain
->uNumOfNode
;
6294 for(i
=0; i
<pAsm
->unSubArrayPointer
; i
++)
6296 pAsm
->subs
[i
].unCFoffset
= unCFoffset
;
6297 plstCFsub
= &(pAsm
->subs
[i
].lstCFInstructions_local
);
6299 pInst
= plstCFsub
->pHead
;
6301 /* reloc instructions */
6304 if(SIT_CF_GENERIC
== pInst
->m_ShaderInstType
)
6306 pCFInst
= (R700ControlFlowGenericClause
*)pInst
;
6308 switch (pCFInst
->m_Word1
.f
.cf_inst
)
6310 case SQ_CF_INST_POP
:
6311 case SQ_CF_INST_JUMP
:
6312 case SQ_CF_INST_ELSE
:
6313 case SQ_CF_INST_LOOP_END
:
6314 case SQ_CF_INST_LOOP_START
:
6315 case SQ_CF_INST_LOOP_START_NO_AL
:
6316 case SQ_CF_INST_LOOP_CONTINUE
:
6317 case SQ_CF_INST_LOOP_BREAK
:
6318 pCFInst
->m_Word0
.f
.addr
+= unCFoffset
;
6325 pInst
->m_uIndex
+= unCFoffset
;
6327 pInst
= pInst
->pNextInst
;
6330 /* Put sub into main */
6331 plstCFmain
->pTail
->pNextInst
= plstCFsub
->pHead
;
6332 plstCFmain
->pTail
= plstCFsub
->pTail
;
6333 plstCFmain
->uNumOfNode
+= plstCFsub
->uNumOfNode
;
6335 unCFoffset
+= plstCFsub
->uNumOfNode
;
6339 for(i
=0; i
<pAsm
->unCallerArrayPointer
; i
++)
6341 pAsm
->callers
[i
].cf_ptr
->m_Word0
.f
.addr
6342 = pAsm
->subs
[pAsm
->callers
[i
].subDescIndex
].unCFoffset
;
6345 /* remove flags init if they are not used */
6346 if((pAsm
->unCFflags
& HAS_LOOPRET
) == 0)
6348 R700ControlFlowALUClause
* pCF_ALU
;
6349 pInst
= plstCFmain
->pHead
;
6352 if(SIT_CF_ALU
== pInst
->m_ShaderInstType
)
6354 pCF_ALU
= (R700ControlFlowALUClause
*)pInst
;
6355 if(1 == pCF_ALU
->m_Word1
.f
.count
)
6357 pCF_ALU
->m_Word1
.f
.cf_inst
= SQ_CF_INST_NOP
;
6361 R700ALUInstruction
* pALU
= pCF_ALU
->m_pLinkedALUInstruction
;
6363 pALU
->m_pLinkedALUClause
= NULL
;
6364 pALU
= (R700ALUInstruction
*)(pALU
->pNextInst
);
6365 pALU
->m_pLinkedALUClause
= pCF_ALU
;
6366 pCF_ALU
->m_pLinkedALUInstruction
= pALU
;
6368 pCF_ALU
->m_Word1
.f
.count
--;
6372 pInst
= pInst
->pNextInst
;
6379 GLboolean
Process_Export(r700_AssemblerBase
* pAsm
,
6381 GLuint export_starting_index
,
6382 GLuint export_count
,
6383 GLuint starting_register_number
,
6384 GLboolean is_depth_export
)
6386 unsigned char ucWriteMask
;
6388 check_current_clause(pAsm
, CF_EMPTY_CLAUSE
);
6389 check_current_clause(pAsm
, CF_EXPORT_CLAUSE
); //alloc the cf_current_export_clause_ptr
6391 pAsm
->cf_current_export_clause_ptr
->m_Word0
.f
.type
= type
;
6395 case SQ_EXPORT_PIXEL
:
6396 if(GL_TRUE
== is_depth_export
)
6398 pAsm
->cf_current_export_clause_ptr
->m_Word0
.f
.array_base
= SQ_CF_PIXEL_Z
;
6402 pAsm
->cf_current_export_clause_ptr
->m_Word0
.f
.array_base
= SQ_CF_PIXEL_MRT0
+ export_starting_index
;
6407 pAsm
->cf_current_export_clause_ptr
->m_Word0
.f
.array_base
= SQ_CF_POS_0
+ export_starting_index
;
6410 case SQ_EXPORT_PARAM
:
6411 pAsm
->cf_current_export_clause_ptr
->m_Word0
.f
.array_base
= 0x0 + export_starting_index
;
6415 radeon_error("Unknown export type: %d\n", type
);
6420 pAsm
->cf_current_export_clause_ptr
->m_Word0
.f
.rw_gpr
= starting_register_number
;
6422 pAsm
->cf_current_export_clause_ptr
->m_Word0
.f
.rw_rel
= SQ_ABSOLUTE
;
6423 pAsm
->cf_current_export_clause_ptr
->m_Word0
.f
.index_gpr
= 0x0;
6424 pAsm
->cf_current_export_clause_ptr
->m_Word0
.f
.elem_size
= 0x3;
6426 pAsm
->cf_current_export_clause_ptr
->m_Word1
.f
.burst_count
= (export_count
- 1);
6427 pAsm
->cf_current_export_clause_ptr
->m_Word1
.f
.end_of_program
= 0x0;
6428 pAsm
->cf_current_export_clause_ptr
->m_Word1
.f
.valid_pixel_mode
= 0x0;
6429 pAsm
->cf_current_export_clause_ptr
->m_Word1
.f
.cf_inst
= SQ_CF_INST_EXPORT
; // _DONE
6430 pAsm
->cf_current_export_clause_ptr
->m_Word1
.f
.whole_quad_mode
= 0x0;
6431 pAsm
->cf_current_export_clause_ptr
->m_Word1
.f
.barrier
= 0x1;
6433 if (export_count
== 1)
6435 ucWriteMask
= pAsm
->pucOutMask
[starting_register_number
- pAsm
->starting_export_register_number
];
6436 /* exports Z as a float into Red channel */
6437 if (GL_TRUE
== is_depth_export
)
6440 if( (ucWriteMask
& 0x1) != 0)
6442 pAsm
->cf_current_export_clause_ptr
->m_Word1_SWIZ
.f
.sel_x
= SQ_SEL_X
;
6446 pAsm
->cf_current_export_clause_ptr
->m_Word1_SWIZ
.f
.sel_x
= SQ_SEL_MASK
;
6448 if( ((ucWriteMask
>>1) & 0x1) != 0)
6450 pAsm
->cf_current_export_clause_ptr
->m_Word1_SWIZ
.f
.sel_y
= SQ_SEL_Y
;
6454 pAsm
->cf_current_export_clause_ptr
->m_Word1_SWIZ
.f
.sel_y
= SQ_SEL_MASK
;
6456 if( ((ucWriteMask
>>2) & 0x1) != 0)
6458 pAsm
->cf_current_export_clause_ptr
->m_Word1_SWIZ
.f
.sel_z
= SQ_SEL_Z
;
6462 pAsm
->cf_current_export_clause_ptr
->m_Word1_SWIZ
.f
.sel_z
= SQ_SEL_MASK
;
6464 if( ((ucWriteMask
>>3) & 0x1) != 0)
6466 pAsm
->cf_current_export_clause_ptr
->m_Word1_SWIZ
.f
.sel_w
= SQ_SEL_W
;
6470 pAsm
->cf_current_export_clause_ptr
->m_Word1_SWIZ
.f
.sel_w
= SQ_SEL_MASK
;
6475 // This should only be used if all components for all registers have been written
6476 pAsm
->cf_current_export_clause_ptr
->m_Word1_SWIZ
.f
.sel_x
= SQ_SEL_X
;
6477 pAsm
->cf_current_export_clause_ptr
->m_Word1_SWIZ
.f
.sel_y
= SQ_SEL_Y
;
6478 pAsm
->cf_current_export_clause_ptr
->m_Word1_SWIZ
.f
.sel_z
= SQ_SEL_Z
;
6479 pAsm
->cf_current_export_clause_ptr
->m_Word1_SWIZ
.f
.sel_w
= SQ_SEL_W
;
6482 pAsm
->cf_last_export_ptr
= pAsm
->cf_current_export_clause_ptr
;
6487 GLboolean
Move_Depth_Exports_To_Correct_Channels(r700_AssemblerBase
*pAsm
, BITS depth_channel_select
)
6489 gl_inst_opcode Opcode_save
= pAsm
->pILInst
[pAsm
->uiCurInst
].Opcode
; //Should be OPCODE_END
6490 pAsm
->pILInst
[pAsm
->uiCurInst
].Opcode
= OPCODE_MOV
;
6492 // MOV depth_export_register.hw_depth_channel, depth_export_register.depth_channel_select
6494 pAsm
->D
.dst
.opcode
= SQ_OP2_INST_MOV
;
6496 setaddrmode_PVSDST(&(pAsm
->D
.dst
), ADDR_ABSOLUTE
);
6497 pAsm
->D
.dst
.rtype
= DST_REG_TEMPORARY
;
6498 pAsm
->D
.dst
.reg
= pAsm
->depth_export_register_number
;
6500 pAsm
->D
.dst
.writex
= 1; // depth goes in R channel for HW
6502 setaddrmode_PVSSRC(&(pAsm
->S
[0].src
), ADDR_ABSOLUTE
);
6503 pAsm
->S
[0].src
.rtype
= DST_REG_TEMPORARY
;
6504 pAsm
->S
[0].src
.reg
= pAsm
->depth_export_register_number
;
6506 setswizzle_PVSSRC(&(pAsm
->S
[0].src
), depth_channel_select
);
6508 noneg_PVSSRC(&(pAsm
->S
[0].src
));
6510 if( GL_FALSE
== next_ins(pAsm
) )
6515 pAsm
->pILInst
[pAsm
->uiCurInst
].Opcode
= Opcode_save
;
6520 GLboolean
Process_Fragment_Exports(r700_AssemblerBase
*pR700AsmCode
,
6521 GLbitfield OutputsWritten
)
6524 GLuint export_count
= 0;
6526 if(pR700AsmCode
->depth_export_register_number
>= 0)
6528 if( GL_FALSE
== Move_Depth_Exports_To_Correct_Channels(pR700AsmCode
, SQ_SEL_Z
) ) // depth
6534 unBit
= 1 << FRAG_RESULT_COLOR
;
6535 if(OutputsWritten
& unBit
)
6537 if( GL_FALSE
== Process_Export(pR700AsmCode
,
6541 pR700AsmCode
->uiFP_OutputMap
[FRAG_RESULT_COLOR
],
6548 unBit
= 1 << FRAG_RESULT_DEPTH
;
6549 if(OutputsWritten
& unBit
)
6551 if( GL_FALSE
== Process_Export(pR700AsmCode
,
6555 pR700AsmCode
->uiFP_OutputMap
[FRAG_RESULT_DEPTH
],
6562 /* Need to export something, otherwise we'll hang
6563 * results are undefined anyway */
6564 if(export_count
== 0)
6566 Process_Export(pR700AsmCode
, SQ_EXPORT_PIXEL
, 0, 1, 0, GL_FALSE
);
6569 if(pR700AsmCode
->cf_last_export_ptr
!= NULL
)
6571 pR700AsmCode
->cf_last_export_ptr
->m_Word1
.f
.cf_inst
= SQ_CF_INST_EXPORT_DONE
;
6572 pR700AsmCode
->cf_last_export_ptr
->m_Word1
.f
.end_of_program
= 0x1;
6578 GLboolean
Process_Vertex_Exports(r700_AssemblerBase
*pR700AsmCode
,
6579 GLbitfield OutputsWritten
)
6584 GLuint export_starting_index
= 0;
6585 GLuint export_count
= pR700AsmCode
->number_of_exports
;
6587 unBit
= 1 << VERT_RESULT_HPOS
;
6588 if(OutputsWritten
& unBit
)
6590 if( GL_FALSE
== Process_Export(pR700AsmCode
,
6592 export_starting_index
,
6594 pR700AsmCode
->ucVP_OutputMap
[VERT_RESULT_HPOS
],
6602 pR700AsmCode
->cf_last_export_ptr
->m_Word1
.f
.cf_inst
= SQ_CF_INST_EXPORT_DONE
;
6605 pR700AsmCode
->number_of_exports
= export_count
;
6607 unBit
= 1 << VERT_RESULT_COL0
;
6608 if(OutputsWritten
& unBit
)
6610 if( GL_FALSE
== Process_Export(pR700AsmCode
,
6612 export_starting_index
,
6614 pR700AsmCode
->ucVP_OutputMap
[VERT_RESULT_COL0
],
6620 export_starting_index
++;
6623 unBit
= 1 << VERT_RESULT_COL1
;
6624 if(OutputsWritten
& unBit
)
6626 if( GL_FALSE
== Process_Export(pR700AsmCode
,
6628 export_starting_index
,
6630 pR700AsmCode
->ucVP_OutputMap
[VERT_RESULT_COL1
],
6636 export_starting_index
++;
6639 unBit
= 1 << VERT_RESULT_FOGC
;
6640 if(OutputsWritten
& unBit
)
6642 if( GL_FALSE
== Process_Export(pR700AsmCode
,
6644 export_starting_index
,
6646 pR700AsmCode
->ucVP_OutputMap
[VERT_RESULT_FOGC
],
6652 export_starting_index
++;
6657 unBit
= 1 << (VERT_RESULT_TEX0
+ i
);
6658 if(OutputsWritten
& unBit
)
6660 if( GL_FALSE
== Process_Export(pR700AsmCode
,
6662 export_starting_index
,
6664 pR700AsmCode
->ucVP_OutputMap
[VERT_RESULT_TEX0
+ i
],
6670 export_starting_index
++;
6674 for(i
=VERT_RESULT_VAR0
; i
<VERT_RESULT_MAX
; i
++)
6677 if(OutputsWritten
& unBit
)
6679 if( GL_FALSE
== Process_Export(pR700AsmCode
,
6681 export_starting_index
,
6683 pR700AsmCode
->ucVP_OutputMap
[i
],
6689 export_starting_index
++;
6693 // At least one param should be exported
6696 pR700AsmCode
->cf_last_export_ptr
->m_Word1
.f
.cf_inst
= SQ_CF_INST_EXPORT_DONE
;
6700 if( GL_FALSE
== Process_Export(pR700AsmCode
,
6704 pR700AsmCode
->starting_export_register_number
,
6710 pR700AsmCode
->cf_last_export_ptr
->m_Word1_SWIZ
.f
.sel_x
= SQ_SEL_0
;
6711 pR700AsmCode
->cf_last_export_ptr
->m_Word1_SWIZ
.f
.sel_y
= SQ_SEL_0
;
6712 pR700AsmCode
->cf_last_export_ptr
->m_Word1_SWIZ
.f
.sel_z
= SQ_SEL_0
;
6713 pR700AsmCode
->cf_last_export_ptr
->m_Word1_SWIZ
.f
.sel_w
= SQ_SEL_1
;
6714 pR700AsmCode
->cf_last_export_ptr
->m_Word1
.f
.cf_inst
= SQ_CF_INST_EXPORT_DONE
;
6717 pR700AsmCode
->cf_last_export_ptr
->m_Word1
.f
.end_of_program
= 0x1;
6722 GLboolean
Clean_Up_Assembler(r700_AssemblerBase
*pR700AsmCode
)
6724 FREE(pR700AsmCode
->pucOutMask
);
6725 FREE(pR700AsmCode
->pInstDeps
);
6727 if(NULL
!= pR700AsmCode
->subs
)
6729 FREE(pR700AsmCode
->subs
);
6731 if(NULL
!= pR700AsmCode
->callers
)
6733 FREE(pR700AsmCode
->callers
);