> First adds a new screen interface for is_vertex_format_supported and also
> we seems to have some GPUs with a single R16 and some with R16X16 so allow
> or this.

Are you sure this is necessary?

Vertex shader formats have an explicitly specified stride, and so
padding does not matter for them.

I think we should just define padding-less formats like all other
vertex formats, and don't add is_vertex_format_supported (except
possibly to not expose the extension if the hardware doesn't support
it).

Padded formats can be added later for floating point *textures*, that
need them since the "pixel size" is derived from the format, unlike
what happens in vertex formats.

Here is my own implementation, which was based on some work of yours
that Jakob (IIRC) sent me.

diff --git a/src/gallium/include/pipe/p_format.h
b/src/gallium/include/pipe/p_format.h
index 6bfff1c..d324c65 100644
--- a/src/gallium/include/pipe/p_format.h
+++ b/src/gallium/include/pipe/p_format.h
@@ -166,6 +166,10 @@ enum pipe_format {
    PIPE_FORMAT_DXT3_SRGBA            = 108,
    PIPE_FORMAT_DXT5_SRGBA            = 109,

+   PIPE_FORMAT_R16_FLOAT          = 110,
+   PIPE_FORMAT_R16G16_FLOAT          = 111,
+   PIPE_FORMAT_R16G16B16_FLOAT    = 112,
+   PIPE_FORMAT_R16G16B16A16_FLOAT    = 113,
    PIPE_FORMAT_COUNT
 };
diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c
index b0d5b99..262cf9e 100644
--- a/src/mesa/state_tracker/st_draw.c
+++ b/src/mesa/state_tracker/st_draw.c
@@ -72,6 +72,13 @@ static GLuint float_types[4] = {
    PIPE_FORMAT_R32G32B32A32_FLOAT
 };

+static GLuint half_float_types[4] = {
+   PIPE_FORMAT_R16_FLOAT,
+   PIPE_FORMAT_R16G16_FLOAT,
+   PIPE_FORMAT_R16G16B16_FLOAT,
+   PIPE_FORMAT_R16G16B16A16_FLOAT
+};
+
 static GLuint uint_types_norm[4] = {
    PIPE_FORMAT_R32_UNORM,
    PIPE_FORMAT_R32G32_UNORM,
@@ -173,7 +180,7 @@ st_pipe_vertex_format(GLenum type, GLuint size,
GLenum format,
                       GLboolean normalized)
 {
    assert((type >= GL_BYTE && type <= GL_DOUBLE) ||
-          type == GL_FIXED);
+          type == GL_FIXED || type == GL_HALF_FLOAT);
    assert(size >= 1);
    assert(size <= 4);
    assert(format == GL_RGBA || format == GL_BGRA);
@@ -189,6 +196,7 @@ st_pipe_vertex_format(GLenum type, GLuint size,
GLenum format,
       switch (type) {
       case GL_DOUBLE: return double_types[size-1];
       case GL_FLOAT: return float_types[size-1];
+      case GL_HALF_FLOAT: return half_float_types[size-1];
       case GL_INT: return int_types_norm[size-1];
       case GL_SHORT: return short_types_norm[size-1];
       case GL_BYTE: return byte_types_norm[size-1];
@@ -203,6 +211,7 @@ st_pipe_vertex_format(GLenum type, GLuint size,
GLenum format,
       switch (type) {
       case GL_DOUBLE: return double_types[size-1];
       case GL_FLOAT: return float_types[size-1];
+      case GL_HALF_FLOAT: return half_float_types[size-1];
       case GL_INT: return int_types_scale[size-1];
       case GL_SHORT: return short_types_scale[size-1];
       case GL_BYTE: return byte_types_scale[size-1];
diff --git a/src/mesa/state_tracker/st_extensions.c
b/src/mesa/state_tracker/st_extensions.c
index 89a16c1..60732f3 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -148,6 +148,7 @@ void st_init_extensions(struct st_context *st)
     */
    ctx->Extensions.ARB_copy_buffer = GL_TRUE;
    ctx->Extensions.ARB_fragment_program = GL_TRUE;
+   ctx->Extensions.ARB_half_float_vertex = GL_TRUE;
    ctx->Extensions.ARB_map_buffer_range = GL_TRUE;
    ctx->Extensions.ARB_multisample = GL_TRUE;
    ctx->Extensions.ARB_texture_border_clamp = GL_TRUE; /* XXX temp */

------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
Mesa3d-dev mailing list
Mesa3d-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mesa3d-dev

Reply via email to