complete fixed-function vertex fetch support
authorChia-I Wu <olv@lunarg.com>
Sun, 18 Jan 2015 06:51:02 +0000 (14:51 +0800)
committerCourtney Goeltzenleuchter <courtney@LunarG.com>
Thu, 5 Feb 2015 00:58:09 +0000 (17:58 -0700)
Update xgl.h (cosmetic changes only).  Add support for new formats.

v2: fix blit tests and enhance xglinfo for new formats

demos/xglinfo.c
icd/common/icd-format.c
icd/common/icd-format.h
include/xgl.h

index 2040e762c82dd4ee2d48b6c5712c217888dd7728..114d8481dbb4d34e1603ae3be2b48d28be3bb980 100644 (file)
@@ -182,6 +182,13 @@ static const char *xgl_channel_format_string(XGL_CHANNEL_FORMAT ch)
     STR(BC6U);
     STR(BC6S);
     STR(BC7);
+    STR(R8G8B8);
+    STR(R16G16B16);
+    STR(B10G10R10A2);
+    STR(R64);
+    STR(R64G64);
+    STR(R64G64B64);
+    STR(R64G64B64A64);
 #undef STR
     default: return "UNKNOWN_CH";
     }
@@ -199,6 +206,8 @@ static const char *xgl_numeric_format_string(XGL_NUM_FORMAT num)
     STR(FLOAT);
     STR(SRGB);
     STR(DS);
+    STR(USCALED);
+    STR(SSCALED);
 #undef STR
     default: return "UNKNOWN_NUM";
     }
index c56d70fc64c88eae29352d17c04f6834821b5c69..d53d424891ff788b85f29bd87c99d4df47eba21a 100644 (file)
@@ -64,6 +64,13 @@ static const struct icd_format_info {
     [XGL_CH_FMT_BC6U]           = { 16, 4 },
     [XGL_CH_FMT_BC6S]           = { 16, 4 },
     [XGL_CH_FMT_BC7]            = { 16, 4 },
+    [XGL_CH_FMT_R8G8B8]         = { 3,  3 },
+    [XGL_CH_FMT_R16G16B16]      = { 6,  3 },
+    [XGL_CH_FMT_B10G10R10A2]    = { 4,  4 },
+    [XGL_CH_FMT_R64]            = { 8,  1 },
+    [XGL_CH_FMT_R64G64]         = { 16, 2 },
+    [XGL_CH_FMT_R64G64B64]      = { 24, 3 },
+    [XGL_CH_FMT_R64G64B64A64]   = { 32, 4 },
 };
 
 size_t icd_format_get_size(XGL_FORMAT format)
@@ -206,6 +213,41 @@ void icd_format_get_raw_value(XGL_FORMAT format,
     case XGL_CH_FMT_BC7:
         memcpy(value, color, 16);
         break;
+    case XGL_CH_FMT_R8G8B8:
+        ((uint8_t *) value)[0]  = (uint8_t) color[0];
+        ((uint8_t *) value)[1]  = (uint8_t) color[1];
+        ((uint8_t *) value)[2]  = (uint8_t) color[2];
+        break;
+    case XGL_CH_FMT_R16G16B16:
+        ((uint16_t *) value)[0] = (uint16_t) color[0];
+        ((uint16_t *) value)[1] = (uint16_t) color[1];
+        ((uint16_t *) value)[2] = (uint16_t) color[2];
+        break;
+    case XGL_CH_FMT_B10G10R10A2:
+        ((uint32_t *) value)[0] = (color[2] & 0x3ff) << 0  |
+                                  (color[1] & 0x3ff) << 10 |
+                                  (color[0] & 0x3ff) << 20 |
+                                  (color[3] & 0x3)   << 30;
+        break;
+    case XGL_CH_FMT_R64:
+        /* higher 32 bits always 0 */
+        ((uint64_t *) value)[0] = color[0];
+        break;
+    case XGL_CH_FMT_R64G64:
+        ((uint64_t *) value)[0] = color[0];
+        ((uint64_t *) value)[1] = color[1];
+        break;
+    case XGL_CH_FMT_R64G64B64:
+        ((uint64_t *) value)[0] = color[0];
+        ((uint64_t *) value)[1] = color[1];
+        ((uint64_t *) value)[2] = color[2];
+        break;
+    case XGL_CH_FMT_R64G64B64A64:
+        ((uint64_t *) value)[0] = color[0];
+        ((uint64_t *) value)[1] = color[1];
+        ((uint64_t *) value)[2] = color[2];
+        ((uint64_t *) value)[3] = color[3];
+        break;
     default:
         assert(!"unknown format");
         break;
index 1292577d426dff053459d03fd0feccd01b3ddf05..e628b1b0ae4c2f8cb8b8f949d9d6edfccbc5dfb1 100644 (file)
@@ -68,6 +68,12 @@ static inline bool icd_format_is_srgb(XGL_FORMAT format)
     return (format.numericFormat == XGL_NUM_FMT_SRGB);
 }
 
