mesa/src/gallium
Francisco Jerez bf045bf9b4 clover: Calculate optimal work group size when it's not specified by the user.
Inspired by a patch sent to the mailing list by Tom Stellard, but
using a different algorithm to calculate the optimal block size that
has been found to be considerably more effective.

Reviewed-by: Tom Stellard <thomas.stellard@amd.com>
2013-11-04 12:12:37 -08:00
..
auxiliary tgsi/scan: set maximum index for each constant buffer 2013-11-04 19:07:57 +01:00
docs gallium: add PIPE_CAP_MIXED_FRAMEBUFFER_SIZES 2013-10-26 01:36:07 +02:00
drivers r600g: properly unbind a DSA state being deleted in r600_delete_dsa_state 2013-11-04 19:07:57 +01:00
include vl/h264: split fields into SPS/PPS 2013-10-28 11:08:12 +01:00
state_trackers clover: Calculate optimal work group size when it's not specified by the user. 2013-11-04 12:12:37 -08:00
targets gallium/targets: remove vdpau-softpipe 2013-11-02 23:34:01 +01:00
tests gallium: new, unified pipe_context::set_sampler_views() function 2013-10-23 10:15:38 -06:00
tools gallium: new, unified pipe_context::set_sampler_views() function 2013-10-23 10:15:38 -06:00
winsys winsys/radeon: use type-3 NOPs for CS padding on CIK 2013-11-04 19:07:56 +01:00
Android.common.mk
Android.mk Move nv30, nv50 and nvc0 to nouveau. 2013-09-11 21:47:07 +02:00
Automake.inc
README.portability
SConscript haiku: Build Haiku's libGL from within Mesa 2013-10-04 18:20:09 -05:00

	      CROSS-PLATFORM PORTABILITY GUIDELINES FOR GALLIUM3D 


= General Considerations =

The state tracker and winsys driver support a rather limited number of
platforms. However, the pipe drivers are meant to run in a wide number of
platforms. Hence the pipe drivers, the auxiliary modules, and all public
headers in general, should strictly follow these guidelines to ensure


= Compiler Support =

* Include the p_compiler.h.

* Don't use the 'inline' keyword, use the INLINE macro in p_compiler.h instead.

* Cast explicitly when converting to integer types of smaller sizes.

* Cast explicitly when converting between float, double and integral types.

* Don't use named struct initializers.

* Don't use variable number of macro arguments. Use static inline functions
instead.

* Don't use C99 features.

= Standard Library =

* Avoid including standard library headers. Most standard library functions are
not available in Windows Kernel Mode. Use the appropriate p_*.h include.

== Memory Allocation ==

* Use MALLOC, CALLOC, FREE instead of the malloc, calloc, free functions.

* Use align_pointer() function defined in u_memory.h for aligning pointers
 in a portable way.

== Debugging ==

* Use the functions/macros in p_debug.h.

* Don't include assert.h, call abort, printf, etc.


= Code Style =

== Inherantice in C ==

The main thing we do is mimic inheritance by structure containment.

Here's a silly made-up example:

/* base class */
struct buffer
{
  int size;
  void (*validate)(struct buffer *buf);
};

/* sub-class of bufffer */
struct texture_buffer
{
  struct buffer base;  /* the base class, MUST COME FIRST! */
  int format;
  int width, height;
};


Then, we'll typically have cast-wrapper functions to convert base-class 
pointers to sub-class pointers where needed:

static inline struct vertex_buffer *vertex_buffer(struct buffer *buf)
{
  return (struct vertex_buffer *) buf;
}


To create/init a sub-classed object:

struct buffer *create_texture_buffer(int w, int h, int format)
{
  struct texture_buffer *t = malloc(sizeof(*t));
  t->format = format;
  t->width = w;
  t->height = h;
  t->base.size = w * h;
  t->base.validate = tex_validate;
  return &t->base;
}

Example sub-class method:

void tex_validate(struct buffer *buf)
{
  struct texture_buffer *tb = texture_buffer(buf);
  assert(tb->format);
  assert(tb->width);
  assert(tb->height);
}


Note that we typically do not use typedefs to make "class names"; we use
'struct whatever' everywhere.

Gallium's pipe_context and the subclassed psb_context, etc are prime examples 
of this.  There's also many examples in Mesa and the Mesa state tracker.