Brian Paul pisze:
Keith Whitwell wrote:
On Fri, 2009-10-30 at 04:36 -0700, michal wrote:
Keith Whitwell pisze:
On Fri, 2009-10-30 at 03:43 -0700, michal wrote:
gallium: Add a PREDICATE register file.

There's already a shader token that allows composition of predicated
instructions (tgsi_instruction_ext_predicate). However, there is no way
one can write to thos predicate registers in the first place.
---
 src/gallium/include/pipe/p_shader_tokens.h |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/src/gallium/include/pipe/p_shader_tokens.h b/src/gallium/include/pipe/p_shader_tokens.h
index de338c4..6aa8b27 100644
--- a/src/gallium/include/pipe/p_shader_tokens.h
+++ b/src/gallium/include/pipe/p_shader_tokens.h
@@ -79,6 +79,7 @@ enum tgsi_file_type {
    TGSI_FILE_ADDRESS     =6,
    TGSI_FILE_IMMEDIATE   =7,
    TGSI_FILE_LOOP        =8,
+   TGSI_FILE_PREDICATE   =9,
    TGSI_FILE_COUNT      /**< how many TGSI_FILE_ types */
 };
Michal,

Is your expectation that all drivers become able to understand
instructions with predicates?  That seems unreasonable.

What is the expected way of setting a predicate register?  What
functionality will use this?

For example:

DECL IN[0..1]
DECL OUT[0]
DECL PRED[0]

1: MOV OUT[0], IN[0]
2: SGT PRED[0], IN[0], IN[1]
3: (PRED[0]) MOV OUT[0], IN[1]

In (2) we set each component of PRED[0] to 1.0 if the corresponding components of IN[0] are greater than IN[1], and to 0.0 otherwise. In (3) we write IN[1] to only those components of OUT[0], for which the respective components of PRED[0] are non-zero.

It seems there are three ways to do conditional execution in TGSI
currently -- predicates, condition codes and IF/THEN/ELSE instructions.

I'd really prefer to have at most two, and in fact preferably just one.
Can you take a look at the three alternatives and figure out if one can
be amputated?

We could kill off the condition codes -- no driver uses that, and it's easier for us to emulate them with predicates than the other way round.
I think I agree with that.  Condition codes are pretty wierd, the only
reason I'd keep them around is that there is the NV GPU4 extension
sitting there as a ready-made definition of a high-end SM4-level
assembly language.

I don't know if Ian plans to introduce a MESA version of the program4
extension that more closely matches his program3 extension (ie
predicates instead of condition codes).

Just FYI: GL_NV_fragment_program uses condition codes but we haven't supported that extension with Gallium; only the ARB versions.


We could always remove condition codes later, when Ian decides about their future.

Attached is an updated patch that obsoletes one TGSI token and fixes the other one, so we can specify swizzles and negation of predicate registers, per GL_MESA_gpu_program3.

Thanks for comments.
>From d1efdb692ae99871585554ddeaff75e700349d70 Mon Sep 17 00:00:00 2001
From: Michal Krol <mic...@vmware.com>
Date: Fri, 30 Oct 2009 13:55:14 +0000
Subject: [PATCH] gallium: Add a PREDICATE register file.

There is little point in having a special TGSI token just to handle
predicate register updates.

Remove tgsi_dst_register_ext_predicate token and instead use
a new PREDICATE register file to update predicates. Actually, the contents
of the obsolete token are being moved to tgsi_instruction_ext_predicate,
where they should be from the very beginning.
---
 src/gallium/include/pipe/p_shader_tokens.h |   40 +++++++---------------------
 1 files changed, 10 insertions(+), 30 deletions(-)

