mesa/src/gallium
Kenneth Graunke b28efd80eb iris: Update comment about 2GB dynamic state range
We tracked this down with the HW teams back in 2020 and there's now a
documented workaround.  Comments from the HW team say this applies all
the way through XeHP but we're not sure beyond that.

This is a bug that we hit but the Windows drivers didn't because Jason
decided to allocate our memory structures from the top end of the VMA
range explicitly to catch bugs like this, while Windows allocates from
zero and up, so they would need to allocate more than 2GB of dynamic
state before running into it.

Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/4880
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17216>
2022-06-24 23:30:12 +00:00
..
auxiliary util: add dri config option to disable GL_MAP_UNSYNCHRONIZED_BIT 2022-06-24 00:29:24 +00:00
drivers iris: Update comment about 2GB dynamic state range 2022-06-24 23:30:12 +00:00
frontends lavapipe: skip post-copy pNext checking during pipeline creation for composites 2022-06-24 00:19:03 +00:00
include util: add dri config option to disable GL_MAP_UNSYNCHRONIZED_BIT 2022-06-24 00:29:24 +00:00
targets meson: Enable wgl tests on mingw 2022-06-23 09:27:06 +00:00
tests util/c11: Update function u_thread_create to be c11 conformance 2022-06-15 17:37:17 +00:00
tools gallium/tools: fixes to option handling 2022-06-20 12:35:53 +00:00
winsys d3d12: Fixes compiling error in d3d12/wgl/d3d12_wgl_framebuffer.cpp with gcc 2022-06-23 09:27:06 +00:00
README.portability
meson.build gallium/swr: Remove common code and build options 2021-12-06 23:37:50 +00:00

README.portability

	      CROSS-PLATFORM PORTABILITY GUIDELINES FOR GALLIUM3D 


= General Considerations =

The frontend 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.

* 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.