From 56c4ccfc193ad3b57a0d1731570a1fc81a664ce3 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 24 Aug 2006 14:35:10 -0700 Subject: [PATCH] Fix up sampler send message translation and give it a near-usable syntax. --- assembler/gram.y | 104 ++++++++++++++++++++++++++++++++++++-------- assembler/packed_yuv_wm.g4a | 4 +- 2 files changed, 89 insertions(+), 19 deletions(-) diff --git a/assembler/gram.y b/assembler/gram.y index e0ffe43..6357044 100644 --- a/assembler/gram.y +++ b/assembler/gram.y @@ -58,8 +58,8 @@ %token DOT %token MINUS ABS -%token TYPE_UD, TYPE_D, TYPE_UW, TYPE_W, TYPE_UB, TYPE_B, -%token TYPE_VF, TYPE_HF, TYPE_V, TYPE_F +%token TYPE_UD, TYPE_D, TYPE_UW, TYPE_W, TYPE_UB, TYPE_B, +%token TYPE_VF, TYPE_HF, TYPE_V, TYPE_F %token ALIGN1 ALIGN16 MASK_DISABLE EOT @@ -82,14 +82,14 @@ %type specialinstruction %type dst dstoperand dstoperandex dstreg %type directsrcaccoperand src directsrcoperand srcimm imm32reg -%type srcacc srcaccimm +%type srcacc srcaccimm payload post_dst msgtarget %type instoptions instoption_list %type instrseq %type instoption %type unaryop binaryop binaryaccop %type conditionalmodifier saturate negate abs %type regtype srcimmtype execsize dstregion -%type subregnum msgtarget +%type subregnum sampler_datatype %type region %type directgenreg directmsgreg addrreg accreg flagreg maskreg %type nullreg @@ -196,14 +196,31 @@ binaryaccop: ADD { $$ = BRW_OPCODE_ADD; } triinstruction: sendinstruction -/* XXX formatting of this instruction */ -sendinstruction: predicate SEND INTEGER execsize dst payload msgtarget +sendinstruction: predicate SEND execsize INTEGER post_dst payload msgtarget MSGLEN INTEGER RETURNLEN INTEGER instoptions { + /* Send instructions are messy. The first argument is the + * post destination -- the grf register that the response + * starts from. The second argument is the current + * destination, which is the start of the message arguments + * to the shared function, and where src0 payload is loaded + * to if not null. The payload is typically based on the + * grf 0 thread payload of your current thread, and is + * implicitly loaded if non-null. + */ bzero(&$$, sizeof($$)); $$.header.opcode = BRW_OPCODE_SEND; - $$.header.execution_size = $4; - $$.header.destreg__conditionalmod = $3; + $$.header.execution_size = $3; + $$.header.destreg__conditionalmod = $4; /* msg reg index */ + set_instruction_dest(&$$, &$5); + set_instruction_src0(&$$, &$6); + $$.bits1.da1.src1_reg_file = BRW_IMMEDIATE_VALUE; + $$.bits1.da1.src1_reg_type = BRW_REGISTER_TYPE_D; + $$.bits3.generic = $7.bits3.generic; + $$.bits3.generic.msg_length = $9; + $$.bits3.generic.response_length = $11; + $$.bits3.generic.end_of_thread = + $12.bits3.generic.msg_target; } specialinstruction: NOP @@ -216,16 +233,68 @@ specialinstruction: NOP payload: directsrcoperand ; -msgtarget: NULL_TOKEN { $$ = BRW_MESSAGE_TARGET_NULL; } - | SAMPLER { $$ = BRW_MESSAGE_TARGET_SAMPLER; } - | MATH { $$ = BRW_MESSAGE_TARGET_MATH; } - | GATEWAY { $$ = BRW_MESSAGE_TARGET_GATEWAY; } - | READ { $$ = BRW_MESSAGE_TARGET_DATAPORT_READ; } - | WRITE { $$ = BRW_MESSAGE_TARGET_DATAPORT_WRITE; } - | URB { $$ = BRW_MESSAGE_TARGET_URB; } - | THREAD_SPAWNER { $$ = BRW_MESSAGE_TARGET_THREAD_SPAWNER; } +post_dst: dst ; +msgtarget: NULL_TOKEN + { + $$.bits3.generic.msg_target = BRW_MESSAGE_TARGET_NULL; + } + | SAMPLER LPAREN INTEGER COMMA INTEGER COMMA + sampler_datatype RPAREN + { + $$.bits3.generic.msg_target = BRW_MESSAGE_TARGET_SAMPLER; + $$.bits3.sampler.binding_table_index = $3; + $$.bits3.sampler.sampler = $5; + switch ($7) { + case TYPE_F: + $$.bits3.sampler.return_format = + BRW_SAMPLER_RETURN_FORMAT_FLOAT32; + break; + case TYPE_UD: + $$.bits3.sampler.return_format = + BRW_SAMPLER_RETURN_FORMAT_UINT32; + break; + case TYPE_D: + $$.bits3.sampler.return_format = + BRW_SAMPLER_RETURN_FORMAT_SINT32; + break; + } + } + | MATH + { + $$.bits3.generic.msg_target = BRW_MESSAGE_TARGET_MATH; + } + | GATEWAY + { + $$.bits3.generic.msg_target = BRW_MESSAGE_TARGET_GATEWAY; + } + | READ + { + $$.bits3.generic.msg_target = + BRW_MESSAGE_TARGET_DATAPORT_READ; + } + | WRITE + { + $$.bits3.generic.msg_target = + BRW_MESSAGE_TARGET_DATAPORT_WRITE; + } + | URB + { + $$.bits3.generic.msg_target = BRW_MESSAGE_TARGET_URB; + } + | THREAD_SPAWNER + { + $$.bits3.generic.msg_target = + BRW_MESSAGE_TARGET_THREAD_SPAWNER; + } +; + +sampler_datatype: + TYPE_F + | TYPE_UD + | TYPE_D + /* 1.4.2: Destination register */ dst: dstoperand | dstoperandex @@ -511,7 +580,8 @@ instoption_list: instoption instoption_list $$.header.mask_control = BRW_MASK_DISABLE; break; case EOT: - /* XXX: EOT shouldn't be here */ + /* XXX: EOT shouldn't be an instoption, I don't think */ + $$.bits3.generic.end_of_thread = 1; break; } } diff --git a/assembler/packed_yuv_wm.g4a b/assembler/packed_yuv_wm.g4a index 6c08d0b..9efde1d 100644 --- a/assembler/packed_yuv_wm.g4a +++ b/assembler/packed_yuv_wm.g4a @@ -89,7 +89,7 @@ mov (8) m4<1>F g7<8,8,1>F { align1 }; * g0 holds the PS thread payload, which (oddly) contains * precisely what the sampler wants to see in m0 */ -send 0 (16) g12<1>UW g0<8,8,1>UW sampler mlen 5 rlen 8 { align1 }; +send (16) 0 g12<1>UW g0<8,8,1>UW sampler (1,0,F) mlen 5 rlen 8 { align1 }; mov (8) g19<1>UW g19<8,8,1>UW { align1 }; /* color space conversion function: @@ -144,7 +144,7 @@ mac.sat (8) m8<1>F g15<8,8,1>F 1F { align1 }; */ mov (8) m1<1>UD g1<8,8,1>UD { align1 mask_disable }; /* Send framebuffer write message: XXX: acc0? */ -send 0 (16) null g0<8,8,1>UW write mlen 10 rlen 0 { align1 EOT }; +send (16) 0 null g0<8,8,1>UW write mlen 10 rlen 0 { align1 EOT }; /* padding */ nop; nop; -- 2.7.4