diff --git a/src/gallium/include/pipe/p_shader_tokens.h 
b/src/gallium/include/pipe/p_shader_tokens.h
index de338c4..f3b8a7b 100644
--- a/src/gallium/include/pipe/p_shader_tokens.h
+++ b/src/gallium/include/pipe/p_shader_tokens.h
@@ -79,6 +79,7 @@ enum tgsi_file_type {
    TGSI_FILE_ADDRESS     =6,
    TGSI_FILE_IMMEDIATE   =7,
    TGSI_FILE_LOOP        =8,
+   TGSI_FILE_PREDICATE   =9,
    TGSI_FILE_COUNT      /**< how many TGSI_FILE_ types */
 };
 
@@ -427,11 +428,15 @@ struct tgsi_instruction_ext_texture
 
 struct tgsi_instruction_ext_predicate
 {
-   unsigned Type             : 4;    /* TGSI_INSTRUCTION_EXT_TYPE_PREDICATE */
-   unsigned PredDstIndex     : 4;    /* UINT */
-   unsigned PredWriteMask    : 4;    /* TGSI_WRITEMASK_ */
-   unsigned Padding          : 19;
-   unsigned Extended         : 1;    /* BOOL */
+   unsigned Type         : 4;    /* TGSI_INSTRUCTION_EXT_TYPE_PREDICATE */
+   unsigned PredSwizzleX : 2;    /* TGSI_SWIZZLE_ */
+   unsigned PredSwizzleY : 2;    /* TGSI_SWIZZLE_ */
+   unsigned PredSwizzleZ : 2;    /* TGSI_SWIZZLE_ */
+   unsigned PredSwizzleW : 2;    /* TGSI_SWIZZLE_ */
+   unsigned PredSrcIndex : 4;    /* UINT */
+   unsigned Negate       : 1;    /* BOOL */
+   unsigned Padding      : 14;
+   unsigned Extended     : 1;    /* BOOL */
 };
 
 /**
@@ -548,7 +553,6 @@ struct tgsi_dst_register
 
 #define TGSI_DST_REGISTER_EXT_TYPE_CONDCODE     0
 #define TGSI_DST_REGISTER_EXT_TYPE_MODULATE     1
-#define TGSI_DST_REGISTER_EXT_TYPE_PREDICATE    2
 
 struct tgsi_dst_register_ext
 {
@@ -566,9 +570,6 @@ struct tgsi_dst_register_ext
  * If tgsi_dst_register_ext::Type is TGSI_DST_REGISTER_EXT_TYPE_MODULATE,
  * it should be cast to tgsi_dst_register_ext_modulate.
  * 
- * If tgsi_dst_register_ext::Type is TGSI_DST_REGISTER_EXT_TYPE_PREDICATE,
- * it should be cast to tgsi_dst_register_ext_predicate.
- * 
  * If tgsi_dst_register_ext::Extended is TRUE, another tgsi_dst_register_ext
  * follows.
  */
@@ -602,27 +603,6 @@ struct tgsi_dst_register_ext_modulate
    unsigned Extended : 1;    /* BOOL */
 };
 
-/*
- * Currently, the following constraints apply.
- *
- * - PredSwizzleXYZW is either set to identity or replicate.
- * - PredSrcIndex is 0.
- */
-
-struct tgsi_dst_register_ext_predicate
-{
-   unsigned Type         : 4;    /* TGSI_DST_REGISTER_EXT_TYPE_PREDICATE */
-   unsigned PredSwizzleX : 2;    /* TGSI_SWIZZLE_ */
-   unsigned PredSwizzleY : 2;    /* TGSI_SWIZZLE_ */
-   unsigned PredSwizzleZ : 2;    /* TGSI_SWIZZLE_ */
-   unsigned PredSwizzleW : 2;    /* TGSI_SWIZZLE_ */
-   unsigned PredSrcIndex : 4;    /* UINT */
-   unsigned Negate       : 1;    /* BOOL */
-   unsigned Padding      : 14;
-   unsigned Extended     : 1;    /* BOOL */
-};
-
-
 #ifdef __cplusplus
 }
 #endif
-- 
1.6.4.msysgit.0

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Mesa3d-dev mailing list
Mesa3d-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mesa3d-dev

Reply via email to