+static inline bool icd_format_is_scaled(XGL_FORMAT format)
+{
+    return (format.numericFormat == XGL_NUM_FMT_USCALED ||
+            format.numericFormat == XGL_NUM_FMT_SSCALED);
+}
+
 static inline bool icd_format_is_compressed(XGL_FORMAT format)
 {
     switch (format.channelFormat) {
index 468b36b935fee3c0d17da993b2a1547ea2f6f9a3..9532a6c50b49e34b19188a930f45e48332f2d6fa 100644 (file)
@@ -801,19 +801,14 @@ typedef enum _XGL_CHANNEL_FORMAT
     XGL_CH_FMT_BC6U                                         = 28,
     XGL_CH_FMT_BC6S                                         = 29,
     XGL_CH_FMT_BC7                                          = 30,
-// IMG CHANGE BEGIN - support for vertex input description
     XGL_CH_FMT_R8G8B8                                       = 31,
     XGL_CH_FMT_R16G16B16                                    = 32,
-
-    // optional? TBD'
     XGL_CH_FMT_B10G10R10A2                                  = 33,
-    XGL_CH_FMT_R64                                          = 34,
-    XGL_CH_FMT_R64G64                                       = 35,
-    XGL_CH_FMT_R64G64B64                                    = 36,
-    XGL_CH_FMT_R64G64B64A64                                 = 37,
-
+    XGL_CH_FMT_R64                                          = 34, // Optional
+    XGL_CH_FMT_R64G64                                       = 35, // Optional
+    XGL_CH_FMT_R64G64B64                                    = 36, // Optional
+    XGL_CH_FMT_R64G64B64A64                                 = 37, // Optional
     XGL_MAX_CH_FMT                                          = XGL_CH_FMT_R64G64B64A64,
-// IMG CHANGE END
     XGL_MAX_ENUM(_XGL_CHANNEL_FORMAT)
 } XGL_CHANNEL_FORMAT;
 
@@ -827,23 +822,19 @@ typedef enum _XGL_NUM_FORMAT
     XGL_NUM_FMT_FLOAT                                       = 5,
     XGL_NUM_FMT_SRGB                                        = 6,
     XGL_NUM_FMT_DS                                          = 7,
-// IMG CHANGE BEGIN - support for vertex input description
     XGL_NUM_FMT_USCALED                                     = 8,
     XGL_NUM_FMT_SSCALED                                     = 9,
     XGL_MAX_NUM_FMT                                         = XGL_NUM_FMT_SSCALED,
-// IMG CHANGE END
     XGL_MAX_ENUM(_XGL_NUM_FORMAT)
 } XGL_NUM_FORMAT;
 
-// IMG CHANGE BEGIN - support for vertex input description
 typedef enum _XGL_VERTEX_INPUT_STEP_RATE
 {
     XGL_VERTEX_INPUT_STEP_RATE_VERTEX     = 0x0,
     XGL_VERTEX_INPUT_STEP_RATE_INSTANCE   = 0x1,
-    XGL_VERTEX_INPUT_STEP_RATE_DRAW       = 0x2,
+    XGL_VERTEX_INPUT_STEP_RATE_DRAW       = 0x2,  //Optional
     XGL_MAX_ENUM(_XGL_VERTEX_INPUT_STEP_RATE)
 } XGL_VERTEX_INPUT_STEP_RATE;
-// IMG CHANGE END
 
 typedef struct _XGL_FORMAT
 {
@@ -1590,25 +1581,6 @@ typedef struct _XGL_COMPUTE_PIPELINE_CREATE_INFO
     XGL_FLAGS                               flags;      // XGL_PIPELINE_CREATE_FLAGS
 } XGL_COMPUTE_PIPELINE_CREATE_INFO;
 
-// IMG CHANGE BEGIN - support for vertex input description
-
-//
-// The shader inputs are mapped to pVertexAttributeDescriptions using a decoration in the BIL.
-//
-// The binding parameter in xglCmdBindVertexBuffer describes the index into pVertexBindingDescriptions[]
-//
-//
-// Formats allowed for attributes (XGL_VERTEX_INPUT_ATTRIBUTE_DESCRIPTION.format) will be detailed in
-// a table in the specification.
-//
-//
-// Queryable limits:
-//
-// XGL_VERTEX_INPUT_BINDING_DESCRIPTION.strideInBytes
-// XGL_VERTEX_INPUT_ATTRIBUTE_DESCRIPTION.offsetInBytes
-//
-//
-
 typedef struct _XGL_VERTEX_INPUT_BINDING_DESCRIPTION
 {
     XGL_UINT                                strideInBytes;  // Distance between vertices in bytes (0 = no advancement)
@@ -1620,7 +1592,7 @@ typedef struct _XGL_VERTEX_INPUT_ATTRIBUTE_DESCRIPTION
 {
     XGL_UINT                                binding;        // index into vertexBindingDescriptions
 
-    XGL_FORMAT                              format;            // format of source data
+    XGL_FORMAT                              format;         // format of source data
 
     XGL_UINT                                offsetInBytes;  // Offset of first element in bytes from base of vertex
 } XGL_VERTEX_INPUT_ATTRIBUTE_DESCRIPTION;
@@ -1636,7 +1608,6 @@ typedef struct _XGL_PIPELINE_VERTEX_INPUT_CREATE_INFO
     XGL_UINT                                attributeCount; // number of attributes
     XGL_VERTEX_INPUT_ATTRIBUTE_DESCRIPTION* pVertexAttributeDescriptions;
 } XGL_PIPELINE_VERTEX_INPUT_CREATE_INFO;
-// IMG CHANGE END
 
 typedef struct _XGL_PIPELINE_IA_STATE_CREATE_INFO
 {
@@ -2537,13 +2508,11 @@ XGL_VOID XGLAPI xglCmdBindDynamicBufferView(
     XGL_PIPELINE_BIND_POINT                     pipelineBindPoint,
     const XGL_BUFFER_VIEW_ATTACH_INFO*          pBufferView);
 
-// IMG CHANGE BEGIN - support for vertex input description
 XGL_VOID XGLAPI xglCmdBindVertexBuffer(
     XGL_CMD_BUFFER                              cmdBuffer,
     XGL_BUFFER                                  buffer,
     XGL_GPU_SIZE                                offset,
     XGL_UINT                                    binding);
-// IMG CHANGE END
 
 XGL_VOID XGLAPI xglCmdBindIndexBuffer(
     XGL_CMD_BUFFER                              cmdBuffer,