From: Chia-I Wu Date: Sun, 18 Jan 2015 06:51:02 +0000 (+0800) Subject: complete fixed-function vertex fetch support X-Git-Tag: submit/tizen/20181227.054638~6200 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=54013ab86c20cf9d48e8743f11d0b8b4a2f33b9f;p=platform%2Fupstream%2FVulkan-Tools.git complete fixed-function vertex fetch support Update xgl.h (cosmetic changes only). Add support for new formats. v2: fix blit tests and enhance xglinfo for new formats --- diff --git a/demos/xglinfo.c b/demos/xglinfo.c index 2040e762..114d8481 100644 --- a/demos/xglinfo.c +++ b/demos/xglinfo.c @@ -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"; } diff --git a/icd/common/icd-format.c b/icd/common/icd-format.c index c56d70fc..d53d4248 100644 --- a/icd/common/icd-format.c +++ b/icd/common/icd-format.c @@ -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; diff --git a/icd/common/icd-format.h b/icd/common/icd-format.h index 1292577d..e628b1b0 100644 --- a/icd/common/icd-format.h +++ b/icd/common/icd-format.h @@ -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) { diff --git a/include/xgl.h b/include/xgl.h index 468b36b9..9532a6c5 100644 --- a/include/xgl.h +++ b/include/xgl.h @@ -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,