[Mesa-dev] [PATCH] Initial Intel Vulkan internals documentation

2016-10-14 Thread kevin . rogovin
From: Kevin Rogovin 

This is an RFC for documentation I am making for the Intel OTC
Vulkan driver. The eventual goal for the documentation is to
help new developers understand the code base more quickly so
that they can contribute more easily.


Kevin Rogovin (1):
  vulkan: Initial partial documentation for Vulkan internals.

 src/intel/genxml/gen_macros.h   |4 +-
 src/intel/vulkan/anv_allocator.c|5 +-
 src/intel/vulkan/anv_private.h  |  287 +++-
 src/intel/vulkan/docs/.gitignore|1 +
 src/intel/vulkan/docs/Doxyfile  | 2483 +++
 src/intel/vulkan/docs/intel_vulkan.doxy |   86 ++
 6 files changed, 2845 insertions(+), 21 deletions(-)
 create mode 100644 src/intel/vulkan/docs/.gitignore
 create mode 100644 src/intel/vulkan/docs/Doxyfile
 create mode 100644 src/intel/vulkan/docs/intel_vulkan.doxy

-- 
2.7.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 2/3] remove main page tags from source files

2013-10-07 Thread Kevin Rogovin
---
 src/gbm/main/gbm.h  | 10 +-
 src/mapi/glapi/glapi.h  | 17 +
 src/mesa/main/context.c | 45 -
 src/mesa/program/program.h  |  8 +---
 src/mesa/swrast/s_context.h | 10 +-
 src/mesa/tnl/t_context.h| 16 +---
 src/mesa/vbo/vbo_context.h  | 18 --
 src/mesa/vbo/vbo_split.h|  8 +---
 8 files changed, 6 insertions(+), 126 deletions(-)

diff --git a/src/gbm/main/gbm.h b/src/gbm/main/gbm.h
index 9d2a030..ee4bd75 100644
--- a/src/gbm/main/gbm.h
+++ b/src/gbm/main/gbm.h
@@ -46,15 +46,7 @@ struct gbm_device;
 struct gbm_bo;
 struct gbm_surface;
 
-/**
- * \mainpage The Generic Buffer Manager
- *
- * This module provides an abstraction that the caller can use to request a
- * buffer from the underlying memory management system for the platform.
- *
- * This allows the creation of portable code whilst still allowing access to
- * the underlying memory manager.
- */
+
 
 /**
  * Abstraction representing the handle to a buffer allocated by the
diff --git a/src/mapi/glapi/glapi.h b/src/mapi/glapi/glapi.h
index c764271..bf6e0de 100644
--- a/src/mapi/glapi/glapi.h
+++ b/src/mapi/glapi/glapi.h
@@ -23,22 +23,7 @@
  */
 
 
-/**
- * \mainpage Mesa GL API Module
- *
- * \section GLAPIIntroduction Introduction
- *
- * The Mesa GL API module is responsible for dispatching all the
- * gl*() functions.  All GL functions are dispatched by jumping through
- * the current dispatch table (basically a struct full of function
- * pointers.)
- *
- * A per-thread current dispatch table and per-thread current context
- * pointer are managed by this module too.
- *
- * This module is intended to be non-Mesa-specific so it can be used
- * with the X/DRI libGL also.
- */
+
 
 
 #ifndef _GLAPI_H
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index 0d1f71c..2717ed6 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -29,51 +29,6 @@
  * \author Brian Paul
  */
 
-/**
- * \mainpage Mesa Main Module
- *
- * \section MainIntroduction Introduction
- *
- * The Mesa Main module consists of all the files in the main/ directory.
- * Among the features of this module are:
- * 
- *  Structures to represent most GL state 
- *  State set/get functions 
- *  Display lists 
- *  Texture unit, object and image handling 
- *  Matrix and attribute stacks 
- * 
- *
- * Other modules are responsible for API dispatch, vertex transformation,
- * point/line/triangle setup, rasterization, vertex array caching,
- * vertex/fragment programs/shaders, etc.
- *
- *
- * \section AboutDoxygen About Doxygen
- *
- * If you're viewing this information as Doxygen-generated HTML you'll
- * see the documentation index at the top of this page.
- *
- * The first line lists the Mesa source code modules.
- * The second line lists the indexes available for viewing the documentation
- * for each module.
- *
- * Selecting the Main page link will display a summary of the module
- * (this page).
- *
- * Selecting Data Structures will list all C structures.
- *
- * Selecting the File List link will list all the source files in
- * the module.
- * Selecting a filename will show a list of all functions defined in that file.
- *
- * Selecting the Data Fields link will display a list of all
- * documented structure members.
- *
- * Selecting the Globals link will display a list
- * of all functions, structures, global variables and macros in the module.
- *
- */
 
 
 #include "glheader.h"
diff --git a/src/mesa/program/program.h b/src/mesa/program/program.h
index 34965ab..17b21f9 100644
--- a/src/mesa/program/program.h
+++ b/src/mesa/program/program.h
@@ -29,13 +29,7 @@
  */
 
 
-/**
- * \mainpage Mesa vertex and fragment program module
- *
- * This module or directory contains most of the code for vertex and
- * fragment programs and shaders, including state management, parsers,
- * and (some) software routines for executing programs
- */
+
 
 #ifndef PROGRAM_H
 #define PROGRAM_H
diff --git a/src/mesa/swrast/s_context.h b/src/mesa/swrast/s_context.h
index eec711f..5508dce 100644
--- a/src/mesa/swrast/s_context.h
+++ b/src/mesa/swrast/s_context.h
@@ -29,15 +29,7 @@
  * \author Keith Whitwell 
  */
 
-/**
- * \mainpage swrast module
- *
- * This module, software rasterization, contains the software fallback
- * routines for drawing points, lines, triangles, bitmaps and images.
- * All rendering boils down to writing spans (arrays) of pixels with
- * particular colors.  The span-writing routines must be implemented
- * by the device driver.
- */
+
 
 
 #ifndef S_CONTEXT_H
diff --git a/src/mesa/tnl/t_context.h b/src/mesa/tnl/t_context.h
index e89a7f8..61df562 100644
--- a/src/mesa/tnl/t_context.h
+++ b/src/mesa/tnl/t_context.h
@@ -29,21 +29,7 @@
  */
 
 
-/**
- * \mainpage The TNL-module
- *
- * TNL stands for "transform and lighting", i.e. this module implements
- * a pipeline that receives as input a buffer of vertices and does al

[Mesa-dev] [PATCH 3/3] doxy-text files added

2013-10-07 Thread Kevin Rogovin
---
 doxygen/all.doxy |   1 +
 src/gbm/gbm.doxy_text|  15 ++
 src/mesa/drivers/dri/i965/i965.doxy_text | 176 +
 src/mesa/main/main.doxy_text | 257 +++
 src/mesa/program/program.doxy_text   |  33 
 src/mesa/swrast/swrast.doxy_text |  42 +
 src/mesa/tnl/tnl.doxy_text   |  33 
 src/mesa/vbo/vbo.doxy_text   | 158 +++
 8 files changed, 715 insertions(+)
 create mode 100644 src/gbm/gbm.doxy_text
 create mode 100644 src/mesa/drivers/dri/i965/i965.doxy_text
 create mode 100644 src/mesa/main/main.doxy_text
 create mode 100644 src/mesa/program/program.doxy_text
 create mode 100644 src/mesa/swrast/swrast.doxy_text
 create mode 100644 src/mesa/tnl/tnl.doxy_text
 create mode 100644 src/mesa/vbo/vbo.doxy_text

diff --git a/doxygen/all.doxy b/doxygen/all.doxy
index 46a00de..e86fe00 100644
--- a/doxygen/all.doxy
+++ b/doxygen/all.doxy
@@ -37,6 +37,7 @@ INPUT  = ../src/mesa/main/ \
 ../src/mesa/drivers/dri/i965 \
 ../src/glx/ \
 ../src/glsl/ \
+ ../src/gbm \
 ../src/gbm/main \
 ../src/gbm/backends/dri/ \
 ../src/egl/ \
diff --git a/src/gbm/gbm.doxy_text b/src/gbm/gbm.doxy_text
new file mode 100644
index 000..3730549
--- /dev/null
+++ b/src/gbm/gbm.doxy_text
@@ -0,0 +1,15 @@
+/**
+ * \page GBM The Generic Buffer Manager
+ *
+ * This module provides an abstraction that the caller can use to request a
+ * buffer from the underlying memory management system for the platform.
+ *
+ * This allows the creation of portable code whilst still allowing access to
+ * the underlying memory manager.
+ */
+
+- ../src/gbm/backends/dri/gbm_dri.c
+- ../src/gbm/backends/dri/driver_name.c
+- ../src/gbm/main/common.c
+- ../src/gbm/main/backend.c
+- ../src/gbm/main/gbm.c
diff --git a/src/mesa/drivers/dri/i965/i965.doxy_text 
b/src/mesa/drivers/dri/i965/i965.doxy_text
new file mode 100644
index 000..abbf049
--- /dev/null
+++ b/src/mesa/drivers/dri/i965/i965.doxy_text
@@ -0,0 +1,176 @@
+/*!
+
+\page I965DRIVER i965 Driver
+
+\section I965DRIVER_OVW Overview
+  The i965 driver implements the driver hardware backend for Intel GPU's for 
+generation 4, 5, 6, 7 and 7.5 (in progress), The GL context is embodied by 
+\ref brw_context (whose first member variable is \ref gl_context to allow
+for simple upcasting). 
+
+\subsection I965DRIVER_INIT Initialization
+
+An instance of a \ref brw_context is created with \ref brwCreateContext().
+
+Driver functions, i.e. values copied into \ref gl_context#Driver 
+(by \ref _mesa_initialize_context() ) are essentially 
+determined by \ref brwInitDriverFunctions(). Note that what functions are 
used, 
+and for that matter what features are supported, depends on 
+the value of \ref intel_screen#gen (copied to \ref brw_context#gen)
+which specifies the GPU Intel generation (6=Sandy Bridge, 7=Ivy Bridge, etc).
+
+In addition, a number of the functions to which values of 
+\ref gl_context#Driver are set rely on values stored in the function
+table \ref brw_context#vbl. These values are set in \ref brwInitVtbl().
+
+The draw function, see \ref vbo_context#draw_prims is \ref brw_draw_prims().
+
+\subsection SS_i965 State and Sending State to GPU
+
+The i965 driver creates a command stream to which to send to the GPU (see ).
+How state changes/values are updated is different for different generations. To
+handle this, the i965 driver makes use of \ref brw_tracked_state values
+to track state and correctly insert the values into the instruction stream.
+What functions to use is set by \ref brw_init_state(), the function to use
+and the "current state of the GPU as far as the context is concerned" are
+found in \ref brw_context#atoms. Change state is uploaded
+for each draw call (see \ref brw_draw_prims()) by \ref brw_upload_state(). 
+
+
+\section ToClassify
+Files left to look at
+- src/mesa/drivers/dri/i965/brw_binding_tables.c
+- src/mesa/drivers/dri/i965/brw_blorp_blit.cpp
+- src/mesa/drivers/dri/i965/brw_blorp_clear.cpp
+- src/mesa/drivers/dri/i965/brw_blorp.cpp
+- src/mesa/drivers/dri/i965/brw_cc.c
+- src/mesa/drivers/dri/i965/brw_cfg.cpp
+- src/mesa/drivers/dri/i965/brw_clear.c
+- src/mesa/drivers/dri/i965/brw_clip.c
+- src/mesa/drivers/dri/i965/brw_clip_line.c
+- src/mesa/drivers/dri/i965/brw_clip_point.c
+- src/mesa/drivers/dri/i965/brw_clip_state.c
+- src/mesa/drivers/dri/i965/brw_clip_tri.c
+- src/mesa/drivers/dri/i965/brw_clip_unfilled.c
+- src/mesa/drivers/dri/i965/brw_clip_util.c
+- src/mesa/drivers/dri/i965/brw_context.c
+- src/mesa/drivers/dri/i965/brw_cubemap_normalize.cpp
+- src/mesa/drivers/dri/i965/brw_curbe.c
+- src/mesa/drivers/dri/i965/brw_disasm.c
+- src/mesa/drivers/dri/i965/brw_draw.c
+- src/mesa/drivers/dri/i965/brw_draw_upload.c
+- src/mesa/

[Mesa-dev] [PATCH 2/3] remove main page tags from source files

2013-10-07 Thread Kevin Rogovin
---
 src/gbm/main/gbm.h  | 10 +-
 src/mapi/glapi/glapi.h  | 17 +
 src/mesa/main/context.c | 45 -
 src/mesa/program/program.h  |  8 +---
 src/mesa/swrast/s_context.h | 10 +-
 src/mesa/tnl/t_context.h| 16 +---
 src/mesa/vbo/vbo_context.h  | 18 --
 src/mesa/vbo/vbo_split.h|  8 +---
 8 files changed, 6 insertions(+), 126 deletions(-)

diff --git a/src/gbm/main/gbm.h b/src/gbm/main/gbm.h
index 9d2a030..ee4bd75 100644
--- a/src/gbm/main/gbm.h
+++ b/src/gbm/main/gbm.h
@@ -46,15 +46,7 @@ struct gbm_device;
 struct gbm_bo;
 struct gbm_surface;
 
-/**
- * \mainpage The Generic Buffer Manager
- *
- * This module provides an abstraction that the caller can use to request a
- * buffer from the underlying memory management system for the platform.
- *
- * This allows the creation of portable code whilst still allowing access to
- * the underlying memory manager.
- */
+
 
 /**
  * Abstraction representing the handle to a buffer allocated by the
diff --git a/src/mapi/glapi/glapi.h b/src/mapi/glapi/glapi.h
index c764271..bf6e0de 100644
--- a/src/mapi/glapi/glapi.h
+++ b/src/mapi/glapi/glapi.h
@@ -23,22 +23,7 @@
  */
 
 
-/**
- * \mainpage Mesa GL API Module
- *
- * \section GLAPIIntroduction Introduction
- *
- * The Mesa GL API module is responsible for dispatching all the
- * gl*() functions.  All GL functions are dispatched by jumping through
- * the current dispatch table (basically a struct full of function
- * pointers.)
- *
- * A per-thread current dispatch table and per-thread current context
- * pointer are managed by this module too.
- *
- * This module is intended to be non-Mesa-specific so it can be used
- * with the X/DRI libGL also.
- */
+
 
 
 #ifndef _GLAPI_H
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index 0d1f71c..2717ed6 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -29,51 +29,6 @@
  * \author Brian Paul
  */
 
-/**
- * \mainpage Mesa Main Module
- *
- * \section MainIntroduction Introduction
- *
- * The Mesa Main module consists of all the files in the main/ directory.
- * Among the features of this module are:
- * 
- *  Structures to represent most GL state 
- *  State set/get functions 
- *  Display lists 
- *  Texture unit, object and image handling 
- *  Matrix and attribute stacks 
- * 
- *
- * Other modules are responsible for API dispatch, vertex transformation,
- * point/line/triangle setup, rasterization, vertex array caching,
- * vertex/fragment programs/shaders, etc.
- *
- *
- * \section AboutDoxygen About Doxygen
- *
- * If you're viewing this information as Doxygen-generated HTML you'll
- * see the documentation index at the top of this page.
- *
- * The first line lists the Mesa source code modules.
- * The second line lists the indexes available for viewing the documentation
- * for each module.
- *
- * Selecting the Main page link will display a summary of the module
- * (this page).
- *
- * Selecting Data Structures will list all C structures.
- *
- * Selecting the File List link will list all the source files in
- * the module.
- * Selecting a filename will show a list of all functions defined in that file.
- *
- * Selecting the Data Fields link will display a list of all
- * documented structure members.
- *
- * Selecting the Globals link will display a list
- * of all functions, structures, global variables and macros in the module.
- *
- */
 
 
 #include "glheader.h"
diff --git a/src/mesa/program/program.h b/src/mesa/program/program.h
index 34965ab..17b21f9 100644
--- a/src/mesa/program/program.h
+++ b/src/mesa/program/program.h
@@ -29,13 +29,7 @@
  */
 
 
-/**
- * \mainpage Mesa vertex and fragment program module
- *
- * This module or directory contains most of the code for vertex and
- * fragment programs and shaders, including state management, parsers,
- * and (some) software routines for executing programs
- */
+
 
 #ifndef PROGRAM_H
 #define PROGRAM_H
diff --git a/src/mesa/swrast/s_context.h b/src/mesa/swrast/s_context.h
index eec711f..5508dce 100644
--- a/src/mesa/swrast/s_context.h
+++ b/src/mesa/swrast/s_context.h
@@ -29,15 +29,7 @@
  * \author Keith Whitwell 
  */
 
-/**
- * \mainpage swrast module
- *
- * This module, software rasterization, contains the software fallback
- * routines for drawing points, lines, triangles, bitmaps and images.
- * All rendering boils down to writing spans (arrays) of pixels with
- * particular colors.  The span-writing routines must be implemented
- * by the device driver.
- */
+
 
 
 #ifndef S_CONTEXT_H
diff --git a/src/mesa/tnl/t_context.h b/src/mesa/tnl/t_context.h
index e89a7f8..61df562 100644
--- a/src/mesa/tnl/t_context.h
+++ b/src/mesa/tnl/t_context.h
@@ -29,21 +29,7 @@
  */
 
 
-/**
- * \mainpage The TNL-module
- *
- * TNL stands for "transform and lighting", i.e. this module implements
- * a pipeline that receives as input a buffer of vertices and does al

[Mesa-dev] [PATCH 3/3] doxy-text files added

2013-10-07 Thread Kevin Rogovin
---
 doxygen/all.doxy |   1 +
 src/gbm/gbm.doxy_text|  15 ++
 src/mesa/drivers/dri/i965/i965.doxy_text | 176 +
 src/mesa/main/main.doxy_text | 257 +++
 src/mesa/program/program.doxy_text   |  33 
 src/mesa/swrast/swrast.doxy_text |  42 +
 src/mesa/tnl/tnl.doxy_text   |  33 
 src/mesa/vbo/vbo.doxy_text   | 158 +++
 8 files changed, 715 insertions(+)
 create mode 100644 src/gbm/gbm.doxy_text
 create mode 100644 src/mesa/drivers/dri/i965/i965.doxy_text
 create mode 100644 src/mesa/main/main.doxy_text
 create mode 100644 src/mesa/program/program.doxy_text
 create mode 100644 src/mesa/swrast/swrast.doxy_text
 create mode 100644 src/mesa/tnl/tnl.doxy_text
 create mode 100644 src/mesa/vbo/vbo.doxy_text

diff --git a/doxygen/all.doxy b/doxygen/all.doxy
index 46a00de..e86fe00 100644
--- a/doxygen/all.doxy
+++ b/doxygen/all.doxy
@@ -37,6 +37,7 @@ INPUT  = ../src/mesa/main/ \
 ../src/mesa/drivers/dri/i965 \
 ../src/glx/ \
 ../src/glsl/ \
+ ../src/gbm \
 ../src/gbm/main \
 ../src/gbm/backends/dri/ \
 ../src/egl/ \
diff --git a/src/gbm/gbm.doxy_text b/src/gbm/gbm.doxy_text
new file mode 100644
index 000..3730549
--- /dev/null
+++ b/src/gbm/gbm.doxy_text
@@ -0,0 +1,15 @@
+/**
+ * \page GBM The Generic Buffer Manager
+ *
+ * This module provides an abstraction that the caller can use to request a
+ * buffer from the underlying memory management system for the platform.
+ *
+ * This allows the creation of portable code whilst still allowing access to
+ * the underlying memory manager.
+ */
+
+- ../src/gbm/backends/dri/gbm_dri.c
+- ../src/gbm/backends/dri/driver_name.c
+- ../src/gbm/main/common.c
+- ../src/gbm/main/backend.c
+- ../src/gbm/main/gbm.c
diff --git a/src/mesa/drivers/dri/i965/i965.doxy_text 
b/src/mesa/drivers/dri/i965/i965.doxy_text
new file mode 100644
index 000..abbf049
--- /dev/null
+++ b/src/mesa/drivers/dri/i965/i965.doxy_text
@@ -0,0 +1,176 @@
+/*!
+
+\page I965DRIVER i965 Driver
+
+\section I965DRIVER_OVW Overview
+  The i965 driver implements the driver hardware backend for Intel GPU's for 
+generation 4, 5, 6, 7 and 7.5 (in progress), The GL context is embodied by 
+\ref brw_context (whose first member variable is \ref gl_context to allow
+for simple upcasting). 
+
+\subsection I965DRIVER_INIT Initialization
+
+An instance of a \ref brw_context is created with \ref brwCreateContext().
+
+Driver functions, i.e. values copied into \ref gl_context#Driver 
+(by \ref _mesa_initialize_context() ) are essentially 
+determined by \ref brwInitDriverFunctions(). Note that what functions are 
used, 
+and for that matter what features are supported, depends on 
+the value of \ref intel_screen#gen (copied to \ref brw_context#gen)
+which specifies the GPU Intel generation (6=Sandy Bridge, 7=Ivy Bridge, etc).
+
+In addition, a number of the functions to which values of 
+\ref gl_context#Driver are set rely on values stored in the function
+table \ref brw_context#vbl. These values are set in \ref brwInitVtbl().
+
+The draw function, see \ref vbo_context#draw_prims is \ref brw_draw_prims().
+
+\subsection SS_i965 State and Sending State to GPU
+
+The i965 driver creates a command stream to which to send to the GPU (see ).
+How state changes/values are updated is different for different generations. To
+handle this, the i965 driver makes use of \ref brw_tracked_state values
+to track state and correctly insert the values into the instruction stream.
+What functions to use is set by \ref brw_init_state(), the function to use
+and the "current state of the GPU as far as the context is concerned" are
+found in \ref brw_context#atoms. Change state is uploaded
+for each draw call (see \ref brw_draw_prims()) by \ref brw_upload_state(). 
+
+
+\section ToClassify
+Files left to look at
+- src/mesa/drivers/dri/i965/brw_binding_tables.c
+- src/mesa/drivers/dri/i965/brw_blorp_blit.cpp
+- src/mesa/drivers/dri/i965/brw_blorp_clear.cpp
+- src/mesa/drivers/dri/i965/brw_blorp.cpp
+- src/mesa/drivers/dri/i965/brw_cc.c
+- src/mesa/drivers/dri/i965/brw_cfg.cpp
+- src/mesa/drivers/dri/i965/brw_clear.c
+- src/mesa/drivers/dri/i965/brw_clip.c
+- src/mesa/drivers/dri/i965/brw_clip_line.c
+- src/mesa/drivers/dri/i965/brw_clip_point.c
+- src/mesa/drivers/dri/i965/brw_clip_state.c
+- src/mesa/drivers/dri/i965/brw_clip_tri.c
+- src/mesa/drivers/dri/i965/brw_clip_unfilled.c
+- src/mesa/drivers/dri/i965/brw_clip_util.c
+- src/mesa/drivers/dri/i965/brw_context.c
+- src/mesa/drivers/dri/i965/brw_cubemap_normalize.cpp
+- src/mesa/drivers/dri/i965/brw_curbe.c
+- src/mesa/drivers/dri/i965/brw_disasm.c
+- src/mesa/drivers/dri/i965/brw_draw.c
+- src/mesa/drivers/dri/i965/brw_draw_upload.c
+- src/mesa/

[Mesa-dev] [PATCH] nicer-no-wrap-patch

2013-11-11 Thread Kevin Rogovin
This patch adds a function interface for enabling no wrap on batch commands,
adds to it assert enforcement that the number bytes added to the
batch buffer does not exceed a passed value and finally this is used
in brw_try_draw_prims() to help make sure that estimated_max_prim_size
is a good value.

---
 src/mesa/drivers/dri/i965/brw_context.h   | 64 +++
 src/mesa/drivers/dri/i965/brw_draw.c  |  4 +-
 src/mesa/drivers/dri/i965/brw_state_batch.c   | 15 ++-
 src/mesa/drivers/dri/i965/intel_batchbuffer.h |  5 +++
 4 files changed, 84 insertions(+), 4 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_context.h 
b/src/mesa/drivers/dri/i965/brw_context.h
index 8b1cbb3..953f2cf 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -1028,8 +1028,29 @@ struct brw_context
uint32_t reset_count;
 
struct intel_batchbuffer batch;
+
+   /*!\var no_batch_wrap
+ While no_batch_wrap is true, the batch buffer must not
+ be flushed. Use the functions begin_no_batch_wrap() and
+ end_no_batch_wrap() to mark the start and end points
+ that the batch buffer must not be flushed.
+*/
bool no_batch_wrap;
 
+   /*!\var max_expected_batch_size_during_no_batch_wrap
+ If \ref no_batch_wrap is true, specifies the number
+ of bytes that are expected before \ref no_batch_wrap
+ is set to false.
+*/
+   int max_expected_batch_size_during_no_batch_wrap;
+
+   /*!\var number_bytes_consumed_during_no_batch_wrap
+ records the number of bytes consumed so far
+ in the batch buffer since the last time \ref 
+ no_batch_wrap was set to true
+*/
+   int number_bytes_consumed_during_no_batch_wrap;
+
struct {
   drm_intel_bo *bo;
   GLuint offset;
@@ -1450,6 +1471,49 @@ is_power_of_two(uint32_t value)
return (value & (value - 1)) == 0;
 }
 
+/*!\fn begin_no_batch_wrap
+  Function to mark the start of a sequence of commands and state 
+  added to the batch buffer that must not be partitioned by
+  a flush. 
+  Requirements: 
+  - no_batch_wrap is false
+
+  Output/side effects:
+  - no_batch_wrap set to true
+  - max_expected_batch_size_during_no_batch_wrap set
+  - number_bytes_consumed_during_no_batch_wrap reset to 0
+
+  \ref brw "GL context"
+  \ref pmax_expected_batch_size value specifying expected maximum number of 
bytes to 
+be consumed in the batch buffer  
+ */ 
+static INLINE void
+begin_no_batch_wrap(struct brw_context *brw, int pmax_expected_batch_size)
+{
+   assert(!brw->no_batch_wrap);
+   brw->no_batch_wrap=true;
+   brw->max_expected_batch_size_during_no_batch_wrap=pmax_expected_batch_size;
+   brw->number_bytes_consumed_during_no_batch_wrap=0;
+}
+
+/*!\fn end_no_batch_wrap
+  Function to mark the end of a sequence of commands and state 
+  added to the batch buffer that must not be partitioned by
+  a flush. 
+  Requirements:
+  - no_batch_wrap is true
+
+  Output/side effects:
+  - no_batch_wrap set to false
+ */
+static INLINE void
+end_no_batch_wrap(struct brw_context *brw)
+{
+   assert(brw->no_batch_wrap);
+   brw->no_batch_wrap=false;
+}
+
+
 /*==
  * brw_vtbl.c
  */
diff --git a/src/mesa/drivers/dri/i965/brw_draw.c 
b/src/mesa/drivers/dri/i965/brw_draw.c
index 7b33b76..12f0ffe 100644
--- a/src/mesa/drivers/dri/i965/brw_draw.c
+++ b/src/mesa/drivers/dri/i965/brw_draw.c
@@ -416,14 +416,14 @@ retry:
* *_set_prim or intel_batchbuffer_flush(), which only impacts
* brw->state.dirty.brw.
*/
+  begin_no_batch_wrap(brw, estimated_max_prim_size);
   if (brw->state.dirty.brw) {
-brw->no_batch_wrap = true;
 brw_upload_state(brw);
   }
 
   brw_emit_prim(brw, &prims[i], brw->primitive);
+  end_no_batch_wrap(brw);
 
-  brw->no_batch_wrap = false;
 
   if (dri_bufmgr_check_aperture_space(&brw->batch.bo, 1)) {
 if (!fail_next) {
diff --git a/src/mesa/drivers/dri/i965/brw_state_batch.c 
b/src/mesa/drivers/dri/i965/brw_state_batch.c
index c71d2f3..ff51c21 100644
--- a/src/mesa/drivers/dri/i965/brw_state_batch.c
+++ b/src/mesa/drivers/dri/i965/brw_state_batch.c
@@ -9,8 +9,7 @@
  without limitation the rights to use, copy, modify, merge, publish,
  distribute, sublicense, and/or sell copies of the Software, and to
  permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
- 
+ the following conditions: 
  The above copyright notice and this permission notice (including the
  next paragraph) shall be included in all copies or substantial
  portions of the Software.
@@ -127,6 +126,18 @@ brw_state_batch(struct brw_context *brw,
assert(size < batch->bo->size);
offset = ROUND_DOWN_TO(batch->state_batch_offset - size, alignment);
 
+#ifdef DEBUG
+   if(brw->no_batch_wrap) {
+  /*
+although the request is for size bytes, the consumption can be great

[Mesa-dev] [PATCH] nicer-no-wrap-patch

2013-11-11 Thread Kevin Rogovin
feedback integrated

space-pace
---
 src/mesa/drivers/dri/i965/brw_context.h   | 85 +++
 src/mesa/drivers/dri/i965/brw_draw.c  |  4 +-
 src/mesa/drivers/dri/i965/brw_state_batch.c   | 15 +
 src/mesa/drivers/dri/i965/intel_batchbuffer.h |  6 ++
 4 files changed, 108 insertions(+), 2 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_context.h 
b/src/mesa/drivers/dri/i965/brw_context.h
index 8b1cbb3..638e570 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -1028,8 +1028,37 @@ struct brw_context
uint32_t reset_count;
 
struct intel_batchbuffer batch;
+
+   /**
+* Debug-only: flag to indicate to that batch buffer flush 
+* should not happen
+* 
+* While no_batch_wrap is true, the batch buffer must not
+* be flushed. Use the functions begin_no_batch_wrap() and
+* end_no_batch_wrap() to mark the start and end points
+* that the batch buffer must not be flushed.
+*/
bool no_batch_wrap;
 
+   /**
+* Debug-only: expected maximum number bytes added to 
+* batch buffer
+*
+* If \ref no_batch_wrap is true, specifies the number
+* of bytes that are expected before \ref no_batch_wrap
+* is set to false.
+*/
+   int max_expected_batch_size_during_no_batch_wrap;
+
+   /**
+* Debug-only: current number of bytes added to batch buffer
+*
+* records the number of bytes consumed so far
+* in the batch buffer since the last time \ref 
+* no_batch_wrap was set to true
+*/
+   int number_bytes_consumed_during_no_batch_wrap;
+
struct {
   drm_intel_bo *bo;
   GLuint offset;
@@ -1450,6 +1479,62 @@ is_power_of_two(uint32_t value)
return (value & (value - 1)) == 0;
 }
 
+/**
+ * Affect only in debug: Begin mark of don't flush batch buffer
+ *
+ * Function to mark the start of a sequence of commands and state 
+ * added to the batch buffer that must not be partitioned by
+ * a flush. 
+ * Requirements: 
+ * - no_batch_wrap is false
+ *
+ * Output/side effects:
+ * - no_batch_wrap set to true
+ * - max_expected_batch_size_during_no_batch_wrap set
+ * - number_bytes_consumed_during_no_batch_wrap reset to 0
+ *
+ * \ref brw context pointer
+ * \ref pmax_expected_batch_size value specifying expected maximum number of 
bytes to 
+ *   be consumed in the batch buffer  
+ */ 
+static INLINE void
+begin_no_batch_wrap(struct brw_context *brw, int pmax_expected_batch_size)
+{
+#ifdef DEBUG
+   assert(!brw->no_batch_wrap);
+   brw->no_batch_wrap=true;
+   brw->max_expected_batch_size_during_no_batch_wrap=pmax_expected_batch_size;
+   brw->number_bytes_consumed_during_no_batch_wrap=0;
+#else
+   (void)brw;
+   (void)pmax_expected_batch_size;
+#endif
+}
+
+/**
+ * Affect only in Debug only: end mark of don't flush batch buffer
+ *
+ * Function to mark the end of a sequence of commands and state 
+ * added to the batch buffer that must not be partitioned by
+ * a flush. 
+ * Requirements:
+ * - no_batch_wrap is true
+ *
+ * Output/side effects:
+ * - no_batch_wrap set to false
+ */
+static INLINE void
+end_no_batch_wrap(struct brw_context *brw)
+{
+#ifdef DEBUG
+   assert(brw->no_batch_wrap);
+   brw->no_batch_wrap=false;
+#else
+   (void)brw;
+#endif
+}
+
+
 /*==
  * brw_vtbl.c
  */
diff --git a/src/mesa/drivers/dri/i965/brw_draw.c 
b/src/mesa/drivers/dri/i965/brw_draw.c
index 7b33b76..12f0ffe 100644
--- a/src/mesa/drivers/dri/i965/brw_draw.c
+++ b/src/mesa/drivers/dri/i965/brw_draw.c
@@ -416,14 +416,14 @@ retry:
* *_set_prim or intel_batchbuffer_flush(), which only impacts
* brw->state.dirty.brw.
*/
+  begin_no_batch_wrap(brw, estimated_max_prim_size);
   if (brw->state.dirty.brw) {
-brw->no_batch_wrap = true;
 brw_upload_state(brw);
   }
 
   brw_emit_prim(brw, &prims[i], brw->primitive);
+  end_no_batch_wrap(brw);
 
-  brw->no_batch_wrap = false;
 
   if (dri_bufmgr_check_aperture_space(&brw->batch.bo, 1)) {
 if (!fail_next) {
diff --git a/src/mesa/drivers/dri/i965/brw_state_batch.c 
b/src/mesa/drivers/dri/i965/brw_state_batch.c
index c71d2f3..60d3c2d 100644
--- a/src/mesa/drivers/dri/i965/brw_state_batch.c
+++ b/src/mesa/drivers/dri/i965/brw_state_batch.c
@@ -127,6 +127,21 @@ brw_state_batch(struct brw_context *brw,
assert(size < batch->bo->size);
offset = ROUND_DOWN_TO(batch->state_batch_offset - size, alignment);
 
+#ifdef DEBUG
+   if(brw->no_batch_wrap) {
+  /* although the request is for size bytes, the consumption 
+   * can be greater because of alignment, thus we use the 
+   * differences of the new-to-be offset with the old 
+   * offset value.
+   */
+  brw->number_bytes_consumed_during_no_batch_wrap += 
+ (batch->state_batch_offset-offset);
+
+  assert(brw->number_bytes_consumed_during_no_batch_wrap <= 
+

[Mesa-dev] [PATCH] nicer-no-wrap-patch

2013-11-11 Thread Kevin Rogovin
Track bytes written during no flush phases for debug builds 


---
 src/mesa/drivers/dri/i965/brw_context.h   | 85 +++
 src/mesa/drivers/dri/i965/brw_draw.c  |  4 +-
 src/mesa/drivers/dri/i965/brw_state_batch.c   | 15 +
 src/mesa/drivers/dri/i965/intel_batchbuffer.h |  6 ++
 4 files changed, 108 insertions(+), 2 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_context.h 
b/src/mesa/drivers/dri/i965/brw_context.h
index 8b1cbb3..638e570 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -1028,8 +1028,37 @@ struct brw_context
uint32_t reset_count;
 
struct intel_batchbuffer batch;
+
+   /**
+* Debug-only: flag to indicate to that batch buffer flush 
+* should not happen
+* 
+* While no_batch_wrap is true, the batch buffer must not
+* be flushed. Use the functions begin_no_batch_wrap() and
+* end_no_batch_wrap() to mark the start and end points
+* that the batch buffer must not be flushed.
+*/
bool no_batch_wrap;
 
+   /**
+* Debug-only: expected maximum number bytes added to 
+* batch buffer
+*
+* If \ref no_batch_wrap is true, specifies the number
+* of bytes that are expected before \ref no_batch_wrap
+* is set to false.
+*/
+   int max_expected_batch_size_during_no_batch_wrap;
+
+   /**
+* Debug-only: current number of bytes added to batch buffer
+*
+* records the number of bytes consumed so far
+* in the batch buffer since the last time \ref 
+* no_batch_wrap was set to true
+*/
+   int number_bytes_consumed_during_no_batch_wrap;
+
struct {
   drm_intel_bo *bo;
   GLuint offset;
@@ -1450,6 +1479,62 @@ is_power_of_two(uint32_t value)
return (value & (value - 1)) == 0;
 }
 
+/**
+ * Affect only in debug: Begin mark of don't flush batch buffer
+ *
+ * Function to mark the start of a sequence of commands and state 
+ * added to the batch buffer that must not be partitioned by
+ * a flush. 
+ * Requirements: 
+ * - no_batch_wrap is false
+ *
+ * Output/side effects:
+ * - no_batch_wrap set to true
+ * - max_expected_batch_size_during_no_batch_wrap set
+ * - number_bytes_consumed_during_no_batch_wrap reset to 0
+ *
+ * \ref brw context pointer
+ * \ref pmax_expected_batch_size value specifying expected maximum number of 
bytes to 
+ *   be consumed in the batch buffer  
+ */ 
+static INLINE void
+begin_no_batch_wrap(struct brw_context *brw, int pmax_expected_batch_size)
+{
+#ifdef DEBUG
+   assert(!brw->no_batch_wrap);
+   brw->no_batch_wrap=true;
+   brw->max_expected_batch_size_during_no_batch_wrap=pmax_expected_batch_size;
+   brw->number_bytes_consumed_during_no_batch_wrap=0;
+#else
+   (void)brw;
+   (void)pmax_expected_batch_size;
+#endif
+}
+
+/**
+ * Affect only in Debug only: end mark of don't flush batch buffer
+ *
+ * Function to mark the end of a sequence of commands and state 
+ * added to the batch buffer that must not be partitioned by
+ * a flush. 
+ * Requirements:
+ * - no_batch_wrap is true
+ *
+ * Output/side effects:
+ * - no_batch_wrap set to false
+ */
+static INLINE void
+end_no_batch_wrap(struct brw_context *brw)
+{
+#ifdef DEBUG
+   assert(brw->no_batch_wrap);
+   brw->no_batch_wrap=false;
+#else
+   (void)brw;
+#endif
+}
+
+
 /*==
  * brw_vtbl.c
  */
diff --git a/src/mesa/drivers/dri/i965/brw_draw.c 
b/src/mesa/drivers/dri/i965/brw_draw.c
index 7b33b76..12f0ffe 100644
--- a/src/mesa/drivers/dri/i965/brw_draw.c
+++ b/src/mesa/drivers/dri/i965/brw_draw.c
@@ -416,14 +416,14 @@ retry:
* *_set_prim or intel_batchbuffer_flush(), which only impacts
* brw->state.dirty.brw.
*/
+  begin_no_batch_wrap(brw, estimated_max_prim_size);
   if (brw->state.dirty.brw) {
-brw->no_batch_wrap = true;
 brw_upload_state(brw);
   }
 
   brw_emit_prim(brw, &prims[i], brw->primitive);
+  end_no_batch_wrap(brw);
 
-  brw->no_batch_wrap = false;
 
   if (dri_bufmgr_check_aperture_space(&brw->batch.bo, 1)) {
 if (!fail_next) {
diff --git a/src/mesa/drivers/dri/i965/brw_state_batch.c 
b/src/mesa/drivers/dri/i965/brw_state_batch.c
index c71d2f3..60d3c2d 100644
--- a/src/mesa/drivers/dri/i965/brw_state_batch.c
+++ b/src/mesa/drivers/dri/i965/brw_state_batch.c
@@ -127,6 +127,21 @@ brw_state_batch(struct brw_context *brw,
assert(size < batch->bo->size);
offset = ROUND_DOWN_TO(batch->state_batch_offset - size, alignment);
 
+#ifdef DEBUG
+   if(brw->no_batch_wrap) {
+  /* although the request is for size bytes, the consumption 
+   * can be greater because of alignment, thus we use the 
+   * differences of the new-to-be offset with the old 
+   * offset value.
+   */
+  brw->number_bytes_consumed_during_no_batch_wrap += 
+ (batch->state_batch_offset-offset);
+
+  assert(brw->number_bytes_consumed_dur

[Mesa-dev] [PATCH] nicer-no-wrap-patch

2013-11-11 Thread Kevin Rogovin
feedback integrated

space-pace
---
 src/mesa/drivers/dri/i965/brw_context.h   | 85 +++
 src/mesa/drivers/dri/i965/brw_draw.c  |  4 +-
 src/mesa/drivers/dri/i965/brw_state_batch.c   | 15 +
 src/mesa/drivers/dri/i965/intel_batchbuffer.h |  6 ++
 4 files changed, 108 insertions(+), 2 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_context.h 
b/src/mesa/drivers/dri/i965/brw_context.h
index 8b1cbb3..638e570 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -1028,8 +1028,37 @@ struct brw_context
uint32_t reset_count;
 
struct intel_batchbuffer batch;
+
+   /**
+* Debug-only: flag to indicate to that batch buffer flush 
+* should not happen
+* 
+* While no_batch_wrap is true, the batch buffer must not
+* be flushed. Use the functions begin_no_batch_wrap() and
+* end_no_batch_wrap() to mark the start and end points
+* that the batch buffer must not be flushed.
+*/
bool no_batch_wrap;
 
+   /**
+* Debug-only: expected maximum number bytes added to 
+* batch buffer
+*
+* If \ref no_batch_wrap is true, specifies the number
+* of bytes that are expected before \ref no_batch_wrap
+* is set to false.
+*/
+   int max_expected_batch_size_during_no_batch_wrap;
+
+   /**
+* Debug-only: current number of bytes added to batch buffer
+*
+* records the number of bytes consumed so far
+* in the batch buffer since the last time \ref 
+* no_batch_wrap was set to true
+*/
+   int number_bytes_consumed_during_no_batch_wrap;
+
struct {
   drm_intel_bo *bo;
   GLuint offset;
@@ -1450,6 +1479,62 @@ is_power_of_two(uint32_t value)
return (value & (value - 1)) == 0;
 }
 
+/**
+ * Affect only in debug: Begin mark of don't flush batch buffer
+ *
+ * Function to mark the start of a sequence of commands and state 
+ * added to the batch buffer that must not be partitioned by
+ * a flush. 
+ * Requirements: 
+ * - no_batch_wrap is false
+ *
+ * Output/side effects:
+ * - no_batch_wrap set to true
+ * - max_expected_batch_size_during_no_batch_wrap set
+ * - number_bytes_consumed_during_no_batch_wrap reset to 0
+ *
+ * \ref brw context pointer
+ * \ref pmax_expected_batch_size value specifying expected maximum number of 
bytes to 
+ *   be consumed in the batch buffer  
+ */ 
+static INLINE void
+begin_no_batch_wrap(struct brw_context *brw, int pmax_expected_batch_size)
+{
+#ifdef DEBUG
+   assert(!brw->no_batch_wrap);
+   brw->no_batch_wrap=true;
+   brw->max_expected_batch_size_during_no_batch_wrap=pmax_expected_batch_size;
+   brw->number_bytes_consumed_during_no_batch_wrap=0;
+#else
+   (void)brw;
+   (void)pmax_expected_batch_size;
+#endif
+}
+
+/**
+ * Affect only in Debug only: end mark of don't flush batch buffer
+ *
+ * Function to mark the end of a sequence of commands and state 
+ * added to the batch buffer that must not be partitioned by
+ * a flush. 
+ * Requirements:
+ * - no_batch_wrap is true
+ *
+ * Output/side effects:
+ * - no_batch_wrap set to false
+ */
+static INLINE void
+end_no_batch_wrap(struct brw_context *brw)
+{
+#ifdef DEBUG
+   assert(brw->no_batch_wrap);
+   brw->no_batch_wrap=false;
+#else
+   (void)brw;
+#endif
+}
+
+
 /*==
  * brw_vtbl.c
  */
diff --git a/src/mesa/drivers/dri/i965/brw_draw.c 
b/src/mesa/drivers/dri/i965/brw_draw.c
index 7b33b76..12f0ffe 100644
--- a/src/mesa/drivers/dri/i965/brw_draw.c
+++ b/src/mesa/drivers/dri/i965/brw_draw.c
@@ -416,14 +416,14 @@ retry:
* *_set_prim or intel_batchbuffer_flush(), which only impacts
* brw->state.dirty.brw.
*/
+  begin_no_batch_wrap(brw, estimated_max_prim_size);
   if (brw->state.dirty.brw) {
-brw->no_batch_wrap = true;
 brw_upload_state(brw);
   }
 
   brw_emit_prim(brw, &prims[i], brw->primitive);
+  end_no_batch_wrap(brw);
 
-  brw->no_batch_wrap = false;
 
   if (dri_bufmgr_check_aperture_space(&brw->batch.bo, 1)) {
 if (!fail_next) {
diff --git a/src/mesa/drivers/dri/i965/brw_state_batch.c 
b/src/mesa/drivers/dri/i965/brw_state_batch.c
index c71d2f3..60d3c2d 100644
--- a/src/mesa/drivers/dri/i965/brw_state_batch.c
+++ b/src/mesa/drivers/dri/i965/brw_state_batch.c
@@ -127,6 +127,21 @@ brw_state_batch(struct brw_context *brw,
assert(size < batch->bo->size);
offset = ROUND_DOWN_TO(batch->state_batch_offset - size, alignment);
 
+#ifdef DEBUG
+   if(brw->no_batch_wrap) {
+  /* although the request is for size bytes, the consumption 
+   * can be greater because of alignment, thus we use the 
+   * differences of the new-to-be offset with the old 
+   * offset value.
+   */
+  brw->number_bytes_consumed_during_no_batch_wrap += 
+ (batch->state_batch_offset-offset);
+
+  assert(brw->number_bytes_consumed_during_no_batch_wrap <= 
+

[Mesa-dev] [PATCH 1/2] Allow for GLSL shaders to have #extension directive anywhere in source file.

2013-12-03 Thread Kevin Rogovin
Allow for GLSL shaders to have #extension directive
anywhere in source file; during preprocessor, #extension
directives are saved to a list rather than being added
to the pre-processed string. That list is played back 
before parsing of pre-processed text takes place.  

---
 src/glsl/Makefile.sources   |   3 +-
 src/glsl/glcpp/glcpp-lex.l  |  19 +-
 src/glsl/glcpp/glcpp-parse.y|  31 +-
 src/glsl/glcpp/glcpp.c  |   2 +-
 src/glsl/glcpp/glcpp.h  |  17 +-
 src/glsl/glcpp/glcpp_extras.c   | 126 
 src/glsl/glcpp/glcpp_extras.h   |  97 +++
 src/glsl/glcpp/pp.c |   5 +-
 src/glsl/glsl_parser_extras.cpp |  55 +-
 src/glsl/glsl_parser_extras.h   |  14 -
 10 files changed, 358 insertions(+), 11 deletions(-)
 create mode 100644 src/glsl/glcpp/glcpp_extras.c
 create mode 100644 src/glsl/glcpp/glcpp_extras.h

diff --git a/src/glsl/Makefile.sources b/src/glsl/Makefile.sources
index 2e81ded..90f57ad 100644
--- a/src/glsl/Makefile.sources
+++ b/src/glsl/Makefile.sources
@@ -7,7 +7,8 @@ GLSL_BUILDDIR = $(top_builddir)/src/glsl
 
 LIBGLCPP_FILES = \
$(GLSL_SRCDIR)/ralloc.c \
-   $(GLSL_SRCDIR)/glcpp/pp.c
+   $(GLSL_SRCDIR)/glcpp/pp.c \
+$(GLSL_SRCDIR)/glcpp/glcpp_extras.c
 
 LIBGLCPP_GENERATED_FILES = \
$(GLSL_BUILDDIR)/glcpp/glcpp-lex.c \
diff --git a/src/glsl/glcpp/glcpp-lex.l b/src/glsl/glcpp/glcpp-lex.l
index a029f62..31b246f 100644
--- a/src/glsl/glcpp/glcpp-lex.l
+++ b/src/glsl/glcpp/glcpp-lex.l
@@ -126,15 +126,30 @@ HEXADECIMAL_INTEGER   0[xX][0-9a-fA-F]+[uU]?
return HASH_VERSION;
 }
 
-   /* glcpp doesn't handle #extension, #version, or #pragma directives.
+   /* glcpp doesn't handle #pragma directives.
 * Simply pass them through to the main compiler's lexer/parser. */
-{HASH}(extension|pragma)[^\n]+ {
+{HASH}(pragma)[^\n]+ {
yylval->str = ralloc_strdup (yyextra, yytext);
yylineno++;
yycolumn = 0;
return OTHER;
 }
 
+/* glcpp will handle the #extension directive if
+* and only if parser->directive_ext_list is non-NULL
+* otherwise it will just send that off to the parser */
+{HASH}(extension)[^\n]+ {
+yylval->str = ralloc_strdup (yyextra, yytext);
+   yylineno++;
+   yycolumn = 0;
+   if(parser->directive_ext_list) {
+ return EXTENSION_DIRECTIVE;
+} else {
+ return OTHER;
+   }
+}
+
+
 {HASH}line{HSPACE}+ {
return HASH_LINE;
 }
diff --git a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y
index 7edc274..d1d58c3 100644
--- a/src/glsl/glcpp/glcpp-parse.y
+++ b/src/glsl/glcpp/glcpp-parse.y
@@ -166,6 +166,7 @@ add_builtin_define(glcpp_parser_t *parser, const char 
*name, int value);
 %expect 0
 %token COMMA_FINAL DEFINED ELIF_EXPANDED HASH HASH_DEFINE FUNC_IDENTIFIER 
OBJ_IDENTIFIER HASH_ELIF HASH_ELSE HASH_ENDIF HASH_IF HASH_IFDEF HASH_IFNDEF 
HASH_LINE HASH_UNDEF HASH_VERSION IDENTIFIER IF_EXPANDED INTEGER INTEGER_STRING 
LINE_EXPANDED NEWLINE OTHER PLACEHOLDER SPACE
 %token PASTE
+%token  EXTENSION_DIRECTIVE
 %type  expression INTEGER operator SPACE integer_constant
 %type  IDENTIFIER FUNC_IDENTIFIER OBJ_IDENTIFIER INTEGER_STRING OTHER
 %type  identifier_list
@@ -208,9 +209,34 @@ line:
ralloc_free ($1);
}
 |  expanded_line
+|   extension_directive
 |  HASH non_directive
 ;
 
+extension_directive:
+EXTENSION_DIRECTIVE {
+   int cnt;
+   
+   assert(parser->directive_ext_list);
+   /*
+ the lexer increments yylineno when it encounters
+ #extension. If it did not, then the line used by
+ the glsl parser when then be wrong. We get around
+ the issue by decrementing by number of #extension
+ processed so far.
+*/
+   cnt=parser->directive_ext_list->count;
+   add_extension_from_preprocessor($1, 
+   @1.first_line - cnt, 
+   @1.first_column,
+   @1.last_line - cnt,
+   @1.last_column,
+   @1.source,
+   parser->directive_ext_list); 
+}
+;
+
+
 expanded_line:
IF_EXPANDED expression NEWLINE {
_glcpp_parser_skip_stack_push_if (parser, & @1, $2);
@@ -1148,7 +1174,8 @@ static void add_builtin_define(glcpp_parser_t *parser,
 }
 
 glcpp_parser_t *
-glcpp_parser_create (const struct gl_extensions *extensions, int api)
+glcpp_parser_create (const struct gl_extensions *extensions, int api,
+ struct glcpp_extension_directive_list *ext_list)
 {
glcpp_parser_t *parser;
int language_version;
@@ -1182,6 +1209,7 @@ glcpp_parser_create (const struct gl_

[Mesa-dev] [PATCH 2/2] add MESA_GLSL option to require that #extension directives come before any variable or function declarations, etc

2013-12-03 Thread Kevin Rogovin
Add an additional bit flag, GLSL_EXTENSION_STRICT for 
gl_context#Shader#Flags to require that #extension 
directives must come before variable of function
declarations. The flag is set to on if MESA_GLSL has
the option extension_strict_ordering in it.

---
 src/glsl/glsl_parser_extras.cpp | 6 +++---
 src/mesa/main/mtypes.h  | 8 +++-
 src/mesa/main/shaderapi.c   | 2 ++
 3 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp
index 75640e1..25d16ab 100644
--- a/src/glsl/glsl_parser_extras.cpp
+++ b/src/glsl/glsl_parser_extras.cpp
@@ -1515,11 +1515,11 @@ _mesa_glsl_compile_shader(struct gl_context *ctx, 
struct gl_shader *shader,
   new(shader) _mesa_glsl_parse_state(ctx, shader->Type, shader);
const char *source = shader->Source;
 
-   if(1) {
+   if(ctx->Shader.Flags&GLSL_EXTENSION_STRICT) {
+  state->ext_directive_list=NULL;
+   } else {
   state->ext_directive_list=&extension_directive_list;
   init_glcpp_extension_directive_list(state->ext_directive_list);
-   } else {
-  state->ext_directive_list=NULL;
}
 
state->error = glcpp_preprocess(state, &source, &state->info_log,
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index b4b432f..28cb5f9 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2652,7 +2652,13 @@ struct gl_shader_program
 #define GLSL_USE_PROG 0x80  /**< Log glUseProgram calls */
 #define GLSL_REPORT_ERRORS 0x100  /**< Print compilation errors */
 #define GLSL_DUMP_ON_ERROR 0x200 /**< Dump shaders to stderr on compile error 
*/
-
+/**
+ * In GLSL sources, follow specifications 
+ * with respect to #extension ordering, i.e.
+ * such directives must come before function
+ * declarations, variable declarations, etc.
+ */
+#define GLSL_EXTENSION_STRICT 0x400 
 
 /**
  * Context state for GLSL vertex/fragment shaders.
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index 1d9aac3..dd12f42 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -92,6 +92,8 @@ get_shader_flags(void)
  flags |= GLSL_USE_PROG;
   if (strstr(env, "errors"))
  flags |= GLSL_REPORT_ERRORS;
+  if(strstr(env, "extension_strict_ordering"))
+ flags |= GLSL_EXTENSION_STRICT;
}
 
return flags;
-- 
1.8.1.2

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 1/2] Allow for GLSL shaders to have #extension directive anywhere in source file. (reworked)

2013-12-03 Thread Kevin Rogovin
Allow for GLSL shaders to have #extension directive
anywhere in source file; during preprocessor, #extension
directives are saved to a list rather than being added
to the pre-processed string. That list is played back 
before parsing of pre-processed text takes place.  

---
 src/glsl/Makefile.sources   |   3 +-
 src/glsl/glcpp/glcpp-lex.l  |  20 +++-
 src/glsl/glcpp/glcpp-parse.y|  30 ++-
 src/glsl/glcpp/glcpp.c  |   2 +-
 src/glsl/glcpp/glcpp.h  |  17 +-
 src/glsl/glcpp/glcpp_extras.c   | 111 
 src/glsl/glcpp/glcpp_extras.h   |  97 +++
 src/glsl/glcpp/pp.c |   5 +-
 src/glsl/glsl_parser_extras.cpp |  56 +++-
 src/glsl/glsl_parser_extras.h   |  14 -
 10 files changed, 344 insertions(+), 11 deletions(-)
 create mode 100644 src/glsl/glcpp/glcpp_extras.c
 create mode 100644 src/glsl/glcpp/glcpp_extras.h

diff --git a/src/glsl/Makefile.sources b/src/glsl/Makefile.sources
index 2e81ded..90f57ad 100644
--- a/src/glsl/Makefile.sources
+++ b/src/glsl/Makefile.sources
@@ -7,7 +7,8 @@ GLSL_BUILDDIR = $(top_builddir)/src/glsl
 
 LIBGLCPP_FILES = \
$(GLSL_SRCDIR)/ralloc.c \
-   $(GLSL_SRCDIR)/glcpp/pp.c
+   $(GLSL_SRCDIR)/glcpp/pp.c \
+$(GLSL_SRCDIR)/glcpp/glcpp_extras.c
 
 LIBGLCPP_GENERATED_FILES = \
$(GLSL_BUILDDIR)/glcpp/glcpp-lex.c \
diff --git a/src/glsl/glcpp/glcpp-lex.l b/src/glsl/glcpp/glcpp-lex.l
index a029f62..1998fce 100644
--- a/src/glsl/glcpp/glcpp-lex.l
+++ b/src/glsl/glcpp/glcpp-lex.l
@@ -126,15 +126,31 @@ HEXADECIMAL_INTEGER   0[xX][0-9a-fA-F]+[uU]?
return HASH_VERSION;
 }
 
-   /* glcpp doesn't handle #extension, #version, or #pragma directives.
+   /* glcpp doesn't handle #pragma directives.
 * Simply pass them through to the main compiler's lexer/parser. */
-{HASH}(extension|pragma)[^\n]+ {
+{HASH}(pragma)[^\n]+ {
yylval->str = ralloc_strdup (yyextra, yytext);
yylineno++;
yycolumn = 0;
return OTHER;
 }
 
+/* glcpp will handle the #extension directive if
+* and only if parser->directive_ext_list is non-NULL
+* otherwise it will just send that off to the 
+* main compiler's lexer/parser. */
+{HASH}(extension)[^\n]+ {
+yylval->str = ralloc_strdup (yyextra, yytext);
+   yylineno++;
+   yycolumn = 0;
+   if(parser->directive_ext_list) {
+   return EXTENSION_DIRECTIVE;
+} else {
+   return OTHER;
+   }
+}
+
+
 {HASH}line{HSPACE}+ {
return HASH_LINE;
 }
diff --git a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y
index 7edc274..b5a5f05 100644
--- a/src/glsl/glcpp/glcpp-parse.y
+++ b/src/glsl/glcpp/glcpp-parse.y
@@ -166,6 +166,7 @@ add_builtin_define(glcpp_parser_t *parser, const char 
*name, int value);
 %expect 0
 %token COMMA_FINAL DEFINED ELIF_EXPANDED HASH HASH_DEFINE FUNC_IDENTIFIER 
OBJ_IDENTIFIER HASH_ELIF HASH_ELSE HASH_ENDIF HASH_IF HASH_IFDEF HASH_IFNDEF 
HASH_LINE HASH_UNDEF HASH_VERSION IDENTIFIER IF_EXPANDED INTEGER INTEGER_STRING 
LINE_EXPANDED NEWLINE OTHER PLACEHOLDER SPACE
 %token PASTE
+%token  EXTENSION_DIRECTIVE
 %type  expression INTEGER operator SPACE integer_constant
 %type  IDENTIFIER FUNC_IDENTIFIER OBJ_IDENTIFIER INTEGER_STRING OTHER
 %type  identifier_list
@@ -208,9 +209,33 @@ line:
ralloc_free ($1);
}
 |  expanded_line
+|   extension_directive
 |  HASH non_directive
 ;
 
+extension_directive:
+EXTENSION_DIRECTIVE {
+int cnt;
+   
+assert(parser->directive_ext_list);
+/* the lexer increments yylineno when it encounters
+ * #extension. If it did not, then the line used by
+ * the glsl parser when then be wrong. We get around
+ * the issue by decrementing by number of #extension
+ * processed so far.
+*/
+cnt=parser->directive_ext_list->count;
+add_extension_from_preprocessor($1, 
+@1.first_line - cnt, 
+@1.first_column,
+@1.last_line - cnt,
+@1.last_column,
+@1.source,
+parser->directive_ext_list); 
+}
+;
+
+
 expanded_line:
IF_EXPANDED expression NEWLINE {
_glcpp_parser_skip_stack_push_if (parser, & @1, $2);
@@ -1148,7 +1173,8 @@ static void add_builtin_define(glcpp_parser_t *parser,
 }
 
 glcpp_parser_t *
-glcpp_parser_create (const struct gl_extensions *extensions, int api)
+glcpp_parser_create (const struct gl_extensions *extensions, int api,
+ struct glcpp_extension_directive_list *ext_list)

[Mesa-dev] [PATCH 2/2] add MESA_GLSL option to require that #extension directives come before any variable or function declarations, etc (reworked)

2013-12-03 Thread Kevin Rogovin
Add an additional bit flag, GLSL_EXTENSION_STRICT for 
gl_context#Shader#Flags to require that #extension 
directives must come before variable or function
declarations. The flag is set to on if MESA_GLSL has
the option extension_strict_ordering in it.

---
 src/glsl/glsl_parser_extras.cpp | 7 ---
 src/mesa/main/mtypes.h  | 8 +++-
 src/mesa/main/shaderapi.c   | 2 ++
 3 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp
index 7ac6798..b74cc83 100644
--- a/src/glsl/glsl_parser_extras.cpp
+++ b/src/glsl/glsl_parser_extras.cpp
@@ -1517,11 +1517,12 @@ _mesa_glsl_compile_shader(struct gl_context *ctx, 
struct gl_shader *shader,
   new(shader) _mesa_glsl_parse_state(ctx, shader->Type, shader);
const char *source = shader->Source;
 
-   if (1) {
+
+   if (ctx->Shader.Flags&GLSL_EXTENSION_STRICT) {
+  state->ext_directive_list = NULL;
+   } else {
   state->ext_directive_list = &extension_directive_list;
   init_glcpp_extension_directive_list(state->ext_directive_list);
-   } else {
-  state->ext_directive_list = NULL;
}
 
state->error = glcpp_preprocess(state, &source, &state->info_log,
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index b4b432f..28cb5f9 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2652,7 +2652,13 @@ struct gl_shader_program
 #define GLSL_USE_PROG 0x80  /**< Log glUseProgram calls */
 #define GLSL_REPORT_ERRORS 0x100  /**< Print compilation errors */
 #define GLSL_DUMP_ON_ERROR 0x200 /**< Dump shaders to stderr on compile error 
*/
-
+/**
+ * In GLSL sources, follow specifications 
+ * with respect to #extension ordering, i.e.
+ * such directives must come before function
+ * declarations, variable declarations, etc.
+ */
+#define GLSL_EXTENSION_STRICT 0x400 
 
 /**
  * Context state for GLSL vertex/fragment shaders.
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index 1d9aac3..c9a86e9 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -92,6 +92,8 @@ get_shader_flags(void)
  flags |= GLSL_USE_PROG;
   if (strstr(env, "errors"))
  flags |= GLSL_REPORT_ERRORS;
+  if (strstr(env, "extension_strict_ordering"))
+ flags |= GLSL_EXTENSION_STRICT;
}
 
return flags;
-- 
1.8.1.2

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] Fix line number on no matching function call

2013-12-06 Thread Kevin Rogovin
This (very tiny) patch fixes the bug (#72264) where when 
no matching function call was found the error message
gave the line and column number as 0.

---
 src/glsl/ast_function.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/glsl/ast_function.cpp b/src/glsl/ast_function.cpp
index 6423759..9dc5427 100644
--- a/src/glsl/ast_function.cpp
+++ b/src/glsl/ast_function.cpp
@@ -1656,7 +1656,7 @@ ast_function_expression::hir(exec_list *instructions,
} else {
   const ast_expression *id = subexpressions[0];
   const char *func_name = id->primary_expression.identifier;
-  YYLTYPE loc = id->get_location();
+  YYLTYPE loc = get_location();
   exec_list actual_parameters;
 
   process_parameters(instructions, &actual_parameters, &this->expressions,
-- 
1.8.1.2

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] Use line number information from entire function expression

2013-12-09 Thread Kevin Rogovin
This patch changes the error reporting behavior for incorrect
function invocation (triggered by match_function_by_name() 
unable to find a matching function call) from using the line
number information associated to the function name term
to using the line number information of the entire function
expression. Fixes bug #72264.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=72264

---
 src/glsl/ast_function.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/glsl/ast_function.cpp b/src/glsl/ast_function.cpp
index 6423759..9dc5427 100644
--- a/src/glsl/ast_function.cpp
+++ b/src/glsl/ast_function.cpp
@@ -1656,7 +1656,7 @@ ast_function_expression::hir(exec_list *instructions,
} else {
   const ast_expression *id = subexpressions[0];
   const char *func_name = id->primary_expression.identifier;
-  YYLTYPE loc = id->get_location();
+  YYLTYPE loc = get_location();
   exec_list actual_parameters;
 
   process_parameters(instructions, &actual_parameters, &this->expressions,
-- 
1.8.1.2

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] Report that no function found if signature lookup is empty

2013-12-09 Thread Kevin Rogovin
Enhancement: if no function signature is found for a function
name, report that the function is not found instead of printing
an empty list of candidates.

---
 src/glsl/ast_function.cpp | 27 +--
 1 file changed, 17 insertions(+), 10 deletions(-)

diff --git a/src/glsl/ast_function.cpp b/src/glsl/ast_function.cpp
index 9dc5427..ec4339c 100644
--- a/src/glsl/ast_function.cpp
+++ b/src/glsl/ast_function.cpp
@@ -450,17 +450,24 @@ no_matching_function_error(const char *name,
   exec_list *actual_parameters,
   _mesa_glsl_parse_state *state)
 {
-   char *str = prototype_string(NULL, name, actual_parameters);
-   _mesa_glsl_error(loc, state,
-"no matching function for call to `%s'; candidates are:",
-str);
-   ralloc_free(str);
+   gl_shader *sh = _mesa_glsl_get_builtin_function_shader();
 
-   print_function_prototypes(state, loc, state->symbols->get_function(name));
-
-   if (state->uses_builtin_functions) {
-  gl_shader *sh = _mesa_glsl_get_builtin_function_shader();
-  print_function_prototypes(state, loc, sh->symbols->get_function(name));
+   if(NULL == state->symbols->get_function(name)
+  && (!state->uses_builtin_functions 
+  || NULL == sh->symbols->get_function(name)) ) {
+  _mesa_glsl_error(loc, state, "no function with name '%s'", name);
+   } else {
+  char *str = prototype_string(NULL, name, actual_parameters);
+  _mesa_glsl_error(loc, state,
+   "no matching function for call to `%s'; candidates 
are:",
+   str);
+  ralloc_free(str);
+  
+  print_function_prototypes(state, loc, 
state->symbols->get_function(name));
+  
+  if (state->uses_builtin_functions) { 
+ print_function_prototypes(state, loc, 
sh->symbols->get_function(name));
+  }
}
 }
 
-- 
1.8.1.2

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] Correct test for depth parameter for checking if dimension is legal

2014-01-27 Thread Kevin Rogovin
Fixes the tests for the depth parameter for TexImage3D calls when the
target type is GL_TEXTURE_2D_ARRAY or GL_TEXTURE_CUBE_MAP_ARRAY
so that a depth value of 0 is accepted. Previously, the check
incorrectly required the depth argument to be atleast 1. 

---
 src/mesa/main/teximage.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index 9c3f1e8..8e2f057 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -1481,7 +1481,7 @@ _mesa_legal_texture_dimensions(struct gl_context *ctx, 
GLenum target,
  return GL_FALSE;
   if (height < 2 * border || height > 2 * border + maxSize)
  return GL_FALSE;
-  if (depth < 1 || depth > ctx->Const.MaxArrayTextureLayers)
+  if (depth < 0 || depth > ctx->Const.MaxArrayTextureLayers)
  return GL_FALSE;
   if (!ctx->Extensions.ARB_texture_non_power_of_two) {
  if (width > 0 && !_mesa_is_pow_two(width - 2 * border))
@@ -1498,7 +1498,7 @@ _mesa_legal_texture_dimensions(struct gl_context *ctx, 
GLenum target,
  return GL_FALSE;
   if (height < 2 * border || height > 2 * border + maxSize)
  return GL_FALSE;
-  if (depth < 1 || depth > ctx->Const.MaxArrayTextureLayers || depth % 6)
+  if (depth < 0 || depth > ctx->Const.MaxArrayTextureLayers || depth % 6)
  return GL_FALSE;
   if (width != height)
  return GL_FALSE;
-- 
1.8.1.2

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] GL_OES_texture_float and GL_OES_texture_half_float support

2014-05-06 Thread Kevin Rogovin
Add support for GLES2 extentions for floating point and half
floating point textures (GL_OES_texture_float, GL_OES_texture_half_float,
GL_OES_texture_float_linear and GL_OES_texture_half_float_linear).

---
 src/mesa/main/extensions.c | 12 +
 src/mesa/main/glformats.c  | 27 
 src/mesa/main/pack.c   | 17 +
 src/mesa/main/teximage.c   | 61 ++
 4 files changed, 117 insertions(+)

diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c
index c2ff7e3..58a5a51 100644
--- a/src/mesa/main/extensions.c
+++ b/src/mesa/main/extensions.c
@@ -360,6 +360,18 @@ static const struct extension extension_table[] = {
{ "GL_SGIS_texture_lod",o(dummy_true),  
GLL,1997 },
{ "GL_SUN_multi_draw_arrays",   o(dummy_true),  
GLL,1999 },
 
+   /*
+ TODO:
+  - rather than have an all or nothing approach for floating point 
textures,
+allow for driver to specify what parts of floating point texture 
funtionality
+is supported: float/half-float and filtering for each. 
+*/
+   { "GL_OES_texture_float",   o(ARB_texture_float),   
ES2|ES3,2005 },
+   { "GL_OES_texture_half_float",  o(ARB_texture_float),   
ES2|ES3,2005 },
+   { "GL_OES_texture_float_linear",o(ARB_texture_float),   
ES2|ES3,2005 },
+   { "GL_OES_texture_half_float_linear",   o(ARB_texture_float),   
ES2|ES3,2005 },
+   
+
{ 0, 0, 0, 0 },
 };
 
diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c
index 9bb341c..be728f4 100644
--- a/src/mesa/main/glformats.c
+++ b/src/mesa/main/glformats.c
@@ -93,6 +93,7 @@ _mesa_sizeof_type(GLenum type)
case GL_DOUBLE:
   return sizeof(GLdouble);
case GL_HALF_FLOAT_ARB:
+   case GL_HALF_FLOAT_OES:
   return sizeof(GLhalfARB);
case GL_FIXED:
   return sizeof(GLfixed);
@@ -125,6 +126,7 @@ _mesa_sizeof_packed_type(GLenum type)
case GL_INT:
   return sizeof(GLint);
case GL_HALF_FLOAT_ARB:
+   case GL_HALF_FLOAT_OES:
   return sizeof(GLhalfARB);
case GL_FLOAT:
   return sizeof(GLfloat);
@@ -243,6 +245,7 @@ _mesa_bytes_per_pixel(GLenum format, GLenum type)
case GL_FLOAT:
   return comps * sizeof(GLfloat);
case GL_HALF_FLOAT_ARB:
+   case GL_HALF_FLOAT_OES:
   return comps * sizeof(GLhalfARB);
case GL_UNSIGNED_BYTE_3_3_2:
case GL_UNSIGNED_BYTE_2_3_3_REV:
@@ -1365,6 +1368,11 @@ _mesa_error_check_format_and_type(const struct 
gl_context *ctx,
 case GL_FLOAT:
 case GL_HALF_FLOAT:
return GL_NO_ERROR;
+case GL_HALF_FLOAT_OES:
+   return (format==GL_LUMINANCE || 
+   format==GL_LUMINANCE_ALPHA || 
+   format==GL_ALPHA) 
+  ? GL_NO_ERROR: GL_INVALID_ENUM;
 default:
return GL_INVALID_ENUM;
  }
@@ -1401,6 +1409,9 @@ _mesa_error_check_format_and_type(const struct gl_context 
*ctx,
 case GL_UNSIGNED_SHORT_5_6_5_REV:
 case GL_HALF_FLOAT:
return GL_NO_ERROR;
+case GL_HALF_FLOAT_OES:
+   return (format==GL_RGB) 
+  ? GL_NO_ERROR: GL_INVALID_ENUM;
 case GL_UNSIGNED_INT_2_10_10_10_REV:
/* OK by GL_EXT_texture_type_2_10_10_10_REV */
return (ctx->API == API_OPENGLES2)
@@ -1454,6 +1465,9 @@ _mesa_error_check_format_and_type(const struct gl_context 
*ctx,
 case GL_UNSIGNED_INT_2_10_10_10_REV:
 case GL_HALF_FLOAT:
return GL_NO_ERROR;
+case GL_HALF_FLOAT_OES:
+   return (format==GL_RGBA) 
+  ? GL_NO_ERROR: GL_INVALID_ENUM;
 default:
return GL_INVALID_ENUM;
  }
@@ -1666,6 +1680,7 @@ _mesa_es_error_check_format_and_type(GLenum format, 
GLenum type,
return type_valid ? GL_NO_ERROR : GL_INVALID_OPERATION;
 }
 
+ 
 
 /**
  * Do error checking of format/type combinations for OpenGL ES 3
@@ -1676,6 +1691,18 @@ GLenum
 _mesa_es3_error_check_format_and_type(GLenum format, GLenum type,
   GLenum internalFormat)
 {
+   /*
+ special case checking for support the GLES2 extension
+ GL_OES_texture_float and GL_OES_texture_half_float
+*/
+   if(format==internalFormat
+  && (type==GL_HALF_FLOAT_OES || type==GL_FLOAT) 
+  && (format==GL_RGBA || format==GL_RGB ||
+  format==GL_LUMINANCE || format==GL_ALPHA ||
+  format==GL_LUMINANCE_ALPHA) ) {
+  return GL_NO_ERROR;
+   }
+   
switch (format) {
case GL_RGBA:
   switch (type) {
diff --git a/src/mesa/main/pack.c b/src/mesa/main/pack.c
index 1df6568.

[Mesa-dev] [PATCH] mesa: Expose GL_OES_texture_float and GL_OES_texture_half_float.

2014-05-07 Thread Kevin Rogovin
 Add support for GLES2 extensions for floating point and half
 floating point textures (GL_OES_texture_float, GL_OES_texture_half_float,
 GL_OES_texture_float_linear and GL_OES_texture_half_float_linear).

---
 src/mesa/main/extensions.c | 12 +-
 src/mesa/main/glformats.c  | 25 
 src/mesa/main/pack.c   | 17 +
 src/mesa/main/teximage.c   | 59 ++
 4 files changed, 112 insertions(+), 1 deletion(-)

diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c
index c2ff7e3..e39f65e 100644
--- a/src/mesa/main/extensions.c
+++ b/src/mesa/main/extensions.c
@@ -301,7 +301,17 @@ static const struct extension extension_table[] = {
{ "GL_OES_texture_mirrored_repeat", o(dummy_true),  
 ES1,   2005 },
{ "GL_OES_texture_npot",
o(ARB_texture_non_power_of_two), ES1 | ES2, 2005 },
{ "GL_OES_vertex_array_object", o(dummy_true),  
 ES1 | ES2, 2010 },
-
+   /*
+* TODO:
+*  - rather than have an all or nothing approach for floating point 
textures,
+*allow for driver to specify what parts of floating point texture 
functionality
+*is supported: float/half-float and filtering for each.
+*/
+   { "GL_OES_texture_float",   o(ARB_texture_float),   
ES2,2005 },
+   { "GL_OES_texture_half_float",  o(ARB_texture_float),   
ES2,2005 },
+   { "GL_OES_texture_float_linear",o(ARB_texture_float),   
ES2,2005 },
+   { "GL_OES_texture_half_float_linear",   o(ARB_texture_float),   
ES2,2005 },
+ 
/* KHR extensions */
{ "GL_KHR_debug",   o(dummy_true),  
GL, 2012 },
 
diff --git a/src/mesa/main/glformats.c b/src/mesa/main/glformats.c
index 9bb341c..093fd59 100644
--- a/src/mesa/main/glformats.c
+++ b/src/mesa/main/glformats.c
@@ -93,6 +93,7 @@ _mesa_sizeof_type(GLenum type)
case GL_DOUBLE:
   return sizeof(GLdouble);
case GL_HALF_FLOAT_ARB:
+   case GL_HALF_FLOAT_OES:
   return sizeof(GLhalfARB);
case GL_FIXED:
   return sizeof(GLfixed);
@@ -125,6 +126,7 @@ _mesa_sizeof_packed_type(GLenum type)
case GL_INT:
   return sizeof(GLint);
case GL_HALF_FLOAT_ARB:
+   case GL_HALF_FLOAT_OES:
   return sizeof(GLhalfARB);
case GL_FLOAT:
   return sizeof(GLfloat);
@@ -243,6 +245,7 @@ _mesa_bytes_per_pixel(GLenum format, GLenum type)
case GL_FLOAT:
   return comps * sizeof(GLfloat);
case GL_HALF_FLOAT_ARB:
+   case GL_HALF_FLOAT_OES:
   return comps * sizeof(GLhalfARB);
case GL_UNSIGNED_BYTE_3_3_2:
case GL_UNSIGNED_BYTE_2_3_3_REV:
@@ -1365,6 +1368,11 @@ _mesa_error_check_format_and_type(const struct 
gl_context *ctx,
 case GL_FLOAT:
 case GL_HALF_FLOAT:
return GL_NO_ERROR;
+case GL_HALF_FLOAT_OES:
+   return (format == GL_LUMINANCE || 
+   format == GL_LUMINANCE_ALPHA || 
+   format == GL_ALPHA) 
+  ? GL_NO_ERROR: GL_INVALID_ENUM;
 default:
return GL_INVALID_ENUM;
  }
@@ -1401,6 +1409,9 @@ _mesa_error_check_format_and_type(const struct gl_context 
*ctx,
 case GL_UNSIGNED_SHORT_5_6_5_REV:
 case GL_HALF_FLOAT:
return GL_NO_ERROR;
+case GL_HALF_FLOAT_OES:
+   return (format == GL_RGB) 
+  ? GL_NO_ERROR: GL_INVALID_ENUM;
 case GL_UNSIGNED_INT_2_10_10_10_REV:
/* OK by GL_EXT_texture_type_2_10_10_10_REV */
return (ctx->API == API_OPENGLES2)
@@ -1454,6 +1465,9 @@ _mesa_error_check_format_and_type(const struct gl_context 
*ctx,
 case GL_UNSIGNED_INT_2_10_10_10_REV:
 case GL_HALF_FLOAT:
return GL_NO_ERROR;
+case GL_HALF_FLOAT_OES:
+   return (format == GL_RGBA) 
+  ? GL_NO_ERROR: GL_INVALID_ENUM;
 default:
return GL_INVALID_ENUM;
  }
@@ -1676,6 +1690,17 @@ GLenum
 _mesa_es3_error_check_format_and_type(GLenum format, GLenum type,
   GLenum internalFormat)
 {
+   /* special case checking for support the GLES2 extension
+* GL_OES_texture_float and GL_OES_texture_half_float
+*/
+   if(format == internalFormat &&
+  (type == GL_HALF_FLOAT_OES || type == GL_FLOAT) && 
+  (format == GL_RGBA || format == GL_RGB ||
+  format == GL_LUMINANCE || format == GL_ALPHA ||
+  format == GL_LUMINANCE_ALPHA) ) {
+  return GL_NO_ERROR;
+   }
+   
switch (format) {
case GL_RGBA:
   switch (type) {
diff --git a/src/mesa

[Mesa-dev] [PATCH] define GL_OES_standard_derivatives if extension is supported

2014-05-19 Thread kevin . rogovin
From: Kevin Rogovin 

Define the macro GL_OES_standard_derivatives as 1 if the extension
GL_OES_standard_derivatives is supported.

---
 src/glsl/glcpp/glcpp-parse.y | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y
index 9887583..83f6f46 100644
--- a/src/glsl/glcpp/glcpp-parse.y
+++ b/src/glsl/glcpp/glcpp-parse.y
@@ -2067,6 +2067,8 @@ _glcpp_parser_handle_version_declaration(glcpp_parser_t 
*parser, intmax_t versio
   if (extensions != NULL) {
  if (extensions->OES_EGL_image_external)
 add_builtin_define(parser, "GL_OES_EGL_image_external", 1);
+  if (extensions->OES_standard_derivatives) 
+ add_builtin_define(parser, "GL_OES_standard_derivatives", 1);
   }
} else {
   add_builtin_define(parser, "GL_ARB_draw_buffers", 1);
-- 
1.8.1.2

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] Allow sampler arrays to have precision qualifier

2014-02-03 Thread Kevin Rogovin
Fixes a minor oversight where a precision qualifier was not
allowed for an array of samplers.

---
 src/glsl/ast_to_hir.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
index 1bfb4e5..08fd0d3 100644
--- a/src/glsl/ast_to_hir.cpp
+++ b/src/glsl/ast_to_hir.cpp
@@ -3397,7 +3397,8 @@ ast_declarator_list::hir(exec_list *instructions,
   && !var->type->is_sampler()
   && !(var->type->is_array()
&& (var->type->fields.array->is_float()
-   || var->type->fields.array->is_integer( {
+   || var->type->fields.array->is_integer()
+   || var->type->fields.array->is_sampler( {
 
  _mesa_glsl_error(&loc, state,
   "precision qualifiers apply only to floating point"
-- 
1.8.1.2

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] centroid affects interpolation

2014-02-04 Thread Kevin Rogovin
Place centroid keyword as an interpolation qualifier.
Previously was a storage qualifier. Fixes front end
to accept input of the form "centroid in type variable"

---
 src/glsl/glsl_parser.yy | 13 ++---
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy
index 928c57e..265fc57 100644
--- a/src/glsl/glsl_parser.yy
+++ b/src/glsl/glsl_parser.yy
@@ -1353,6 +1353,11 @@ interpolation_qualifier:
   memset(& $$, 0, sizeof($$));
   $$.flags.q.flat = 1;
}
+   | CENTROID
+   {
+  memset(& $$, 0, sizeof($$));
+  $$.flags.q.centroid = 1;
+   }
| NOPERSPECTIVE
{
   memset(& $$, 0, sizeof($$));
@@ -1501,13 +1506,7 @@ type_qualifier:
}
;
 
-auxiliary_storage_qualifier:
-   CENTROID
-   {
-  memset(& $$, 0, sizeof($$));
-  $$.flags.q.centroid = 1;
-   }
-   | SAMPLE
+auxiliary_storage_qualifier:SAMPLE
{
   memset(& $$, 0, sizeof($$));
   $$.flags.q.sample = 1;
-- 
1.8.1.2

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] meta_blitframebuffer integer format corrections

2014-02-10 Thread Kevin Rogovin
Corrects the format for the temp texture used in
for the case where source framebuffer is an integer
texture when blitframebuffer_texture() cannot be used.
Note: Does NOT correct the underling blits, rather only
corrects the format of the temporary texture to be
an integer format.

---
 src/mesa/drivers/common/meta.c | 42 +++---
 1 file changed, 39 insertions(+), 3 deletions(-)

diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index f12bcaa..b446053 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -356,6 +356,34 @@ static void meta_glsl_clear_cleanup(struct clear_state 
*clear);
 static void meta_glsl_generate_mipmap_cleanup(struct gen_mipmap_state *mipmap);
 static void meta_decompress_cleanup(struct decompress_state *decompress);
 static void meta_drawpix_cleanup(struct drawpix_state *drawpix);
+static GLenum meta_integer_suffixed_format(GLenum base_format);
+
+/**
+ * returns the base_format value suffixed with _INTEGER
+ */
+static GLenum 
+meta_integer_suffixed_format(GLenum base_format)
+{
+   switch(base_format) {
+   case GL_RED:
+  return GL_RED_INTEGER;
+   case GL_RG:
+  return GL_RG_INTEGER;
+   case GL_RGB:
+  return GL_RGB_INTEGER;
+   case GL_RGBA:
+  return GL_RGBA_INTEGER;
+   case GL_ALPHA:
+  return GL_ALPHA_INTEGER_EXT;
+   case GL_LUMINANCE:
+  return GL_LUMINANCE_INTEGER_EXT;
+   case GL_LUMINANCE_ALPHA:
+  return GL_LUMINANCE_ALPHA_INTEGER_EXT;
+   default:
+  return base_format;
+   }
+}
+
 
 static GLuint
 compile_shader_with_debug(struct gl_context *ctx, GLenum target, const 
GLcharARB *source)
@@ -1902,15 +1930,23 @@ _mesa_meta_BlitFramebuffer(struct gl_context *ctx,
   const struct gl_renderbuffer *colorReadRb = readFb->_ColorReadBuffer;
   const GLenum rb_base_format =
  _mesa_base_tex_format(ctx, colorReadRb->InternalFormat);
+  const GLenum rb_datatype = 
+ _mesa_get_format_datatype(colorReadRb->Format); 
+  const GLenum rb_format = (rb_datatype==GL_INT 
+|| rb_datatype==GL_UNSIGNED_INT) ?
+ meta_integer_suffixed_format(rb_base_format):
+ rb_base_format;
+ 
+  
 
-  /* Using  the exact source rectangle to create the texture does incorrect
+  /* Using the exact source rectangle to create the texture does incorrect
* linear filtering along the edges. So, allocate the texture extended 
along
* edges by one pixel in x, y directions.
*/
-  newTex = alloc_texture(tex, srcW + 2, srcH + 2, rb_base_format);
+  newTex = alloc_texture(tex, srcW + 2, srcH + 2, 
colorReadRb->InternalFormat);
   setup_copypix_texture(ctx, tex, newTex,
 srcX - 1, srcY - 1, srcW + 2, srcH + 2,
-rb_base_format, filter);
+rb_format, filter);
   /* texcoords (after texture allocation!) */
   {
  verts[0].s = 1.0F;
-- 
1.8.1.2

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] Channels alive in fast clear

2014-03-24 Thread Kevin Rogovin
When deciding if a clear color is suitable for fast clear,
take into account if a color channel is active in the
buffer format.

---
 src/mesa/drivers/dri/i965/brw_blorp_clear.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp 
b/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp
index fd18b45..d16da97 100644
--- a/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp
+++ b/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp
@@ -153,7 +153,8 @@ is_color_fast_clear_compatible(struct brw_context *brw,
   return false;
 
for (int i = 0; i < 4; i++) {
-  if (color->f[i] != 0.0 && color->f[i] != 1.0) {
+  if (color->f[i] != 0.0 && color->f[i] != 1.0 &&
+  _mesa_format_has_color_component(format, i)) {
  perf_debug("Clear color unsupported by fast color clear.  "
 "Falling back to slow clear.\n");
  return false;
-- 
1.8.1.2

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 0/2] Extra check for GenQueriesARB and DeleteQueriesARB

2016-04-05 Thread kevin . rogovin
From: Kevin Rogovin 

This patch sequence enforces an extra check
for GenQueriesARB and DeleteQueriesARB that
is not preset in GenQueries and DeleteQueries.

Kevin Rogovin (2):
  Differentiate between GenQueries and GenQueriesARB
  Differentiate between DeleteQueries and DeleteQueriesARB

 src/mapi/glapi/gen/gl_API.xml |  4 ++--
 src/mesa/main/context.c   |  1 +
 src/mesa/main/queryobj.c  | 51 ++-
 src/mesa/main/queryobj.h  |  4 
 4 files changed, 52 insertions(+), 8 deletions(-)

-- 
1.9.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 1/2] Differentiate between GenQueries and GenQueriesARB

2016-04-05 Thread kevin . rogovin
From: Kevin Rogovin 

The extension, GL_ARB_occlusion_queries mandates that an
INVALID_OPERATION should be thrown if GenQueriesARB is
called while a query is active. In contrast, the GL spec
has no such requirement for GenQueries. This patch unaliases
the two functions and has that the ARB variant performs
that extra check.

Signed-off-by: Kevin Rogovin 
---
 src/mapi/glapi/gen/gl_API.xml |  2 +-
 src/mesa/main/queryobj.c  | 20 +++-
 src/mesa/main/queryobj.h  |  2 ++
 3 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/src/mapi/glapi/gen/gl_API.xml b/src/mapi/glapi/gen/gl_API.xml
index cdd680c..5918e63 100644
--- a/src/mapi/glapi/gen/gl_API.xml
+++ b/src/mapi/glapi/gen/gl_API.xml
@@ -7564,7 +7564,7 @@
 
 
 
-
+
 
 
 
diff --git a/src/mesa/main/queryobj.c b/src/mesa/main/queryobj.c
index 7a70b59..43f1b0c 100644
--- a/src/mesa/main/queryobj.c
+++ b/src/mesa/main/queryobj.c
@@ -236,7 +236,8 @@ get_query_binding_point(struct gl_context *ctx, GLenum 
target, GLuint index)
 
 /**
  * Create $n query objects and store them in *ids. Make them of type $target
- * if dsa is set. Called from _mesa_GenQueries() and _mesa_CreateQueries().
+ * if dsa is set. Called from _mesa_GenQueries(), _mesa_GenQueriesARB()
+ * and _mesa_CreateQueries().
  */
 static void
 create_queries(struct gl_context *ctx, GLenum target, GLsizei n, GLuint *ids,
@@ -281,6 +282,23 @@ _mesa_GenQueries(GLsizei n, GLuint *ids)
 }
 
 void GLAPIENTRY
+_mesa_GenQueriesARB(GLsizei n, GLuint *ids)
+{
+   GET_CURRENT_CONTEXT(ctx);
+   /* From GL_ARB_occlusion_query:
+   "The error INVALID_OPERATION is generated if GenQueriesARB or
+DeleteQueriesARB is called when a query of any target is active."
+  That extension only support the target SAMPLES_PASSED_ARB, so we
+  only check for CurrentOcclusionObject
+   */
+   if(ctx->Query.CurrentOcclusionObject != NULL) {
+  _mesa_error(ctx, GL_INVALID_OPERATION, "glGenQueriesARB\n");
+  return;
+   }
+   create_queries(ctx, 0, n, ids, false);
+}
+
+void GLAPIENTRY
 _mesa_CreateQueries(GLenum target, GLsizei n, GLuint *ids)
 {
GET_CURRENT_CONTEXT(ctx);
diff --git a/src/mesa/main/queryobj.h b/src/mesa/main/queryobj.h
index d1036fc..245d104 100644
--- a/src/mesa/main/queryobj.h
+++ b/src/mesa/main/queryobj.h
@@ -51,6 +51,8 @@ _mesa_free_queryobj_data(struct gl_context *ctx);
 void GLAPIENTRY
 _mesa_GenQueries(GLsizei n, GLuint *ids);
 void GLAPIENTRY
+_mesa_GenQueriesARB(GLsizei n, GLuint *ids);
+void GLAPIENTRY
 _mesa_CreateQueries(GLenum target, GLsizei n, GLuint *ids);
 void GLAPIENTRY
 _mesa_DeleteQueries(GLsizei n, const GLuint *ids);
-- 
1.9.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 2/2] Differentiate between DeleteQueries and DeleteQueriesARB

2016-04-05 Thread kevin . rogovin
From: Kevin Rogovin 

The extension, GL_ARB_occlusion_queries mandates that an
INVALID_OPERATION should be thrown if DeleteQueriesARB is
called while a query is active. In contrast, the GL spec
has no such requirement for DeleteQueries. This patch
unaliases the two functions and has that the ARB variant
performs that extra check.

Signed-off-by: Kevin Rogovin 
---
 src/mapi/glapi/gen/gl_API.xml |  2 +-
 src/mesa/main/context.c   |  1 +
 src/mesa/main/queryobj.c  | 31 ++-
 src/mesa/main/queryobj.h  |  2 ++
 4 files changed, 30 insertions(+), 6 deletions(-)

diff --git a/src/mapi/glapi/gen/gl_API.xml b/src/mapi/glapi/gen/gl_API.xml
index 5918e63..452584c 100644
--- a/src/mapi/glapi/gen/gl_API.xml
+++ b/src/mapi/glapi/gen/gl_API.xml
@@ -7569,7 +7569,7 @@
 
 
 
-
+
 
 
 
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index dbba136..1b250c0 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -1090,6 +1090,7 @@ create_beginend_table(const struct gl_context *ctx)
COPY_DISPATCH(IsTexture);
COPY_DISPATCH(IsTransformFeedback);
COPY_DISPATCH(DeleteQueries);
+   COPY_DISPATCH(DeleteQueriesARB);
COPY_DISPATCH(AreTexturesResident);
COPY_DISPATCH(FenceSync);
COPY_DISPATCH(ClientWaitSync);
diff --git a/src/mesa/main/queryobj.c b/src/mesa/main/queryobj.c
index 43f1b0c..d8575c2 100644
--- a/src/mesa/main/queryobj.c
+++ b/src/mesa/main/queryobj.c
@@ -321,19 +321,29 @@ _mesa_CreateQueries(GLenum target, GLsizei n, GLuint *ids)
create_queries(ctx, target, n, ids, true);
 }
 
-
-void GLAPIENTRY
-_mesa_DeleteQueries(GLsizei n, const GLuint *ids)
+static void
+delete_queries(GLsizei n, const GLuint *ids, const char *func, bool is_arb)
 {
GLint i;
GET_CURRENT_CONTEXT(ctx);
FLUSH_VERTICES(ctx, 0);
 
if (MESA_VERBOSE & VERBOSE_API)
-  _mesa_debug(ctx, "glDeleteQueries(%d)\n", n);
+  _mesa_debug(ctx, "%s(%d)\n", func, n);
 
if (n < 0) {
-  _mesa_error(ctx, GL_INVALID_VALUE, "glDeleteQueriesARB(n < 0)");
+  _mesa_error(ctx, GL_INVALID_VALUE, "%s(n < 0)", func);
+  return;
+   }
+
+   /* From GL_ARB_occlusion_query:
+  "The error INVALID_OPERATION is generated if GenQueriesARB or
+   DeleteQueriesARB is called when a query of any target is active."
+  That extension only support the target SAMPLES_PASSED_ARB, so we
+  only check for CurrentOcclusionObject
+*/
+   if(is_arb && ctx->Query.CurrentOcclusionObject != NULL) {
+  _mesa_error(ctx, GL_INVALID_OPERATION, "%s\n", func);
   return;
}
 
@@ -358,6 +368,17 @@ _mesa_DeleteQueries(GLsizei n, const GLuint *ids)
}
 }
 
+void GLAPIENTRY
+_mesa_DeleteQueries(GLsizei n, const GLuint *ids)
+{
+   delete_queries(n, ids, "glDeleteQueries", false);
+}
+
+void GLAPIENTRY
+_mesa_DeleteQueriesARB(GLsizei n, const GLuint *ids)
+{
+   delete_queries(n, ids, "glDeleteQueriesARB", true);
+}
 
 GLboolean GLAPIENTRY
 _mesa_IsQuery(GLuint id)
diff --git a/src/mesa/main/queryobj.h b/src/mesa/main/queryobj.h
index 245d104..524767e 100644
--- a/src/mesa/main/queryobj.h
+++ b/src/mesa/main/queryobj.h
@@ -56,6 +56,8 @@ void GLAPIENTRY
 _mesa_CreateQueries(GLenum target, GLsizei n, GLuint *ids);
 void GLAPIENTRY
 _mesa_DeleteQueries(GLsizei n, const GLuint *ids);
+void GLAPIENTRY
+_mesa_DeleteQueriesARB(GLsizei n, const GLuint *ids);
 GLboolean GLAPIENTRY
 _mesa_IsQuery(GLuint id);
 void GLAPIENTRY
-- 
1.9.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 5/9] mesa: add helper convenience functions for computing box intersected against scissors of gl_framebuffer

2015-04-29 Thread kevin . rogovin
From: Kevin Rogovin 

Add helper convenience function that intersects the scissor values
against a passed bounding box. In addition, to avoid replicated code,
make the function _mesa_scissor_bounding_box() use this new function.

---
 src/mesa/main/framebuffer.c | 63 +++--
 src/mesa/main/framebuffer.h |  4 +++
 2 files changed, 47 insertions(+), 20 deletions(-)

diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c
index 4e4d896..56c1225 100644
--- a/src/mesa/main/framebuffer.c
+++ b/src/mesa/main/framebuffer.c
@@ -357,42 +357,38 @@ update_framebuffer_size(struct gl_context *ctx, struct 
gl_framebuffer *fb)
 }
 
 
+
 /**
- * Calculate the inclusive bounding box for the scissor of a specific viewport
+ * Given a bounding box, intersect the bounding box with the scissor of
+ * a specified vieport.
  *
  * \param ctx GL context.
- * \param buffer  Framebuffer to be checked against
  * \param idx Index of the desired viewport
  * \param bboxBounding box for the scissored viewport.  Stored as xmin,
  *xmax, ymin, ymax.
- *
- * \warning This function assumes that the framebuffer dimensions are up to
- * date (e.g., update_framebuffer_size has been recently called on \c buffer).
- *
- * \sa _mesa_clip_to_region
  */
-void
-_mesa_scissor_bounding_box(const struct gl_context *ctx,
-   const struct gl_framebuffer *buffer,
-   unsigned idx, int *bbox)
+extern void
+_mesa_intersect_scissor_bounding_box(const struct gl_context *ctx,
+ unsigned idx, int *bbox)
 {
-   bbox[0] = 0;
-   bbox[2] = 0;
-   bbox[1] = buffer->Width;
-   bbox[3] = buffer->Height;
-
if (ctx->Scissor.EnableFlags & (1u << idx)) {
+  int xmax, ymax;
+
+  xmax = ctx->Scissor.ScissorArray[idx].X
++ ctx->Scissor.ScissorArray[idx].Width;
+  ymax = ctx->Scissor.ScissorArray[idx].Y
++ ctx->Scissor.ScissorArray[idx].Height;
   if (ctx->Scissor.ScissorArray[idx].X > bbox[0]) {
  bbox[0] = ctx->Scissor.ScissorArray[idx].X;
   }
   if (ctx->Scissor.ScissorArray[idx].Y > bbox[2]) {
  bbox[2] = ctx->Scissor.ScissorArray[idx].Y;
   }
-  if (ctx->Scissor.ScissorArray[idx].X + 
ctx->Scissor.ScissorArray[idx].Width < bbox[1]) {
- bbox[1] = ctx->Scissor.ScissorArray[idx].X + 
ctx->Scissor.ScissorArray[idx].Width;
+  if (xmax < bbox[1]) {
+ bbox[1] = xmax;
   }
-  if (ctx->Scissor.ScissorArray[idx].Y + 
ctx->Scissor.ScissorArray[idx].Height < bbox[3]) {
- bbox[3] = ctx->Scissor.ScissorArray[idx].Y + 
ctx->Scissor.ScissorArray[idx].Height;
+  if (ymax < bbox[3]) {
+bbox[3] = ymax;
   }
   /* finally, check for empty region */
   if (bbox[0] > bbox[1]) {
@@ -402,6 +398,33 @@ _mesa_scissor_bounding_box(const struct gl_context *ctx,
  bbox[2] = bbox[3];
   }
}
+}
+
+/**
+ * Calculate the inclusive bounding box for the scissor of a specific viewport
+ *
+ * \param ctx GL context.
+ * \param buffer  Framebuffer to be checked against
+ * \param idx Index of the desired viewport
+ * \param bboxBounding box for the scissored viewport.  Stored as xmin,
+ *xmax, ymin, ymax.
+ *
+ * \warning This function assumes that the framebuffer dimensions are up to
+ * date (e.g., update_framebuffer_size has been recently called on \c buffer).
+ *
+ * \sa _mesa_clip_to_region
+ */
+void
+_mesa_scissor_bounding_box(const struct gl_context *ctx,
+   const struct gl_framebuffer *buffer,
+   unsigned idx, int *bbox)
+{
+   bbox[0] = 0;
+   bbox[2] = 0;
+   bbox[1] = buffer->Width;
+   bbox[3] = buffer->Height;
+
+   _mesa_intersect_scissor_bounding_box(ctx, idx, bbox);
 
assert(bbox[0] <= bbox[1]);
assert(bbox[2] <= bbox[3]);
diff --git a/src/mesa/main/framebuffer.h b/src/mesa/main/framebuffer.h
index 4a2e0d9..8c824dc 100644
--- a/src/mesa/main/framebuffer.h
+++ b/src/mesa/main/framebuffer.h
@@ -76,6 +76,10 @@ _mesa_scissor_bounding_box(const struct gl_context *ctx,
const struct gl_framebuffer *buffer,
unsigned idx, int *bbox);
 
+extern void
+_mesa_intersect_scissor_bounding_box(const struct gl_context *ctx,
+ unsigned idx, int *bbox);
+
 static inline  GLuint
 _mesa_geometric_width(const struct gl_framebuffer *buffer)
 {
-- 
1.9.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 9/9] mark GL_ARB_framebuffer_no_attachments as done for i965

2015-04-29 Thread kevin . rogovin
From: Kevin Rogovin 

Mark GL_ARB_framebuffer_no_attachments as done for i965.

---
 docs/GL3.txt  | 2 +-
 docs/relnotes/10.6.0.html | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/docs/GL3.txt b/docs/GL3.txt
index 172fd3c..cf3b5a2 100644
--- a/docs/GL3.txt
+++ b/docs/GL3.txt
@@ -157,7 +157,7 @@ GL 4.3, GLSL 4.30:
   GL_KHR_debug DONE (all drivers)
   GL_ARB_explicit_uniform_location DONE (all drivers that 
support GLSL)
   GL_ARB_fragment_layer_viewport   DONE (nv50, nvc0, r600, 
llvmpipe)
-  GL_ARB_framebuffer_no_attachmentsnot started
+  GL_ARB_framebuffer_no_attachmentsDONE (i965)
   GL_ARB_internalformat_query2 not started
   GL_ARB_invalidate_subdataDONE (all drivers)
   GL_ARB_multi_draw_indirect   DONE (i965, nvc0, r600, 
radeonsi, llvmpipe, softpipe)
diff --git a/docs/relnotes/10.6.0.html b/docs/relnotes/10.6.0.html
index 48f76f9..3919d19 100644
--- a/docs/relnotes/10.6.0.html
+++ b/docs/relnotes/10.6.0.html
@@ -55,6 +55,7 @@ Note: some of the new features are only available with 
certain drivers.
 GL_ARB_clip_control on i965
 GL_ARB_program_interface_query (all drivers)
 GL_ARB_texture_stencil8 on nv50, nvc0, r600, radeonsi, softpipe
+GL_ARB_framebuffer_no_attachments on i965
 
 
 Bug fixes
-- 
1.9.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 1/9] mesa:Define extension GL_ARB_framebuffer_no_attachments

2015-04-29 Thread kevin . rogovin
From: Kevin Rogovin 

Define the infrastructure for the extension GL_ARB_framebuffer_no_attachments:
 - extension table
 - additions to gl_framebuffer

---
 src/mesa/main/extensions.c  |  1 +
 src/mesa/main/fbobject.c|  1 +
 src/mesa/main/framebuffer.c |  1 +
 src/mesa/main/mtypes.h  | 52 -
 4 files changed, 50 insertions(+), 5 deletions(-)

diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c
index 3d4965c..99c1b06 100644
--- a/src/mesa/main/extensions.c
+++ b/src/mesa/main/extensions.c
@@ -117,6 +117,7 @@ static const struct extension extension_table[] = {
{ "GL_ARB_fragment_program",o(ARB_fragment_program),
GLL,2002 },
{ "GL_ARB_fragment_program_shadow", 
o(ARB_fragment_program_shadow), GLL,2003 },
{ "GL_ARB_fragment_shader", o(ARB_fragment_shader), 
GL, 2002 },
+   { "GL_ARB_framebuffer_no_attachments",  
o(ARB_framebuffer_no_attachments),  GL, 2012 },
{ "GL_ARB_framebuffer_object",  o(ARB_framebuffer_object),  
GL, 2005 },
{ "GL_ARB_framebuffer_sRGB",o(EXT_framebuffer_sRGB),
GL, 1998 },
{ "GL_ARB_get_program_binary",  o(dummy_true),  
GL, 2010 },
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 27cf97f..eabbb96 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -914,6 +914,7 @@ _mesa_test_framebuffer_completeness(struct gl_context *ctx,
fb->Height = 0;
fb->_AllColorBuffersFixedPoint = GL_TRUE;
fb->_HasSNormOrFloatColorBuffer = GL_FALSE;
+   fb->_HasAttachments = GL_TRUE;
 
/* Start at -2 to more easily loop over all attachment points.
 *  -2: depth buffer
diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c
index 4f7736a..4e4d896 100644
--- a/src/mesa/main/framebuffer.c
+++ b/src/mesa/main/framebuffer.c
@@ -157,6 +157,7 @@ _mesa_initialize_window_framebuffer(struct gl_framebuffer 
*fb,
fb->_Status = GL_FRAMEBUFFER_COMPLETE_EXT;
fb->_AllColorBuffersFixedPoint = !visual->floatMode;
fb->_HasSNormOrFloatColorBuffer = visual->floatMode;
+   fb->_HasAttachments = GL_TRUE;
 
compute_depth_max(fb);
 }
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index fb41430..ef97538 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -3133,12 +3133,29 @@ struct gl_framebuffer
 */
struct gl_config Visual;
 
-   GLuint Width, Height;   /**< size of frame buffer in pixels */
+   /**
+* size of frame buffer in pixels,
+* no attachments has these values as 0
+*/
+   GLuint Width, Height;
+
+   /**
+* In the case that the framebuffer has no attachment (i.e.
+* GL_ARB_framebuffer_no_attachments) then the geometry of
+* the framebuffer is specified by the default values.
+*/
+   struct {
+ GLuint Width, Height, Layers, NumSamples;
+ GLboolean FixedSampleLocations;
+   } DefaultGeometry;
 
-   /** \name  Drawing bounds (Intersection of buffer size and scissor box) */
+   /** \name  Drawing bounds (Intersection of buffer size and scissor box)
+* The drawing region is given by [_Xmin, _Xmax) x [_Ymin, _Ymax),
+* (inclusive for _Xmin and _Ymin while exclusive for _Xmax and _Ymax)
+*/
/*@{*/
-   GLint _Xmin, _Xmax;  /**< inclusive */
-   GLint _Ymin, _Ymax;  /**< exclusive */
+   GLint _Xmin, _Xmax;
+   GLint _Ymin, _Ymax;
/*@}*/
 
/** \name  Derived Z buffer stuff */
@@ -3151,6 +3168,20 @@ struct gl_framebuffer
/** One of the GL_FRAMEBUFFER_(IN)COMPLETE_* tokens */
GLenum _Status;
 
+   /** True if both of the conditions:
+*  1. one of Attachment has Type != GL_NONE
+*  2 _Status is GL_FRAMEBUFFER_COMPLETE_EXT
+* NOTE: the values for Width and Height are set to 0 in
+* case of no attachments, a backend driver supporting
+* GL_ARB_framebuffer_no_attachments must check for the
+* flag _HasAttachments and if GL_FALSE, must then use
+* the values in DefaultGeometry to initialize its
+* viewport, scissor and so on (in particular _Xmin,
+* _Xmax, _Ymin and _Ymax do NOT take into account
+* _HasAttachments being false)
+*/
+   GLboolean _HasAttachments;
+
/** Integer color values */
GLboolean _IntegerColor;
 
@@ -3161,7 +3192,9 @@ struct gl_framebuffer
/**
 * The maximum number of layers in the framebuffer, or 0 if the framebuffer
 * is not layered.  For cube maps and cube map arrays, each cube face
-* counts as a layer.
+* counts as a layer. As the case for Width, Height a backend driver
+* supporting GL_ARB_framebuffer_no_attachments must use D

[Mesa-dev] [PATCH 6/9] i965: Use _mesa_geometry_ functions appropriately

2015-04-29 Thread kevin . rogovin
From: Kevin Rogovin 

Change references to gl_framebuffer::Width, Height, MaxNumLayers
and Visual::samples to use the _mesa_geometry_ convenience functions
for those places where the geometry of the gl_framebuffer is needed
(in contrast to the geometry of the intersection of the attachments
of the gl_framebuffer).

This patch is to pave the way to enable GL_ARB_framebuffer_no_attachments
on Gen7 and higher in i965. 

---
 src/mesa/drivers/dri/i965/brw_clip_state.c |  9 ++---
 src/mesa/drivers/dri/i965/brw_misc_state.c | 10 +++---
 src/mesa/drivers/dri/i965/brw_sf_state.c   |  8 
 src/mesa/drivers/dri/i965/brw_state_upload.c   |  6 --
 src/mesa/drivers/dri/i965/brw_wm.c |  7 ---
 src/mesa/drivers/dri/i965/brw_wm_surface_state.c   | 11 +++
 src/mesa/drivers/dri/i965/gen6_clip_state.c| 10 +++---
 src/mesa/drivers/dri/i965/gen6_multisample_state.c |  3 ++-
 src/mesa/drivers/dri/i965/gen6_scissor_state.c | 13 ++---
 src/mesa/drivers/dri/i965/gen6_sf_state.c  |  3 ++-
 src/mesa/drivers/dri/i965/gen6_viewport_state.c|  5 +++--
 src/mesa/drivers/dri/i965/gen6_wm_state.c  |  3 ++-
 src/mesa/drivers/dri/i965/gen7_sf_state.c  |  3 ++-
 src/mesa/drivers/dri/i965/gen7_viewport_state.c|  5 +++--
 src/mesa/drivers/dri/i965/gen7_wm_state.c  |  3 ++-
 src/mesa/drivers/dri/i965/gen8_viewport_state.c|  8 +---
 16 files changed, 74 insertions(+), 33 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_clip_state.c 
b/src/mesa/drivers/dri/i965/brw_clip_state.c
index 3223834..dee74db 100644
--- a/src/mesa/drivers/dri/i965/brw_clip_state.c
+++ b/src/mesa/drivers/dri/i965/brw_clip_state.c
@@ -32,6 +32,7 @@
 #include "brw_context.h"
 #include "brw_state.h"
 #include "brw_defines.h"
+#include "main/framebuffer.h"
 
 static void
 upload_clip_vp(struct brw_context *brw)
@@ -59,7 +60,9 @@ brw_upload_clip_unit(struct brw_context *brw)
struct brw_clip_unit_state *clip;
 
/* _NEW_BUFFERS */
-   struct gl_framebuffer *fb = ctx->DrawBuffer;
+   const struct gl_framebuffer *fb = ctx->DrawBuffer;
+   const float fb_width = (float)_mesa_geometric_width(fb);
+   const float fb_height = (float)_mesa_geometric_height(fb);
 
upload_clip_vp(brw);
 
@@ -127,8 +130,8 @@ brw_upload_clip_unit(struct brw_context *brw)
/* enable guardband clipping if we can */
if (ctx->ViewportArray[0].X == 0 &&
ctx->ViewportArray[0].Y == 0 &&
-   ctx->ViewportArray[0].Width == (float) fb->Width &&
-   ctx->ViewportArray[0].Height == (float) fb->Height)
+   ctx->ViewportArray[0].Width == fb_width &&
+   ctx->ViewportArray[0].Height == fb_height)
{
   clip->clip5.guard_band_enable = 1;
   clip->clip6.clipper_viewport_state_ptr =
diff --git a/src/mesa/drivers/dri/i965/brw_misc_state.c 
b/src/mesa/drivers/dri/i965/brw_misc_state.c
index 78a46cb..e9b1773 100644
--- a/src/mesa/drivers/dri/i965/brw_misc_state.c
+++ b/src/mesa/drivers/dri/i965/brw_misc_state.c
@@ -39,6 +39,7 @@
 #include "brw_state.h"
 #include "brw_defines.h"
 
+#include "main/framebuffer.h"
 #include "main/fbobject.h"
 #include "main/glformats.h"
 
@@ -46,12 +47,15 @@
 static void upload_drawing_rect(struct brw_context *brw)
 {
struct gl_context *ctx = &brw->ctx;
+   const struct gl_framebuffer *fb = ctx->DrawBuffer;
+   const unsigned int fb_width = _mesa_geometric_width(fb);
+   const unsigned int fb_height = _mesa_geometric_height(fb);
 
BEGIN_BATCH(4);
OUT_BATCH(_3DSTATE_DRAWING_RECTANGLE << 16 | (4 - 2));
OUT_BATCH(0); /* xmin, ymin */
-   OUT_BATCH(((ctx->DrawBuffer->Width - 1) & 0x) |
-   ((ctx->DrawBuffer->Height - 1) << 16));
+   OUT_BATCH(((fb_width - 1) & 0x) |
+   ((fb_height - 1) << 16));
OUT_BATCH(0);
ADVANCE_BATCH();
 }
@@ -767,7 +771,7 @@ static void upload_polygon_stipple_offset(struct 
brw_context *brw)
 * works just fine, and there's no window system to worry about.
 */
if (_mesa_is_winsys_fbo(ctx->DrawBuffer))
-  OUT_BATCH((32 - (ctx->DrawBuffer->Height & 31)) & 31);
+  OUT_BATCH((32 - (_mesa_geometric_height(ctx->DrawBuffer) & 31)) & 31);
else
   OUT_BATCH(0);
ADVANCE_BATCH();
diff --git a/src/mesa/drivers/dri/i965/brw_sf_state.c 
b/src/mesa/drivers/dri/i965/brw_sf_state.c
index 014b434..6f9397f 100644
--- a/src/mesa/drivers/dri/i965/brw_sf_state.c
+++ b/src/mesa/drivers/dri/i965/brw_sf_state.c
@@ -52,6 +52,14 @@ static void upload_sf_vp(struct brw_context *brw)
 sizeof(*sfv), 32, &brw->sf.vp_offset);
memset(sfv, 0, sizeof(*sfv));
 
+   /* Accessing the fields Width and Height of
+* gl_framebuffer to produce the values to
+* p

[Mesa-dev] [PATCH 4/9] mesa: add helper convenience functions for fetching geometry of gl_framebuffer

2015-04-29 Thread kevin . rogovin
From: Kevin Rogovin 

Add convenience helper functions for fetching geometry of gl_framebuffer
that return the geometry of the gl_framebuffer instead of the geometry of
the buffers of the gl_framebuffer when then the gl_framebuffer has no 
attachments.

---
 src/mesa/main/framebuffer.h | 29 +
 src/mesa/main/mtypes.h  |  8 +++-
 2 files changed, 36 insertions(+), 1 deletion(-)

diff --git a/src/mesa/main/framebuffer.h b/src/mesa/main/framebuffer.h
index a427421..4a2e0d9 100644
--- a/src/mesa/main/framebuffer.h
+++ b/src/mesa/main/framebuffer.h
@@ -76,6 +76,35 @@ _mesa_scissor_bounding_box(const struct gl_context *ctx,
const struct gl_framebuffer *buffer,
unsigned idx, int *bbox);
 
+static inline  GLuint
+_mesa_geometric_width(const struct gl_framebuffer *buffer)
+{
+   return buffer->_HasAttachments ?
+  buffer->Width : buffer->DefaultGeometry.Width;
+}
+
+
+static inline  GLuint
+_mesa_geometric_height(const struct gl_framebuffer *buffer)
+{
+   return buffer->_HasAttachments ?
+  buffer->Height : buffer->DefaultGeometry.Height;
+}
+
+static inline  GLuint
+_mesa_geometric_samples(const struct gl_framebuffer *buffer)
+{
+   return buffer->_HasAttachments ?
+  buffer->Visual.samples : buffer->DefaultGeometry.NumSamples;
+}
+
+static inline  GLuint
+_mesa_geometric_layers(const struct gl_framebuffer *buffer)
+{
+   return buffer->_HasAttachments ?
+  buffer->MaxNumLayers : buffer->DefaultGeometry.Layers;
+}
+
 extern void 
 _mesa_update_draw_buffer_bounds(struct gl_context *ctx);
 
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index ef97538..f0e8fbc 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -3178,7 +3178,13 @@ struct gl_framebuffer
 * the values in DefaultGeometry to initialize its
 * viewport, scissor and so on (in particular _Xmin,
 * _Xmax, _Ymin and _Ymax do NOT take into account
-* _HasAttachments being false)
+* _HasAttachments being false). To get the geometry
+* of the framebuffer, the  helper functions
+*   _mesa_geometric_width(),
+*   _mesa_geometric_height(),
+*   _mesa_geometric_samples(),
+*   _mesa_geometric_layers()
+* are available that check _HasAttachments.
 */
GLboolean _HasAttachments;
 
-- 
1.9.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 3/9] mesa: Complete implementation for GL_ARB_framebuffer_no_attachments in Mesa core

2015-04-29 Thread kevin . rogovin
From: Kevin Rogovin 

Implement GL_ARB_framebuffer_no_attachments in Mesa core
 - changes to conditions for framebuffer completenss
 - implement set/get functions for framebuffers for 
   new functions in GL_ARB_framebuffer_no_attachments

---
 src/mesa/main/fbobject.c | 154 ---
 1 file changed, 145 insertions(+), 9 deletions(-)

diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 5c78c40..402537b 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -1113,14 +1113,49 @@ _mesa_test_framebuffer_completeness(struct gl_context 
*ctx,
   } else if (att_layer_count > max_layer_count) {
  max_layer_count = att_layer_count;
   }
+
+  /**
+   * The extension GL_ARB_framebuffer_no_attachments places the additional
+   * requirement on each attachment that
+   *
+   * "The width and height of image are greater than zero and less than or
+   *  equal to the values of the implementation-dependent limits
+   *  MAX_FRAMEBUFFER_WIDTH and MAX_FRAMEBUFFER_HEIGHT, respectively. "
+   *
+   * "If  is a three-dimensional texture or a one- or 
two-dimensional
+   *  array texture and the attachment is layered, the depth or layer count
+   *  of the texture is less than or equal to the implementation-dependent
+   *  limit MAX_FRAMEBUFFER_LAYERS."
+   *
+   * "If image has multiple samples, its sample count is less than or equal
+   *  to the value of the implementation-dependent limit MAX_FRAMEBUFFER_-
+   *  SAMPLES ."
+   *
+   * The same requirements are also in place for GL 4.5,
+   * Section 9.4.1 "Framebuffer Attachment Completeness", pg 310-311
+   *
+   * However, this is a tighter restriction than previous version of GL.
+   * In interest of better compatibility, we will not enforce these
+   * restrictions.
+   */
}
 
fb->MaxNumLayers = max_layer_count;
 
if (numImages == 0) {
-  fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT;
-  fbo_incomplete(ctx, "no attachments", -1);
-  return;
+  fb->_HasAttachments = GL_FALSE;
+
+  if (!ctx->Extensions.ARB_framebuffer_no_attachments) {
+ fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT;
+ fbo_incomplete(ctx, "no attachments", -1);
+ return;
+  }
+
+  if (fb->DefaultGeometry.Width == 0 || fb->DefaultGeometry.Height == 0) {
+ fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT;
+ fbo_incomplete(ctx, "no attachments and default width or height is 
0", -1);
+ return;
+  }
}
 
if (_mesa_is_desktop_gl(ctx) && !ctx->Extensions.ARB_ES2_compatibility) {
@@ -1185,8 +1220,10 @@ _mesa_test_framebuffer_completeness(struct gl_context 
*ctx,
* renderbuffers/textures are different sizes, the framebuffer
* width/height will be set to the smallest width/height.
*/
-  fb->Width = minWidth;
-  fb->Height = minHeight;
+  if (numImages != 0) {
+ fb->Width = minWidth;
+ fb->Height = minHeight;
+  }
 
   /* finally, update the visual info for the framebuffer */
   _mesa_update_framebuffer_visual(ctx, fb);
@@ -1292,16 +1329,115 @@ _mesa_BindRenderbufferEXT(GLenum target, GLuint 
renderbuffer)
bind_renderbuffer(target, renderbuffer, true);
 }
 
-extern void GLAPIENTRY
+static void
+framebuffer_parameteri(struct gl_context *ctx, struct gl_framebuffer *fb,
+   GLenum pname, GLint param, const char *func)
+{
+   switch (pname) {
+   case GL_FRAMEBUFFER_DEFAULT_WIDTH:
+  if (param < 0 || param > ctx->Const.MaxFramebufferWidth)
+_mesa_error(ctx, GL_INVALID_VALUE, "%s", func);
+  else
+ fb->DefaultGeometry.Width = param;
+  break;
+   case GL_FRAMEBUFFER_DEFAULT_HEIGHT:
+  if (param < 0 || param > ctx->Const.MaxFramebufferHeight)
+_mesa_error(ctx, GL_INVALID_VALUE, "%s", func);
+  else
+ fb->DefaultGeometry.Height = param;
+  break;
+   case GL_FRAMEBUFFER_DEFAULT_LAYERS:
+  if (param < 0 || param > ctx->Const.MaxFramebufferLayers)
+_mesa_error(ctx, GL_INVALID_VALUE, "%s", func);
+  else
+ fb->DefaultGeometry.Layers = param;
+  break;
+   case GL_FRAMEBUFFER_DEFAULT_SAMPLES:
+  if (param < 0 || param > ctx->Const.MaxFramebufferSamples)
+_mesa_error(ctx, GL_INVALID_VALUE, "%s", func);
+  else
+fb->DefaultGeometry.NumSamples = param;
+  break;
+   case GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS:
+  fb->DefaultGeometry.FixedSampleLocations = param;
+  break;
+   default:
+  _mesa_error(ctx, GL_INVALID_ENUM,
+  "%s(pname=0x%x

[Mesa-dev] [PATCH 8/9] i965: enable ARB_framebuffer_no_attachments extension for Gen7 and later

2015-04-29 Thread kevin . rogovin
From: Kevin Rogovin 

Enable GL_ARB_framebuffer_no_attachments in i965 for Gen7 and higher.

---
 src/mesa/drivers/dri/i965/brw_context.c  | 6 ++
 src/mesa/drivers/dri/i965/intel_extensions.c | 1 +
 2 files changed, 7 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/brw_context.c 
b/src/mesa/drivers/dri/i965/brw_context.c
index 9d90360..5c9577f 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -608,6 +608,12 @@ brw_initialize_context_constants(struct brw_context *brw)
/* ARB_gpu_shader5 */
if (brw->gen >= 7)
   ctx->Const.MaxVertexStreams = MIN2(4, MAX_VERTEX_STREAMS);
+
+   /* ARB_framebuffer_no_attachments */
+   ctx->Const.MaxFramebufferWidth = ctx->Const.MaxViewportWidth;
+   ctx->Const.MaxFramebufferHeight = ctx->Const.MaxViewportHeight;
+   ctx->Const.MaxFramebufferLayers = ctx->Const.MaxArrayTextureLayers;
+   ctx->Const.MaxFramebufferSamples = max_samples;
 }
 
 /**
diff --git a/src/mesa/drivers/dri/i965/intel_extensions.c 
b/src/mesa/drivers/dri/i965/intel_extensions.c
index 48064e1..65cf2bb 100644
--- a/src/mesa/drivers/dri/i965/intel_extensions.c
+++ b/src/mesa/drivers/dri/i965/intel_extensions.c
@@ -304,6 +304,7 @@ intelInitExtensions(struct gl_context *ctx)
if (brw->gen >= 7) {
   ctx->Extensions.ARB_conservative_depth = true;
   ctx->Extensions.ARB_texture_view = true;
+  ctx->Extensions.ARB_framebuffer_no_attachments = true;
   if (can_do_pipelined_register_writes(brw)) {
  ctx->Extensions.ARB_transform_feedback2 = true;
  ctx->Extensions.ARB_transform_feedback3 = true;
-- 
1.9.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 2/9] mesa:Define constants and functions for GL_ARB_framebuffer_no_attachment extension

2015-04-29 Thread kevin . rogovin
From: Kevin Rogovin 

Define the enumeration constants, function entry points and
glGet for the GL_ARB_framebuffer_no_attachments

---
 .../glapi/gen/ARB_framebuffer_no_attachments.xml   | 33 +++
 src/mapi/glapi/gen/Makefile.am |  1 +
 src/mapi/glapi/gen/gl_API.xml  |  4 ++-
 src/mesa/main/fbobject.c   | 12 +++
 src/mesa/main/fbobject.h   |  7 
 src/mesa/main/get.c|  3 ++
 src/mesa/main/get_hash_params.py   | 38 ++
 7 files changed, 97 insertions(+), 1 deletion(-)
 create mode 100644 src/mapi/glapi/gen/ARB_framebuffer_no_attachments.xml

diff --git a/src/mapi/glapi/gen/ARB_framebuffer_no_attachments.xml 
b/src/mapi/glapi/gen/ARB_framebuffer_no_attachments.xml
new file mode 100644
index 000..5bde14d
--- /dev/null
+++ b/src/mapi/glapi/gen/ARB_framebuffer_no_attachments.xml
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/mapi/glapi/gen/Makefile.am b/src/mapi/glapi/gen/Makefile.am
index 1c4b86a..dc61739 100644
--- a/src/mapi/glapi/gen/Makefile.am
+++ b/src/mapi/glapi/gen/Makefile.am
@@ -129,6 +129,7 @@ API_XML = \
ARB_draw_instanced.xml \
ARB_ES2_compatibility.xml \
ARB_ES3_compatibility.xml \
+   ARB_framebuffer_no_attachments.xml \
ARB_framebuffer_object.xml \
ARB_geometry_shader4.xml \
ARB_get_program_binary.xml \
diff --git a/src/mapi/glapi/gen/gl_API.xml b/src/mapi/glapi/gen/gl_API.xml
index a8a6db6..91882ef 100644
--- a/src/mapi/glapi/gen/gl_API.xml
+++ b/src/mapi/glapi/gen/gl_API.xml
@@ -8324,7 +8324,9 @@
 
 
 
-
+http://www.w3.org/2001/XInclude"/>
+
+
 
 
 
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index eabbb96..5c78c40 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -1292,6 +1292,18 @@ _mesa_BindRenderbufferEXT(GLenum target, GLuint 
renderbuffer)
bind_renderbuffer(target, renderbuffer, true);
 }
 
+extern void GLAPIENTRY
+_mesa_FramebufferParameteri(GLenum target, GLenum pname, GLint param)
+{
+  /* to be implemented */
+}
+
+extern void GLAPIENTRY
+_mesa_GetFramebufferParameteriv(GLenum target, GLenum pname, GLint *params)
+{
+  /* to be implemented */
+}
+
 
 /**
  * Remove the specified renderbuffer or texture from any attachment point in
diff --git a/src/mesa/main/fbobject.h b/src/mesa/main/fbobject.h
index 61aa1f5..76adb92 100644
--- a/src/mesa/main/fbobject.h
+++ b/src/mesa/main/fbobject.h
@@ -211,4 +211,11 @@ extern void GLAPIENTRY
 _mesa_DiscardFramebufferEXT(GLenum target, GLsizei numAttachments,
 const GLenum *attachments);
 
+
+extern void GLAPIENTRY
+_mesa_FramebufferParameteri(GLenum target, GLenum pname, GLint param);
+
+extern void GLAPIENTRY
+_mesa_GetFramebufferParameteriv(GLenum target, GLenum pname, GLint *params);
+
 #endif /* FBOBJECT_H */
diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
index a881bc5..ca9d13c 100644
--- a/src/mesa/main/get.c
+++ b/src/mesa/main/get.c
@@ -393,6 +393,7 @@ EXTRA_EXT(INTEL_performance_query);
 EXTRA_EXT(ARB_explicit_uniform_location);
 EXTRA_EXT(ARB_clip_control);
 EXTRA_EXT(EXT_polygon_offset_clamp);
+EXTRA_EXT(ARB_framebuffer_no_attachments);
 
 static const int
 extra_ARB_color_buffer_float_or_glcore[] = {
@@ -466,6 +467,8 @@ static const int 
extra_core_ARB_color_buffer_float_and_new_buffers[] = {
  * remaining combinations. To look up the enums valid in a given API
  * we will use a hash table specific to that API. These tables are in
  * turn generated at build time and included through get_hash.h.
+ * To add an entry (i.e. a new enumeration for glGet that is taken
+ * from the table) add an entry to get_hash_params.py.
  */
 
 #include "get_hash.h"
diff --git a/src/mesa/main/get_hash_params.py b/src/mesa/main/get_hash_params.py
index 41cb2c1..37d9545 100644
--- a/src/mesa/main/get_hash_params.py
+++ b/src/mesa/main/get_hash_params.py
@@ -1,3 +1,34 @@
+# glGet pnames possible, organized first by GL version
+# and then organized by GL extension.
+# There is a list for different combinations of GL_ version
+# that combination is specified by the field "apis".
+# The field "params" is a list of entries describing
+# how glGet* operates when passed a pname.
+# To add a pname for glGet* to handle, the entry is of the form
+# a) [ "PnameX", "LOC_CUSTOM, TypeX, ExtraRequirementX" ]
+# OR
+# b) [ "PnameX", "OffsetX, ExtraRequirement" ]
+#
+#   - PnameX is the name of the pname passed to glGet without the GL_ prefix
+#   - ExtraRequirement is extra requirment declared in get.c listing
+# GL requirements (such as extension requirements). If no extra
+# requirement is needed, then it is NO_EXTRA
+#
+# Form a) is for those pnames whose glGet implementation is
+# not 

[Mesa-dev] [PATCH 7/9] i965: ensure execution of fragment shader when fragment shader has atomic buffer access

2015-04-29 Thread kevin . rogovin
From: Kevin Rogovin 

If the fragment shader has atomic buffer access, the shader must execute
even if the current draw buffer has no attachments.

---
 src/mesa/drivers/dri/i965/gen7_wm_state.c | 7 +++
 src/mesa/drivers/dri/i965/gen8_ps_state.c | 4 
 2 files changed, 11 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/gen7_wm_state.c 
b/src/mesa/drivers/dri/i965/gen7_wm_state.c
index 4d67b86..939d6e4 100644
--- a/src/mesa/drivers/dri/i965/gen7_wm_state.c
+++ b/src/mesa/drivers/dri/i965/gen7_wm_state.c
@@ -77,6 +77,13 @@ upload_wm_state(struct brw_context *brw)
   dw1 |= GEN7_WM_KILL_ENABLE;
}
 
+   if (brw->ctx.Shader._CurrentFragmentProgram != NULL &&
+   brw->ctx.Shader._CurrentFragmentProgram->NumAtomicBuffers > 0) {
+ dw1 |= GEN7_WM_DISPATCH_ENABLE;
+   }
+
/* _NEW_BUFFERS | _NEW_COLOR */
if (brw_color_buffer_write_enabled(brw) || writes_depth ||
dw1 & GEN7_WM_KILL_ENABLE) {
diff --git a/src/mesa/drivers/dri/i965/gen8_ps_state.c 
b/src/mesa/drivers/dri/i965/gen8_ps_state.c
index 5f39e12..614bc9b 100644
--- a/src/mesa/drivers/dri/i965/gen8_ps_state.c
+++ b/src/mesa/drivers/dri/i965/gen8_ps_state.c
@@ -62,6 +62,10 @@ upload_ps_extra(struct brw_context *brw)
if (prog_data->uses_omask)
   dw1 |= GEN8_PSX_OMASK_TO_RENDER_TARGET;
 
+   if (brw->ctx.Shader._CurrentFragmentProgram != NULL &&
+   brw->ctx.Shader._CurrentFragmentProgram->NumAtomicBuffers > 0)
+  dw1 |= GEN8_PSX_SHADER_HAS_UAV;
+
BEGIN_BATCH(2);
OUT_BATCH(_3DSTATE_PS_EXTRA << 16 | (2 - 2));
OUT_BATCH(dw1);
-- 
1.9.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [v3 PATCH 00/10] Implement extension ARB_framebuffer_no_attachments

2015-05-21 Thread kevin . rogovin
From: Kevin Rogovin 

This patch series implements:
  - the needed functionality in Mesa-core for ARB_framebuffer_no_attachments
  - implements and enables the extension i965

Kevin Rogovin (10):
  mesa:Define extension ARB_framebuffer_no_attachments to gl_framebuffer
for extension ARB_framebuffer_no_attachments
  mesa:Define constants and functions for ARB_framebuffer_no_attachment
extension
  mesa: Complete implementation for ARB_framebuffer_no_attachment in
Mesa core
  mesa: add helper convenience functions for fetching geometry of
gl_framebuffer
  mesa: add helper convenience functions for computing box intersected
against scissors of gl_framebuffer
  i965: Use _mesa_geometry_ functions appropriately
  mesa: add helper function for testing if current fragment shader has
atomics
  i965: ensure execution of fragment shader when fragment shader has
atomic buffer access
  i965: enable ARB_framebuffer_no_attachment extension for Gen7 and
later
  mark GL_ARB_framebuffer_no_attachments as done for i965

 docs/GL3.txt   |   4 +-
 docs/relnotes/10.6.0.html  |   1 +
 .../glapi/gen/ARB_framebuffer_no_attachments.xml   |  32 +++
 src/mapi/glapi/gen/Makefile.am |   1 +
 src/mapi/glapi/gen/gl_API.xml  |   4 +-
 src/mesa/drivers/dri/i965/brw_clip_state.c |   9 +-
 src/mesa/drivers/dri/i965/brw_context.c|   6 +
 src/mesa/drivers/dri/i965/brw_misc_state.c |  10 +-
 src/mesa/drivers/dri/i965/brw_sf_state.c   |   8 +
 src/mesa/drivers/dri/i965/brw_state_upload.c   |   6 +-
 src/mesa/drivers/dri/i965/brw_wm.c |   7 +-
 src/mesa/drivers/dri/i965/brw_wm_surface_state.c   |  12 +-
 src/mesa/drivers/dri/i965/gen6_clip_state.c|  10 +-
 src/mesa/drivers/dri/i965/gen6_multisample_state.c |   3 +-
 src/mesa/drivers/dri/i965/gen6_scissor_state.c |  13 +-
 src/mesa/drivers/dri/i965/gen6_sf_state.c  |   3 +-
 src/mesa/drivers/dri/i965/gen6_viewport_state.c|   5 +-
 src/mesa/drivers/dri/i965/gen6_wm_state.c  |   3 +-
 src/mesa/drivers/dri/i965/gen7_sf_state.c  |   3 +-
 src/mesa/drivers/dri/i965/gen7_viewport_state.c|   5 +-
 src/mesa/drivers/dri/i965/gen7_wm_state.c  |   7 +-
 src/mesa/drivers/dri/i965/gen8_ps_state.c  |   3 +
 src/mesa/drivers/dri/i965/gen8_viewport_state.c|   8 +-
 src/mesa/drivers/dri/i965/intel_extensions.c   |   1 +
 src/mesa/main/extensions.c |   1 +
 src/mesa/main/fbobject.c   | 218 +++--
 src/mesa/main/fbobject.h   |   7 +
 src/mesa/main/framebuffer.c|  64 --
 src/mesa/main/framebuffer.h|  33 
 src/mesa/main/get.c|   3 +
 src/mesa/main/get_hash_params.py   |  38 
 src/mesa/main/mtypes.h |  63 +-
 src/mesa/main/tests/dispatch_sanity.cpp|   4 +-
 33 files changed, 511 insertions(+), 84 deletions(-)
 create mode 100644 src/mapi/glapi/gen/ARB_framebuffer_no_attachments.xml

-- 
1.9.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [v3 PATCH 03/10] mesa: Complete implementation for ARB_framebuffer_no_attachments in Mesa core

2015-05-21 Thread kevin . rogovin
From: Kevin Rogovin 

Implement GL_ARB_framebuffer_no_attachments in Mesa core
 - changes to conditions for framebuffer completenss
 - implement set/get functions for framebuffers for 
   new functions in GL_ARB_framebuffer_no_attachments

v1 -> v2
 Spacing and exceed 80 characters per line fixes.

v2 -> v3
 Implement DSA functions of extension. 


Signed-off-by: Kevin Rogovin 
---
 src/mesa/main/fbobject.c | 217 ---
 1 file changed, 184 insertions(+), 33 deletions(-)

diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 4ac3f20..18def71 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -1156,14 +1156,49 @@ _mesa_test_framebuffer_completeness(struct gl_context 
*ctx,
   } else if (att_layer_count > max_layer_count) {
  max_layer_count = att_layer_count;
   }
+
+  /**
+   * The extension GL_ARB_framebuffer_no_attachments places the additional
+   * requirement on each attachment that
+   *
+   * "The width and height of image are greater than zero and less than or
+   *  equal to the values of the implementation-dependent limits
+   *  MAX_FRAMEBUFFER_WIDTH and MAX_FRAMEBUFFER_HEIGHT, respectively. "
+   *
+   * "If  is a three-dimensional texture or a one- or 
two-dimensional
+   *  array texture and the attachment is layered, the depth or layer count
+   *  of the texture is less than or equal to the implementation-dependent
+   *  limit MAX_FRAMEBUFFER_LAYERS."
+   *
+   * "If image has multiple samples, its sample count is less than or equal
+   *  to the value of the implementation-dependent limit MAX_FRAMEBUFFER_-
+   *  SAMPLES ."
+   *
+   * The same requirements are also in place for GL 4.5,
+   * Section 9.4.1 "Framebuffer Attachment Completeness", pg 310-311
+   *
+   * However, this is a tighter restriction than previous version of GL.
+   * In interest of better compatibility, we will not enforce these
+   * restrictions.
+   */
}
 
fb->MaxNumLayers = max_layer_count;
 
if (numImages == 0) {
-  fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT;
-  fbo_incomplete(ctx, "no attachments", -1);
-  return;
+  fb->_HasAttachments = GL_FALSE;
+
+  if (!ctx->Extensions.ARB_framebuffer_no_attachments) {
+ fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT;
+ fbo_incomplete(ctx, "no attachments", -1);
+ return;
+  }
+
+  if (fb->DefaultGeometry.Width == 0 || fb->DefaultGeometry.Height == 0) {
+ fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT;
+ fbo_incomplete(ctx, "no attachments and default width or height is 
0", -1);
+ return;
+  }
}
 
if (_mesa_is_desktop_gl(ctx) && !ctx->Extensions.ARB_ES2_compatibility) {
@@ -1228,8 +1263,10 @@ _mesa_test_framebuffer_completeness(struct gl_context 
*ctx,
* renderbuffers/textures are different sizes, the framebuffer
* width/height will be set to the smallest width/height.
*/
-  fb->Width = minWidth;
-  fb->Height = minHeight;
+  if (numImages != 0) {
+ fb->Width = minWidth;
+ fb->Height = minHeight;
+  }
 
   /* finally, update the visual info for the framebuffer */
   _mesa_update_framebuffer_visual(ctx, fb);
@@ -1335,32 +1372,127 @@ _mesa_BindRenderbufferEXT(GLenum target, GLuint 
renderbuffer)
bind_renderbuffer(target, renderbuffer, true);
 }
 
-extern void GLAPIENTRY
+static void
+framebuffer_parameteri(struct gl_context *ctx, struct gl_framebuffer *fb,
+   GLenum pname, GLint param, const char *func)
+{
+   switch (pname) {
+   case GL_FRAMEBUFFER_DEFAULT_WIDTH:
+  if (param < 0 || param > ctx->Const.MaxFramebufferWidth)
+_mesa_error(ctx, GL_INVALID_VALUE, "%s", func);
+  else
+ fb->DefaultGeometry.Width = param;
+  break;
+   case GL_FRAMEBUFFER_DEFAULT_HEIGHT:
+  if (param < 0 || param > ctx->Const.MaxFramebufferHeight)
+_mesa_error(ctx, GL_INVALID_VALUE, "%s", func);
+  else
+ fb->DefaultGeometry.Height = param;
+  break;
+   case GL_FRAMEBUFFER_DEFAULT_LAYERS:
+  if (param < 0 || param > ctx->Const.MaxFramebufferLayers)
+_mesa_error(ctx, GL_INVALID_VALUE, "%s", func);
+  else
+ fb->DefaultGeometry.Layers = param;
+  break;
+   case GL_FRAMEBUFFER_DEFAULT_SAMPLES:
+  if (param < 0 || param > ctx->Const.MaxFramebufferSamples)
+_mesa_error(ctx, GL_INVALID_VALUE, "%s", func);
+  else
+fb->DefaultGeometry.NumSamples = param;
+  break;
+   case GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS:
+  fb->DefaultGeometry.Fi

[Mesa-dev] [v3 PATCH 02/10] mesa:Define constants and functions for ARB_framebuffer_no_attachment extension

2015-05-21 Thread kevin . rogovin
From: Kevin Rogovin 

Define the enumeration constants, function entry points and
glGet for the GL_ARB_framebuffer_no_attachments.

v1 -> v2
 Add output="true" for GetFramebufferParameteriv parameter params.
 Alphabetical insertion.  

v2 -> v3
 Implement _mesa_GetFramebufferParameteriv and _mesa_FramebufferParameteri
 as always error.

Signed-off-by: Kevin Rogovin 
---
 .../glapi/gen/ARB_framebuffer_no_attachments.xml   | 32 ++
 src/mapi/glapi/gen/Makefile.am |  1 +
 src/mapi/glapi/gen/gl_API.xml  |  4 ++-
 src/mesa/main/fbobject.c   | 28 
 src/mesa/main/fbobject.h   |  7 
 src/mesa/main/get.c|  3 ++
 src/mesa/main/get_hash_params.py   | 38 ++
 src/mesa/main/tests/dispatch_sanity.cpp|  4 +--
 8 files changed, 114 insertions(+), 3 deletions(-)
 create mode 100644 src/mapi/glapi/gen/ARB_framebuffer_no_attachments.xml

diff --git a/src/mapi/glapi/gen/ARB_framebuffer_no_attachments.xml 
b/src/mapi/glapi/gen/ARB_framebuffer_no_attachments.xml
new file mode 100644
index 000..10bdebc
--- /dev/null
+++ b/src/mapi/glapi/gen/ARB_framebuffer_no_attachments.xml
@@ -0,0 +1,32 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/mapi/glapi/gen/Makefile.am b/src/mapi/glapi/gen/Makefile.am
index adebd5c..5099f12 100644
--- a/src/mapi/glapi/gen/Makefile.am
+++ b/src/mapi/glapi/gen/Makefile.am
@@ -130,6 +130,7 @@ API_XML = \
ARB_draw_instanced.xml \
ARB_ES2_compatibility.xml \
ARB_ES3_compatibility.xml \
+   ARB_framebuffer_no_attachments.xml \
ARB_framebuffer_object.xml \
ARB_geometry_shader4.xml \
ARB_get_program_binary.xml \
diff --git a/src/mapi/glapi/gen/gl_API.xml b/src/mapi/glapi/gen/gl_API.xml
index 3090b9f..5079d30 100644
--- a/src/mapi/glapi/gen/gl_API.xml
+++ b/src/mapi/glapi/gen/gl_API.xml
@@ -8188,7 +8188,9 @@
 
 
 
-
+http://www.w3.org/2001/XInclude"/>
+
+
 
 
 
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 8fea7f8..4ac3f20 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -1335,6 +1335,34 @@ _mesa_BindRenderbufferEXT(GLenum target, GLuint 
renderbuffer)
bind_renderbuffer(target, renderbuffer, true);
 }
 
+extern void GLAPIENTRY
+_mesa_FramebufferParameteri(GLenum target, GLenum pname, GLint param)
+{
+   GET_CURRENT_CONTEXT(ctx);
+
+   (void) target;
+   (void) pname;
+   (void) param;
+
+   _mesa_error(ctx, GL_INVALID_OPERATION,
+   "glFramebufferParameteri not supported "
+   "(ARB_framebuffer_no_attachments not implemented)");
+}
+
+extern void GLAPIENTRY
+_mesa_GetFramebufferParameteriv(GLenum target, GLenum pname, GLint *params)
+{
+   GET_CURRENT_CONTEXT(ctx);
+
+   (void) target;
+   (void) pname;
+   (void) param;
+
+   _mesa_error(ctx, GL_INVALID_OPERATION,
+   "glGetNamedFramebufferParameteriv not supported "
+   "(ARB_framebuffer_no_attachments not implemented)");
+}
+
 
 /**
  * Remove the specified renderbuffer or texture from any attachment point in
diff --git a/src/mesa/main/fbobject.h b/src/mesa/main/fbobject.h
index 9f570db..21f5b12 100644
--- a/src/mesa/main/fbobject.h
+++ b/src/mesa/main/fbobject.h
@@ -288,4 +288,11 @@ extern void GLAPIENTRY
 _mesa_DiscardFramebufferEXT(GLenum target, GLsizei numAttachments,
 const GLenum *attachments);
 
+
+extern void GLAPIENTRY
+_mesa_FramebufferParameteri(GLenum target, GLenum pname, GLint param);
+
+extern void GLAPIENTRY
+_mesa_GetFramebufferParameteriv(GLenum target, GLenum pname, GLint *params);
+
 #endif /* FBOBJECT_H */
diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
index 8a6c81a..d02ec08 100644
--- a/src/mesa/main/get.c
+++ b/src/mesa/main/get.c
@@ -393,6 +393,7 @@ EXTRA_EXT(INTEL_performance_query);
 EXTRA_EXT(ARB_explicit_uniform_location);
 EXTRA_EXT(ARB_clip_control);
 EXTRA_EXT(EXT_polygon_offset_clamp);
+EXTRA_EXT(ARB_framebuffer_no_attachments);
 
 static const int
 extra_ARB_color_buffer_float_or_glcore[] = {
@@ -466,6 +467,8 @@ static const int 
extra_core_ARB_color_buffer_float_and_new_buffers[] = {
  * remaining combinations. To look up the enums valid in a given API
  * we will use a hash table specific to that API. These tables are in
  * turn generated at build time and included through get_hash.h.
+ * To add an entry (i.e. a new enumeration for glGet that is taken
+ * from the table) add an entry to get_hash_params.py.
  */
 
 #include "get_hash.h"
diff --git a/src/mesa/main/get_hash_params.py b/src/mesa/main/get_hash_params.py
index 41cb2c1..37d9545 100644
--- a/src/mesa/main/get_hash_params.py
+++ b/src/mesa/main/get_hash_params.py
@@ -1,3 +1,34 @@
+# glGet pnames possible, organized first by GL versi

[Mesa-dev] [v3 PATCH 08/10] i965: ensure execution of fragment shader when fragment shader has atomic buffer access

2015-05-21 Thread kevin . rogovin
From: Kevin Rogovin 

Ensure that the GPU spawns the fragment shader thread for those
fragment shaders with atomic buffer access.

v1 -> v2
 No change.

v2 -> v3
 Use utility function _mesa_active_fragment_shader_has_atomic_ops().

Reviewed-by: Tapani Pälli  (v1)
Signed-off-by: Kevin Rogovin 
---
 src/mesa/drivers/dri/i965/gen7_wm_state.c | 4 
 src/mesa/drivers/dri/i965/gen8_ps_state.c | 3 +++
 2 files changed, 7 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/gen7_wm_state.c 
b/src/mesa/drivers/dri/i965/gen7_wm_state.c
index 1c47076..63092cf 100644
--- a/src/mesa/drivers/dri/i965/gen7_wm_state.c
+++ b/src/mesa/drivers/dri/i965/gen7_wm_state.c
@@ -77,6 +77,10 @@ upload_wm_state(struct brw_context *brw)
   dw1 |= GEN7_WM_KILL_ENABLE;
}
 
+   if (_mesa_active_fragment_shader_has_atomic_ops(&brw->ctx) ) {
+ dw1 |= GEN7_WM_DISPATCH_ENABLE;
+   }
+
/* _NEW_BUFFERS | _NEW_COLOR */
if (brw_color_buffer_write_enabled(brw) || writes_depth ||
dw1 & GEN7_WM_KILL_ENABLE) {
diff --git a/src/mesa/drivers/dri/i965/gen8_ps_state.c 
b/src/mesa/drivers/dri/i965/gen8_ps_state.c
index 85ad3b6..3dee8b6 100644
--- a/src/mesa/drivers/dri/i965/gen8_ps_state.c
+++ b/src/mesa/drivers/dri/i965/gen8_ps_state.c
@@ -58,6 +58,9 @@ gen8_upload_ps_extra(struct brw_context *brw,
if (prog_data->uses_omask)
   dw1 |= GEN8_PSX_OMASK_TO_RENDER_TARGET;
 
+   if (_mesa_active_fragment_shader_has_atomic_ops(&brw->ctx) )
+  dw1 |= GEN8_PSX_SHADER_HAS_UAV;
+
BEGIN_BATCH(2);
OUT_BATCH(_3DSTATE_PS_EXTRA << 16 | (2 - 2));
OUT_BATCH(dw1);
-- 
1.9.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [v3 PATCH 07/10] mesa: add helper function for testing if current fragment shader has atomics

2015-05-21 Thread kevin . rogovin
From: Kevin Rogovin 

Add helper function that checks if current fragment shader active
of gl_context has atomic buffer access.

v1 -> v3
 Added in v3 of patch series.

Signed-off-by: Kevin Rogovin 
---
 src/mesa/main/mtypes.h | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 7e1f0e0..b88b10a 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -4464,7 +4464,12 @@ enum _debug
DEBUG_INCOMPLETE_FBO = (1 << 3)
 };
 
-
+static inline bool
+_mesa_active_fragment_shader_has_atomic_ops(const struct gl_context *ctx)
+{
+   return ctx->Shader._CurrentFragmentProgram!=NULL &&
+  ctx->Shader._CurrentFragmentProgram->NumAtomicBuffers > 0;
+}
 
 #ifdef __cplusplus
 }
-- 
1.9.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [v3 PATCH 01/10] mesa:Define extension ARB_framebuffer_no_attachments

2015-05-21 Thread kevin . rogovin
From: Kevin Rogovin 

Define the infrastructure for the extension GL_ARB_framebuffer_no_attachments:
 - extension table
 - additions to gl_framebuffer

v1 -> v2
 Spacing and trailing spaces fixes.

v2 -> v3
 mtypes.h: Correct comment on _HasAttachments.

Signed-off-by: Kevin Rogovin 
---
 src/mesa/main/extensions.c  |  1 +
 src/mesa/main/fbobject.c|  1 +
 src/mesa/main/framebuffer.c |  1 +
 src/mesa/main/mtypes.h  | 50 -
 4 files changed, 48 insertions(+), 5 deletions(-)

diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c
index c82416a..3256b2c 100644
--- a/src/mesa/main/extensions.c
+++ b/src/mesa/main/extensions.c
@@ -117,6 +117,7 @@ static const struct extension extension_table[] = {
{ "GL_ARB_fragment_program",o(ARB_fragment_program),
GLL,2002 },
{ "GL_ARB_fragment_program_shadow", 
o(ARB_fragment_program_shadow), GLL,2003 },
{ "GL_ARB_fragment_shader", o(ARB_fragment_shader), 
GL, 2002 },
+   { "GL_ARB_framebuffer_no_attachments",  
o(ARB_framebuffer_no_attachments),  GL, 2012 },
{ "GL_ARB_framebuffer_object",  o(ARB_framebuffer_object),  
GL, 2005 },
{ "GL_ARB_framebuffer_sRGB",o(EXT_framebuffer_sRGB),
GL, 1998 },
{ "GL_ARB_get_program_binary",  o(dummy_true),  
GL, 2010 },
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 1859c27..8fea7f8 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -957,6 +957,7 @@ _mesa_test_framebuffer_completeness(struct gl_context *ctx,
fb->Height = 0;
fb->_AllColorBuffersFixedPoint = GL_TRUE;
fb->_HasSNormOrFloatColorBuffer = GL_FALSE;
+   fb->_HasAttachments = GL_TRUE;
 
/* Start at -2 to more easily loop over all attachment points.
 *  -2: depth buffer
diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c
index 665a5ba..c2cfb92 100644
--- a/src/mesa/main/framebuffer.c
+++ b/src/mesa/main/framebuffer.c
@@ -157,6 +157,7 @@ _mesa_initialize_window_framebuffer(struct gl_framebuffer 
*fb,
fb->_Status = GL_FRAMEBUFFER_COMPLETE_EXT;
fb->_AllColorBuffersFixedPoint = !visual->floatMode;
fb->_HasSNormOrFloatColorBuffer = visual->floatMode;
+   fb->_HasAttachments = GL_TRUE;
 
compute_depth_max(fb);
 }
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 8342517..1a37aa6 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -3146,12 +3146,29 @@ struct gl_framebuffer
 */
struct gl_config Visual;
 
-   GLuint Width, Height;   /**< size of frame buffer in pixels */
+   /**
+* size of frame buffer in pixels,
+* no attachments has these values as 0
+*/
+   GLuint Width, Height;
+
+   /**
+* In the case that the framebuffer has no attachment (i.e.
+* GL_ARB_framebuffer_no_attachments) then the geometry of
+* the framebuffer is specified by the default values.
+*/
+   struct {
+ GLuint Width, Height, Layers, NumSamples;
+ GLboolean FixedSampleLocations;
+   } DefaultGeometry;
 
-   /** \name  Drawing bounds (Intersection of buffer size and scissor box) */
+   /** \name  Drawing bounds (Intersection of buffer size and scissor box)
+* The drawing region is given by [_Xmin, _Xmax) x [_Ymin, _Ymax),
+* (inclusive for _Xmin and _Ymin while exclusive for _Xmax and _Ymax)
+*/
/*@{*/
-   GLint _Xmin, _Xmax;  /**< inclusive */
-   GLint _Ymin, _Ymax;  /**< exclusive */
+   GLint _Xmin, _Xmax;
+   GLint _Ymin, _Ymax;
/*@}*/
 
/** \name  Derived Z buffer stuff */
@@ -3164,6 +3181,18 @@ struct gl_framebuffer
/** One of the GL_FRAMEBUFFER_(IN)COMPLETE_* tokens */
GLenum _Status;
 
+   /** True if one of Attachment has Type != GL_NONE
+* NOTE: the values for Width and Height are set to 0 in
+* case of no attachments, a backend driver supporting
+* GL_ARB_framebuffer_no_attachments must check for the
+* flag _HasAttachments and if GL_FALSE, must then use
+* the values in DefaultGeometry to initialize its
+* viewport, scissor and so on (in particular _Xmin,
+* _Xmax, _Ymin and _Ymax do NOT take into account
+* _HasAttachments being false)
+*/
+   GLboolean _HasAttachments;
+
/** Integer color values */
GLboolean _IntegerColor;
 
@@ -3174,7 +3203,9 @@ struct gl_framebuffer
/**
 * The maximum number of layers in the framebuffer, or 0 if the framebuffer
 * is not layered.  For cube maps and cube map arrays, each cube face
-* counts as a layer.
+* counts as a layer. As the case for Width, Height a backend driver
+* sup

[Mesa-dev] [v3 PATCH 06/10] i965: Use _mesa_geometry_ functions appropriately

2015-05-21 Thread kevin . rogovin
From: Kevin Rogovin 

Change references to gl_framebuffer::Width, Height, MaxNumLayers
and Visual::samples to use the _mesa_geometry_ convenience functions
for those places where the geometry of the gl_framebuffer is needed
(in contrast to the geometry of the intersection of the attachments
of the gl_framebuffer).

This patch is to pave the way to enable GL_ARB_framebuffer_no_attachments
on Gen7 and higher in i965. 

v1 -> v2
 Remove changes that would only be active in Gen4/5.
 Type and casting changes for consistency and readability.
 
v2 -> v3
 Updates for rebase against master

Signed-off-by: Kevin Rogovin 
---
 src/mesa/drivers/dri/i965/brw_clip_state.c |  9 ++---
 src/mesa/drivers/dri/i965/brw_misc_state.c | 10 +++---
 src/mesa/drivers/dri/i965/brw_sf_state.c   |  8 
 src/mesa/drivers/dri/i965/brw_state_upload.c   |  6 --
 src/mesa/drivers/dri/i965/brw_wm.c |  7 ---
 src/mesa/drivers/dri/i965/brw_wm_surface_state.c   | 12 +++-
 src/mesa/drivers/dri/i965/gen6_clip_state.c| 10 +++---
 src/mesa/drivers/dri/i965/gen6_multisample_state.c |  3 ++-
 src/mesa/drivers/dri/i965/gen6_scissor_state.c | 13 ++---
 src/mesa/drivers/dri/i965/gen6_sf_state.c  |  3 ++-
 src/mesa/drivers/dri/i965/gen6_viewport_state.c|  5 +++--
 src/mesa/drivers/dri/i965/gen6_wm_state.c  |  3 ++-
 src/mesa/drivers/dri/i965/gen7_sf_state.c  |  3 ++-
 src/mesa/drivers/dri/i965/gen7_viewport_state.c|  5 +++--
 src/mesa/drivers/dri/i965/gen7_wm_state.c  |  3 ++-
 src/mesa/drivers/dri/i965/gen8_viewport_state.c|  8 +---
 16 files changed, 74 insertions(+), 34 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_clip_state.c 
b/src/mesa/drivers/dri/i965/brw_clip_state.c
index 3223834..dee74db 100644
--- a/src/mesa/drivers/dri/i965/brw_clip_state.c
+++ b/src/mesa/drivers/dri/i965/brw_clip_state.c
@@ -32,6 +32,7 @@
 #include "brw_context.h"
 #include "brw_state.h"
 #include "brw_defines.h"
+#include "main/framebuffer.h"
 
 static void
 upload_clip_vp(struct brw_context *brw)
@@ -59,7 +60,9 @@ brw_upload_clip_unit(struct brw_context *brw)
struct brw_clip_unit_state *clip;
 
/* _NEW_BUFFERS */
-   struct gl_framebuffer *fb = ctx->DrawBuffer;
+   const struct gl_framebuffer *fb = ctx->DrawBuffer;
+   const float fb_width = (float)_mesa_geometric_width(fb);
+   const float fb_height = (float)_mesa_geometric_height(fb);
 
upload_clip_vp(brw);
 
@@ -127,8 +130,8 @@ brw_upload_clip_unit(struct brw_context *brw)
/* enable guardband clipping if we can */
if (ctx->ViewportArray[0].X == 0 &&
ctx->ViewportArray[0].Y == 0 &&
-   ctx->ViewportArray[0].Width == (float) fb->Width &&
-   ctx->ViewportArray[0].Height == (float) fb->Height)
+   ctx->ViewportArray[0].Width == fb_width &&
+   ctx->ViewportArray[0].Height == fb_height)
{
   clip->clip5.guard_band_enable = 1;
   clip->clip6.clipper_viewport_state_ptr =
diff --git a/src/mesa/drivers/dri/i965/brw_misc_state.c 
b/src/mesa/drivers/dri/i965/brw_misc_state.c
index 67a693b..1672786 100644
--- a/src/mesa/drivers/dri/i965/brw_misc_state.c
+++ b/src/mesa/drivers/dri/i965/brw_misc_state.c
@@ -39,6 +39,7 @@
 #include "brw_state.h"
 #include "brw_defines.h"
 
+#include "main/framebuffer.h"
 #include "main/fbobject.h"
 #include "main/glformats.h"
 
@@ -46,12 +47,15 @@
 static void upload_drawing_rect(struct brw_context *brw)
 {
struct gl_context *ctx = &brw->ctx;
+   const struct gl_framebuffer *fb = ctx->DrawBuffer;
+   const unsigned int fb_width = _mesa_geometric_width(fb);
+   const unsigned int fb_height = _mesa_geometric_height(fb);
 
BEGIN_BATCH(4);
OUT_BATCH(_3DSTATE_DRAWING_RECTANGLE << 16 | (4 - 2));
OUT_BATCH(0); /* xmin, ymin */
-   OUT_BATCH(((ctx->DrawBuffer->Width - 1) & 0x) |
-   ((ctx->DrawBuffer->Height - 1) << 16));
+   OUT_BATCH(((fb_width - 1) & 0x) |
+   ((fb_height - 1) << 16));
OUT_BATCH(0);
ADVANCE_BATCH();
 }
@@ -767,7 +771,7 @@ static void upload_polygon_stipple_offset(struct 
brw_context *brw)
 * works just fine, and there's no window system to worry about.
 */
if (_mesa_is_winsys_fbo(ctx->DrawBuffer))
-  OUT_BATCH((32 - (ctx->DrawBuffer->Height & 31)) & 31);
+  OUT_BATCH((32 - (_mesa_geometric_height(ctx->DrawBuffer) & 31)) & 31);
else
   OUT_BATCH(0);
ADVANCE_BATCH();
diff --git a/src/mesa/drivers/dri/i965/brw_sf_state.c 
b/src/mesa/drivers/dri/i965/brw_sf_state.c
index 014b434..6f9397f 100644
--- a/src/mesa/drivers/dri/i965/brw_sf_state.c
+++ b/src/mesa/drivers/dri/i965/brw_sf_state.c
@@ -52,6 +52,14 @@ static void upload_sf_vp(struct brw_context *br

[Mesa-dev] [v3 PATCH 04/10] mesa: add helper convenience functions for fetching geometry of gl_framebuffer

2015-05-21 Thread kevin . rogovin
From: Kevin Rogovin 

Add convenience helper functions for fetching geometry of gl_framebuffer
that return the geometry of the gl_framebuffer instead of the geometry of
the buffers of the gl_framebuffer when then the gl_framebuffer has no 
attachments.

v1 -> v2
 Split from patch "mesa:helper-conveniance functions for drivers to implement 
ARB_framebuffer_no_attachment".

v2 -> v3
 Add error check for functions of extension.
 Implement DSA functions dependent on extension.

Signed-off-by: Kevin Rogovin 
---
 src/mesa/main/framebuffer.h | 29 +
 src/mesa/main/mtypes.h  |  8 +++-
 2 files changed, 36 insertions(+), 1 deletion(-)

diff --git a/src/mesa/main/framebuffer.h b/src/mesa/main/framebuffer.h
index d02b86f..c402ce7 100644
--- a/src/mesa/main/framebuffer.h
+++ b/src/mesa/main/framebuffer.h
@@ -76,6 +76,35 @@ _mesa_scissor_bounding_box(const struct gl_context *ctx,
const struct gl_framebuffer *buffer,
unsigned idx, int *bbox);
 
+static inline  GLuint
+_mesa_geometric_width(const struct gl_framebuffer *buffer)
+{
+   return buffer->_HasAttachments ?
+  buffer->Width : buffer->DefaultGeometry.Width;
+}
+
+
+static inline  GLuint
+_mesa_geometric_height(const struct gl_framebuffer *buffer)
+{
+   return buffer->_HasAttachments ?
+  buffer->Height : buffer->DefaultGeometry.Height;
+}
+
+static inline  GLuint
+_mesa_geometric_samples(const struct gl_framebuffer *buffer)
+{
+   return buffer->_HasAttachments ?
+  buffer->Visual.samples : buffer->DefaultGeometry.NumSamples;
+}
+
+static inline  GLuint
+_mesa_geometric_layers(const struct gl_framebuffer *buffer)
+{
+   return buffer->_HasAttachments ?
+  buffer->MaxNumLayers : buffer->DefaultGeometry.Layers;
+}
+
 extern void 
 _mesa_update_draw_buffer_bounds(struct gl_context *ctx,
 struct gl_framebuffer *drawFb);
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 1a37aa6..7e1f0e0 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -3189,7 +3189,13 @@ struct gl_framebuffer
 * the values in DefaultGeometry to initialize its
 * viewport, scissor and so on (in particular _Xmin,
 * _Xmax, _Ymin and _Ymax do NOT take into account
-* _HasAttachments being false)
+* _HasAttachments being false). To get the geometry
+* of the framebuffer, the  helper functions
+*   _mesa_geometric_width(),
+*   _mesa_geometric_height(),
+*   _mesa_geometric_samples(),
+*   _mesa_geometric_layers()
+* are available that check _HasAttachments.
 */
GLboolean _HasAttachments;
 
-- 
1.9.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [v3 PATCH 09/10] i965: enable ARB_framebuffer_no_attachment extension for Gen7 and later

2015-05-21 Thread kevin . rogovin
From: Kevin Rogovin 

Enable GL_ARB_framebuffer_no_attachments in i965 for Gen7 and higher.

v1 -> v2
 No changes.

v2 -> v3
 intel_extensions.c: Alphabetize insertion.

Reviewed-by: Ian Romanick  (v2)
Signed-off-by: Kevin Rogovin 
---
 src/mesa/drivers/dri/i965/brw_context.c  | 6 ++
 src/mesa/drivers/dri/i965/intel_extensions.c | 1 +
 2 files changed, 7 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/brw_context.c 
b/src/mesa/drivers/dri/i965/brw_context.c
index ea56859..9401a4a 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -613,6 +613,12 @@ brw_initialize_context_constants(struct brw_context *brw)
/* ARB_gpu_shader5 */
if (brw->gen >= 7)
   ctx->Const.MaxVertexStreams = MIN2(4, MAX_VERTEX_STREAMS);
+
+   /* ARB_framebuffer_no_attachments */
+   ctx->Const.MaxFramebufferWidth = ctx->Const.MaxViewportWidth;
+   ctx->Const.MaxFramebufferHeight = ctx->Const.MaxViewportHeight;
+   ctx->Const.MaxFramebufferLayers = ctx->Const.MaxArrayTextureLayers;
+   ctx->Const.MaxFramebufferSamples = max_samples;
 }
 
 static void
diff --git a/src/mesa/drivers/dri/i965/intel_extensions.c 
b/src/mesa/drivers/dri/i965/intel_extensions.c
index 18b69a0..1f38b5a 100644
--- a/src/mesa/drivers/dri/i965/intel_extensions.c
+++ b/src/mesa/drivers/dri/i965/intel_extensions.c
@@ -326,6 +326,7 @@ intelInitExtensions(struct gl_context *ctx)
if (brw->gen >= 7) {
   ctx->Extensions.ARB_conservative_depth = true;
   ctx->Extensions.ARB_derivative_control = true;
+  ctx->Extensions.ARB_framebuffer_no_attachments = true;
   ctx->Extensions.ARB_gpu_shader5 = true;
   ctx->Extensions.ARB_shader_atomic_counters = true;
   ctx->Extensions.ARB_texture_compression_bptc = true;
-- 
1.9.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [v3 PATCH 05/10] mesa: add helper convenience functions for computing box intersected against scissors of gl_framebuffer

2015-05-21 Thread kevin . rogovin
From: Kevin Rogovin 

Add helper convenience function that intersects the scissor values
against a passed bounding box. In addition, to avoid replicated code,
make the function _mesa_scissor_bounding_box() use this new function.

v1 -> v2
 Split from patch "mesa:helper-conveniance functions for drivers to implement 
ARB_framebuffer_no_attachment".
 White space and long line fixes.

v2 -> v3
 No changes.

Signed-off-by: Kevin Rogovin 
---
 src/mesa/main/framebuffer.c | 63 +++--
 src/mesa/main/framebuffer.h |  4 +++
 2 files changed, 47 insertions(+), 20 deletions(-)

diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c
index c2cfb92..dd9e4bc 100644
--- a/src/mesa/main/framebuffer.c
+++ b/src/mesa/main/framebuffer.c
@@ -357,42 +357,38 @@ update_framebuffer_size(struct gl_context *ctx, struct 
gl_framebuffer *fb)
 }
 
 
+
 /**
- * Calculate the inclusive bounding box for the scissor of a specific viewport
+ * Given a bounding box, intersect the bounding box with the scissor of
+ * a specified vieport.
  *
  * \param ctx GL context.
- * \param buffer  Framebuffer to be checked against
  * \param idx Index of the desired viewport
  * \param bboxBounding box for the scissored viewport.  Stored as xmin,
  *xmax, ymin, ymax.
- *
- * \warning This function assumes that the framebuffer dimensions are up to
- * date (e.g., update_framebuffer_size has been recently called on \c buffer).
- *
- * \sa _mesa_clip_to_region
  */
-void
-_mesa_scissor_bounding_box(const struct gl_context *ctx,
-   const struct gl_framebuffer *buffer,
-   unsigned idx, int *bbox)
+extern void
+_mesa_intersect_scissor_bounding_box(const struct gl_context *ctx,
+ unsigned idx, int *bbox)
 {
-   bbox[0] = 0;
-   bbox[2] = 0;
-   bbox[1] = buffer->Width;
-   bbox[3] = buffer->Height;
-
if (ctx->Scissor.EnableFlags & (1u << idx)) {
+  int xmax, ymax;
+
+  xmax = ctx->Scissor.ScissorArray[idx].X
++ ctx->Scissor.ScissorArray[idx].Width;
+  ymax = ctx->Scissor.ScissorArray[idx].Y
++ ctx->Scissor.ScissorArray[idx].Height;
   if (ctx->Scissor.ScissorArray[idx].X > bbox[0]) {
  bbox[0] = ctx->Scissor.ScissorArray[idx].X;
   }
   if (ctx->Scissor.ScissorArray[idx].Y > bbox[2]) {
  bbox[2] = ctx->Scissor.ScissorArray[idx].Y;
   }
-  if (ctx->Scissor.ScissorArray[idx].X + 
ctx->Scissor.ScissorArray[idx].Width < bbox[1]) {
- bbox[1] = ctx->Scissor.ScissorArray[idx].X + 
ctx->Scissor.ScissorArray[idx].Width;
+  if (xmax < bbox[1]) {
+ bbox[1] = xmax;
   }
-  if (ctx->Scissor.ScissorArray[idx].Y + 
ctx->Scissor.ScissorArray[idx].Height < bbox[3]) {
- bbox[3] = ctx->Scissor.ScissorArray[idx].Y + 
ctx->Scissor.ScissorArray[idx].Height;
+  if (ymax < bbox[3]) {
+bbox[3] = ymax;
   }
   /* finally, check for empty region */
   if (bbox[0] > bbox[1]) {
@@ -402,6 +398,33 @@ _mesa_scissor_bounding_box(const struct gl_context *ctx,
  bbox[2] = bbox[3];
   }
}
+}
+
+/**
+ * Calculate the inclusive bounding box for the scissor of a specific viewport
+ *
+ * \param ctx GL context.
+ * \param buffer  Framebuffer to be checked against
+ * \param idx Index of the desired viewport
+ * \param bboxBounding box for the scissored viewport.  Stored as xmin,
+ *xmax, ymin, ymax.
+ *
+ * \warning This function assumes that the framebuffer dimensions are up to
+ * date (e.g., update_framebuffer_size has been recently called on \c buffer).
+ *
+ * \sa _mesa_clip_to_region
+ */
+void
+_mesa_scissor_bounding_box(const struct gl_context *ctx,
+   const struct gl_framebuffer *buffer,
+   unsigned idx, int *bbox)
+{
+   bbox[0] = 0;
+   bbox[2] = 0;
+   bbox[1] = buffer->Width;
+   bbox[3] = buffer->Height;
+
+   _mesa_intersect_scissor_bounding_box(ctx, idx, bbox);
 
assert(bbox[0] <= bbox[1]);
assert(bbox[2] <= bbox[3]);
diff --git a/src/mesa/main/framebuffer.h b/src/mesa/main/framebuffer.h
index c402ce7..bb1f2ea 100644
--- a/src/mesa/main/framebuffer.h
+++ b/src/mesa/main/framebuffer.h
@@ -76,6 +76,10 @@ _mesa_scissor_bounding_box(const struct gl_context *ctx,
const struct gl_framebuffer *buffer,
unsigned idx, int *bbox);
 
+extern void
+_mesa_intersect_scissor_bounding_box(const struct gl_context *ctx,
+ unsigned idx, int *bbox);
+
 static inline  GLuint
 _mesa_geometric_width(const struct gl_framebuffer *buffer)
 {
-- 
1.9.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [v3 PATCH 10/10] mark GL_ARB_framebuffer_no_attachments as done for i965

2015-05-21 Thread kevin . rogovin
From: Kevin Rogovin 

Mark GL_ARB_framebuffer_no_attachments as done for i965.

v1 -> v2
 File added to patch series

v2 -> v3
 docs/GL3.txt : add done mark under GLES3.1
 docs/relnotes/10.6.0.html : maintain alphabetical order 

Reviewed-by: Ian Romanick  (v2)
Signed-off-by: Kevin Rogovin 
---
 docs/GL3.txt  | 4 ++--
 docs/relnotes/10.6.0.html | 1 +
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/docs/GL3.txt b/docs/GL3.txt
index 9d56ee5..fae8253 100644
--- a/docs/GL3.txt
+++ b/docs/GL3.txt
@@ -157,7 +157,7 @@ GL 4.3, GLSL 4.30:
   GL_KHR_debug DONE (all drivers)
   GL_ARB_explicit_uniform_location DONE (all drivers that 
support GLSL)
   GL_ARB_fragment_layer_viewport   DONE (nv50, nvc0, r600, 
llvmpipe)
-  GL_ARB_framebuffer_no_attachmentsnot started
+  GL_ARB_framebuffer_no_attachmentsDONE (i965)
   GL_ARB_internalformat_query2 not started
   GL_ARB_invalidate_subdataDONE (all drivers)
   GL_ARB_multi_draw_indirect   DONE (i965, nvc0, r600, 
radeonsi, llvmpipe, softpipe)
@@ -216,7 +216,7 @@ GLES3.1, GLSL ES 3.1
   GL_ARB_compute_shaderin progress (jljusten)
   GL_ARB_draw_indirect DONE (i965, nvc0, r600, 
radeonsi, llvmpipe, softpipe)
   GL_ARB_explicit_uniform_location DONE (all drivers that 
support GLSL)
-  GL_ARB_framebuffer_no_attachmentsnot started
+  GL_ARB_framebuffer_no_attachmentsDONE (i965)
   GL_ARB_program_interface_query   DONE (all drivers)
   GL_ARB_shader_atomic_countersDONE (i965)
   GL_ARB_shader_image_load_store   in progress (curro)
diff --git a/docs/relnotes/10.6.0.html b/docs/relnotes/10.6.0.html
index 474a2c7..bc0cf8e 100644
--- a/docs/relnotes/10.6.0.html
+++ b/docs/relnotes/10.6.0.html
@@ -51,6 +51,7 @@ Note: some of the new features are only available with 
certain drivers.
 GL_ARB_direct_state_access on all drivers that support GL 2.0+
 GL_ARB_draw_indirect, GL_ARB_multi_draw_indirect on r600
 GL_ARB_draw_instanced on freedreno
+GL_ARB_framebuffer_no_attachments on i965
 GL_ARB_gpu_shader_fp64 on nvc0, softpipe
 GL_ARB_gpu_shader5 on i965/gen8+
 GL_ARB_instanced_arrays on freedreno
-- 
1.9.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [v4 PATCH 00/10] Implement extension ARB_framebuffer_no_attachments

2015-05-27 Thread Kevin Rogovin
This patch series implements:
  - the needed functionality in Mesa-core for ARB_framebuffer_no_attachments
  - implements and enables the extension i965

Kevin Rogovin (10):
  mesa: Define infrastructure for ARB_framebuffer_no_attachments
  mesa: Constants and functions for ARB_framebuffer_no_attachments
  mesa: Complete ARB_framebuffer_no_attachments in Mesa core
  mesa: add helper functions for geometry of gl_framebuffer
  mesa: helper function for scissor box of gl_framebuffer
  i965: Use _mesa_geometry_ functions appropriately
  mesa: mesa: function for testing if current frag-shader has atomics
  i965: execution of frag-shader when it has atomic buffer
  i965: enable ARB_framebuffer_no_attachments for Gen7+
  mark GL_ARB_framebuffer_no_attachments as done for i965

 docs/GL3.txt   |   4 +-
 docs/relnotes/10.7.0.html  |   4 +-
 .../glapi/gen/ARB_framebuffer_no_attachments.xml   |  32 +++
 src/mapi/glapi/gen/Makefile.am |   1 +
 src/mapi/glapi/gen/gl_API.xml  |   4 +-
 src/mesa/drivers/dri/i965/brw_clip_state.c |   9 +-
 src/mesa/drivers/dri/i965/brw_context.c|   6 +
 src/mesa/drivers/dri/i965/brw_misc_state.c |   9 +-
 src/mesa/drivers/dri/i965/brw_sf_state.c   |   6 +
 src/mesa/drivers/dri/i965/brw_state_upload.c   |   6 +-
 src/mesa/drivers/dri/i965/brw_wm.c |   7 +-
 src/mesa/drivers/dri/i965/brw_wm_surface_state.c   |  12 +-
 src/mesa/drivers/dri/i965/gen6_clip_state.c|  10 +-
 src/mesa/drivers/dri/i965/gen6_multisample_state.c |   3 +-
 src/mesa/drivers/dri/i965/gen6_scissor_state.c |  12 +-
 src/mesa/drivers/dri/i965/gen6_sf_state.c  |   3 +-
 src/mesa/drivers/dri/i965/gen6_viewport_state.c|   5 +-
 src/mesa/drivers/dri/i965/gen6_wm_state.c  |   3 +-
 src/mesa/drivers/dri/i965/gen7_sf_state.c  |   3 +-
 src/mesa/drivers/dri/i965/gen7_viewport_state.c|   5 +-
 src/mesa/drivers/dri/i965/gen7_wm_state.c  |   7 +-
 src/mesa/drivers/dri/i965/gen8_ps_state.c  |   3 +
 src/mesa/drivers/dri/i965/gen8_viewport_state.c|   8 +-
 src/mesa/drivers/dri/i965/intel_extensions.c   |   1 +
 src/mesa/main/extensions.c |   1 +
 src/mesa/main/fbobject.c   | 221 +++--
 src/mesa/main/fbobject.h   |   6 +
 src/mesa/main/framebuffer.c|  64 --
 src/mesa/main/framebuffer.h|  33 +++
 src/mesa/main/get.c|   1 +
 src/mesa/main/get_hash_params.py   |   6 +
 src/mesa/main/mtypes.h |  61 +-
 src/mesa/main/tests/dispatch_sanity.cpp|   4 +-
 33 files changed, 475 insertions(+), 85 deletions(-)
 create mode 100644 src/mapi/glapi/gen/ARB_framebuffer_no_attachments.xml

-- 
1.9.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [v4 PATCH 02/10] mesa: Constants and functions for ARB_framebuffer_no_attachments

2015-05-27 Thread Kevin Rogovin
Define the enumeration constants, function entry points and
glGet for the GL_ARB_framebuffer_no_attachments.

v2:
 Add output="true" for GetFramebufferParameteriv parameter params.
 Alphabetical insertion.  

v3:
 Implement _mesa_GetFramebufferParameteriv and _mesa_FramebufferParameteri
 as always error.

v4:
 Formatting fixes.
 Remove added documentation of how to add enums for glGet

Signed-off-by: Kevin Rogovin 
---
 .../glapi/gen/ARB_framebuffer_no_attachments.xml   | 32 ++
 src/mapi/glapi/gen/Makefile.am |  1 +
 src/mapi/glapi/gen/gl_API.xml  |  4 ++-
 src/mesa/main/fbobject.c   | 28 +++
 src/mesa/main/fbobject.h   |  6 
 src/mesa/main/get.c|  1 +
 src/mesa/main/get_hash_params.py   |  6 
 src/mesa/main/tests/dispatch_sanity.cpp|  4 +--
 8 files changed, 79 insertions(+), 3 deletions(-)
 create mode 100644 src/mapi/glapi/gen/ARB_framebuffer_no_attachments.xml

diff --git a/src/mapi/glapi/gen/ARB_framebuffer_no_attachments.xml 
b/src/mapi/glapi/gen/ARB_framebuffer_no_attachments.xml
new file mode 100644
index 000..10bdebc
--- /dev/null
+++ b/src/mapi/glapi/gen/ARB_framebuffer_no_attachments.xml
@@ -0,0 +1,32 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/mapi/glapi/gen/Makefile.am b/src/mapi/glapi/gen/Makefile.am
index adebd5c..5099f12 100644
--- a/src/mapi/glapi/gen/Makefile.am
+++ b/src/mapi/glapi/gen/Makefile.am
@@ -130,6 +130,7 @@ API_XML = \
ARB_draw_instanced.xml \
ARB_ES2_compatibility.xml \
ARB_ES3_compatibility.xml \
+   ARB_framebuffer_no_attachments.xml \
ARB_framebuffer_object.xml \
ARB_geometry_shader4.xml \
ARB_get_program_binary.xml \
diff --git a/src/mapi/glapi/gen/gl_API.xml b/src/mapi/glapi/gen/gl_API.xml
index 3090b9f..5079d30 100644
--- a/src/mapi/glapi/gen/gl_API.xml
+++ b/src/mapi/glapi/gen/gl_API.xml
@@ -8188,7 +8188,9 @@
 
 
 
-
+http://www.w3.org/2001/XInclude"/>
+
+
 
 
 
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 8fea7f8..4ac3f20 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -1335,6 +1335,34 @@ _mesa_BindRenderbufferEXT(GLenum target, GLuint 
renderbuffer)
bind_renderbuffer(target, renderbuffer, true);
 }
 
+extern void GLAPIENTRY
+_mesa_FramebufferParameteri(GLenum target, GLenum pname, GLint param)
+{
+   GET_CURRENT_CONTEXT(ctx);
+
+   (void) target;
+   (void) pname;
+   (void) param;
+
+   _mesa_error(ctx, GL_INVALID_OPERATION,
+   "glFramebufferParameteri not supported "
+   "(ARB_framebuffer_no_attachments not implemented)");
+}
+
+extern void GLAPIENTRY
+_mesa_GetFramebufferParameteriv(GLenum target, GLenum pname, GLint *params)
+{
+   GET_CURRENT_CONTEXT(ctx);
+
+   (void) target;
+   (void) pname;
+   (void) param;
+
+   _mesa_error(ctx, GL_INVALID_OPERATION,
+   "glGetNamedFramebufferParameteriv not supported "
+   "(ARB_framebuffer_no_attachments not implemented)");
+}
+
 
 /**
  * Remove the specified renderbuffer or texture from any attachment point in
diff --git a/src/mesa/main/fbobject.h b/src/mesa/main/fbobject.h
index 9f570db..8dad0ff 100644
--- a/src/mesa/main/fbobject.h
+++ b/src/mesa/main/fbobject.h
@@ -288,4 +288,10 @@ extern void GLAPIENTRY
 _mesa_DiscardFramebufferEXT(GLenum target, GLsizei numAttachments,
 const GLenum *attachments);
 
+extern void GLAPIENTRY
+_mesa_FramebufferParameteri(GLenum target, GLenum pname, GLint param);
+
+extern void GLAPIENTRY
+_mesa_GetFramebufferParameteriv(GLenum target, GLenum pname, GLint *params);
+
 #endif /* FBOBJECT_H */
diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
index 8a6c81a..6290096 100644
--- a/src/mesa/main/get.c
+++ b/src/mesa/main/get.c
@@ -393,6 +393,7 @@ EXTRA_EXT(INTEL_performance_query);
 EXTRA_EXT(ARB_explicit_uniform_location);
 EXTRA_EXT(ARB_clip_control);
 EXTRA_EXT(EXT_polygon_offset_clamp);
+EXTRA_EXT(ARB_framebuffer_no_attachments);
 
 static const int
 extra_ARB_color_buffer_float_or_glcore[] = {
diff --git a/src/mesa/main/get_hash_params.py b/src/mesa/main/get_hash_params.py
index 41cb2c1..4d30cee 100644
--- a/src/mesa/main/get_hash_params.py
+++ b/src/mesa/main/get_hash_params.py
@@ -798,6 +798,12 @@ descriptor=[
   [ "MIN_FRAGMENT_INTERPOLATION_OFFSET", 
"CONTEXT_FLOAT(Const.MinFragmentInterpolationOffset), extra_ARB_gpu_shader5" ],
   [ "MAX_FRAGMENT_INTERPOLATION_OFFSET", 
"CONTEXT_FLOAT(Const.MaxFragmentInterpolationOffset), extra_ARB_gpu_shader5" ],
   [ "FRAGMENT_INTERPOLATION_OFFSET_BITS", 
"CONST(FRAGMENT_INTERPOLATION_OFFSET_BITS), extra_ARB_gpu_shader5" ],
+
+# GL_ARB_framebuffer_no_a

[Mesa-dev] [v4 PATCH 05/10] mesa: helper function for scissor box of gl_framebuffer

2015-05-27 Thread Kevin Rogovin
Add helper convenience function that intersects the scissor values
against a passed bounding box. In addition, to avoid replicated code,
make the function _mesa_scissor_bounding_box() use this new function.

v2:
 Split from patch "mesa:helper-conveniance functions for drivers to implement 
ARB_framebuffer_no_attachment".
 White space and long line fixes.

v3:
 No changes.

v4:
 No changes.


Signed-off-by: Kevin Rogovin 
---
 src/mesa/main/framebuffer.c | 63 +++--
 src/mesa/main/framebuffer.h |  5 
 2 files changed, 48 insertions(+), 20 deletions(-)

diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c
index c2cfb92..dd9e4bc 100644
--- a/src/mesa/main/framebuffer.c
+++ b/src/mesa/main/framebuffer.c
@@ -357,42 +357,38 @@ update_framebuffer_size(struct gl_context *ctx, struct 
gl_framebuffer *fb)
 }
 
 
+
 /**
- * Calculate the inclusive bounding box for the scissor of a specific viewport
+ * Given a bounding box, intersect the bounding box with the scissor of
+ * a specified vieport.
  *
  * \param ctx GL context.
- * \param buffer  Framebuffer to be checked against
  * \param idx Index of the desired viewport
  * \param bboxBounding box for the scissored viewport.  Stored as xmin,
  *xmax, ymin, ymax.
- *
- * \warning This function assumes that the framebuffer dimensions are up to
- * date (e.g., update_framebuffer_size has been recently called on \c buffer).
- *
- * \sa _mesa_clip_to_region
  */
-void
-_mesa_scissor_bounding_box(const struct gl_context *ctx,
-   const struct gl_framebuffer *buffer,
-   unsigned idx, int *bbox)
+extern void
+_mesa_intersect_scissor_bounding_box(const struct gl_context *ctx,
+ unsigned idx, int *bbox)
 {
-   bbox[0] = 0;
-   bbox[2] = 0;
-   bbox[1] = buffer->Width;
-   bbox[3] = buffer->Height;
-
if (ctx->Scissor.EnableFlags & (1u << idx)) {
+  int xmax, ymax;
+
+  xmax = ctx->Scissor.ScissorArray[idx].X
++ ctx->Scissor.ScissorArray[idx].Width;
+  ymax = ctx->Scissor.ScissorArray[idx].Y
++ ctx->Scissor.ScissorArray[idx].Height;
   if (ctx->Scissor.ScissorArray[idx].X > bbox[0]) {
  bbox[0] = ctx->Scissor.ScissorArray[idx].X;
   }
   if (ctx->Scissor.ScissorArray[idx].Y > bbox[2]) {
  bbox[2] = ctx->Scissor.ScissorArray[idx].Y;
   }
-  if (ctx->Scissor.ScissorArray[idx].X + 
ctx->Scissor.ScissorArray[idx].Width < bbox[1]) {
- bbox[1] = ctx->Scissor.ScissorArray[idx].X + 
ctx->Scissor.ScissorArray[idx].Width;
+  if (xmax < bbox[1]) {
+ bbox[1] = xmax;
   }
-  if (ctx->Scissor.ScissorArray[idx].Y + 
ctx->Scissor.ScissorArray[idx].Height < bbox[3]) {
- bbox[3] = ctx->Scissor.ScissorArray[idx].Y + 
ctx->Scissor.ScissorArray[idx].Height;
+  if (ymax < bbox[3]) {
+bbox[3] = ymax;
   }
   /* finally, check for empty region */
   if (bbox[0] > bbox[1]) {
@@ -402,6 +398,33 @@ _mesa_scissor_bounding_box(const struct gl_context *ctx,
  bbox[2] = bbox[3];
   }
}
+}
+
+/**
+ * Calculate the inclusive bounding box for the scissor of a specific viewport
+ *
+ * \param ctx GL context.
+ * \param buffer  Framebuffer to be checked against
+ * \param idx Index of the desired viewport
+ * \param bboxBounding box for the scissored viewport.  Stored as xmin,
+ *xmax, ymin, ymax.
+ *
+ * \warning This function assumes that the framebuffer dimensions are up to
+ * date (e.g., update_framebuffer_size has been recently called on \c buffer).
+ *
+ * \sa _mesa_clip_to_region
+ */
+void
+_mesa_scissor_bounding_box(const struct gl_context *ctx,
+   const struct gl_framebuffer *buffer,
+   unsigned idx, int *bbox)
+{
+   bbox[0] = 0;
+   bbox[2] = 0;
+   bbox[1] = buffer->Width;
+   bbox[3] = buffer->Height;
+
+   _mesa_intersect_scissor_bounding_box(ctx, idx, bbox);
 
assert(bbox[0] <= bbox[1]);
assert(bbox[2] <= bbox[3]);
diff --git a/src/mesa/main/framebuffer.h b/src/mesa/main/framebuffer.h
index 8b2aa34..bb1f2ea 100644
--- a/src/mesa/main/framebuffer.h
+++ b/src/mesa/main/framebuffer.h
@@ -76,6 +76,10 @@ _mesa_scissor_bounding_box(const struct gl_context *ctx,
const struct gl_framebuffer *buffer,
unsigned idx, int *bbox);
 
+extern void
+_mesa_intersect_scissor_bounding_box(const struct gl_context *ctx,
+ unsigned idx, int *bbox);
+
 static inline  GLuint
 _mesa_geometric_width(const struct gl_framebuffer *buffer)
 {
@@ -83,6 +87,7 @@ _mesa_geometric_width(const struct gl_framebuffer *buffer)
   buffer->Width : buffer->DefaultGeometry.Width;
 }
 
+
 static inline  GLuint
 _mesa_geometric_height

[Mesa-dev] [v4 PATCH 04/10] mesa: add helper functions for geometry of gl_framebuffer

2015-05-27 Thread Kevin Rogovin
Add convenience helper functions for fetching geometry of gl_framebuffer
that return the geometry of the gl_framebuffer instead of the geometry of
the buffers of the gl_framebuffer when then the gl_framebuffer has no 
attachments.

v2:
 Split from patch "mesa:helper-conveniance functions for drivers to implement 
ARB_framebuffer_no_attachment".

v3:
 Add error check for functions of extension.
 Implement DSA functions dependent on extension.

v4:
 Formatting fixes.

Signed-off-by: Kevin Rogovin 
---
 src/mesa/main/framebuffer.h | 28 
 src/mesa/main/mtypes.h  |  8 +++-
 2 files changed, 35 insertions(+), 1 deletion(-)

diff --git a/src/mesa/main/framebuffer.h b/src/mesa/main/framebuffer.h
index d02b86f..8b2aa34 100644
--- a/src/mesa/main/framebuffer.h
+++ b/src/mesa/main/framebuffer.h
@@ -76,6 +76,34 @@ _mesa_scissor_bounding_box(const struct gl_context *ctx,
const struct gl_framebuffer *buffer,
unsigned idx, int *bbox);
 
+static inline  GLuint
+_mesa_geometric_width(const struct gl_framebuffer *buffer)
+{
+   return buffer->_HasAttachments ?
+  buffer->Width : buffer->DefaultGeometry.Width;
+}
+
+static inline  GLuint
+_mesa_geometric_height(const struct gl_framebuffer *buffer)
+{
+   return buffer->_HasAttachments ?
+  buffer->Height : buffer->DefaultGeometry.Height;
+}
+
+static inline  GLuint
+_mesa_geometric_samples(const struct gl_framebuffer *buffer)
+{
+   return buffer->_HasAttachments ?
+  buffer->Visual.samples : buffer->DefaultGeometry.NumSamples;
+}
+
+static inline  GLuint
+_mesa_geometric_layers(const struct gl_framebuffer *buffer)
+{
+   return buffer->_HasAttachments ?
+  buffer->MaxNumLayers : buffer->DefaultGeometry.Layers;
+}
+
 extern void 
 _mesa_update_draw_buffer_bounds(struct gl_context *ctx,
 struct gl_framebuffer *drawFb);
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 5abbc0a..08316dc 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -3187,7 +3187,13 @@ struct gl_framebuffer
 * GL_ARB_framebuffer_no_attachments must check for the flag _HasAttachments
 * and if GL_FALSE, must then use the values in DefaultGeometry to 
initialize
 * its viewport, scissor and so on (in particular _Xmin, _Xmax, _Ymin and
-* _Ymax do NOT take into account _HasAttachments being false)
+* _Ymax do NOT take into account _HasAttachments being false). To get the
+* geometry of the framebuffer, the  helper functions
+*   _mesa_geometric_width(),
+*   _mesa_geometric_height(),
+*   _mesa_geometric_samples() and
+*   _mesa_geometric_layers()
+* are available that check _HasAttachments.
 */
GLboolean _HasAttachments;
 
-- 
1.9.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [v4 PATCH 08/10] i965: execution of frag-shader when it has atomic buffer

2015-05-27 Thread Kevin Rogovin
Ensure that the GPU spawns the fragment shader thread for those
fragment shaders with atomic buffer access.

v2:
 No change.

v3:
 Use utility function _mesa_active_fragment_shader_has_atomic_ops().

v4:
 Formatting fixes.

Reviewed-by: Tapani Pälli  (v1)
Signed-off-by: Kevin Rogovin 
---
 src/mesa/drivers/dri/i965/gen7_wm_state.c | 4 
 src/mesa/drivers/dri/i965/gen8_ps_state.c | 3 +++
 2 files changed, 7 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/gen7_wm_state.c 
b/src/mesa/drivers/dri/i965/gen7_wm_state.c
index 1c47076..ea11ae8 100644
--- a/src/mesa/drivers/dri/i965/gen7_wm_state.c
+++ b/src/mesa/drivers/dri/i965/gen7_wm_state.c
@@ -77,6 +77,10 @@ upload_wm_state(struct brw_context *brw)
   dw1 |= GEN7_WM_KILL_ENABLE;
}
 
+   if (_mesa_active_fragment_shader_has_atomic_ops(&brw->ctx)) {
+  dw1 |= GEN7_WM_DISPATCH_ENABLE;
+   }
+
/* _NEW_BUFFERS | _NEW_COLOR */
if (brw_color_buffer_write_enabled(brw) || writes_depth ||
dw1 & GEN7_WM_KILL_ENABLE) {
diff --git a/src/mesa/drivers/dri/i965/gen8_ps_state.c 
b/src/mesa/drivers/dri/i965/gen8_ps_state.c
index 85ad3b6..b9cae50 100644
--- a/src/mesa/drivers/dri/i965/gen8_ps_state.c
+++ b/src/mesa/drivers/dri/i965/gen8_ps_state.c
@@ -58,6 +58,9 @@ gen8_upload_ps_extra(struct brw_context *brw,
if (prog_data->uses_omask)
   dw1 |= GEN8_PSX_OMASK_TO_RENDER_TARGET;
 
+   if (_mesa_active_fragment_shader_has_atomic_ops(&brw->ctx))
+  dw1 |= GEN8_PSX_SHADER_HAS_UAV;
+
BEGIN_BATCH(2);
OUT_BATCH(_3DSTATE_PS_EXTRA << 16 | (2 - 2));
OUT_BATCH(dw1);
-- 
1.9.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [v4 PATCH 09/10] i965: enable ARB_framebuffer_no_attachments for Gen7+

2015-05-27 Thread Kevin Rogovin
Enable GL_ARB_framebuffer_no_attachments in i965 for Gen7 and higher.

v2:
 No changes.

v3:
 intel_extensions.c: Alphabetize insertion.

v4:
 No changes.

Reviewed-by: Ian Romanick  (v2)
Signed-off-by: Kevin Rogovin 
---
 src/mesa/drivers/dri/i965/brw_context.c  | 6 ++
 src/mesa/drivers/dri/i965/intel_extensions.c | 1 +
 2 files changed, 7 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/brw_context.c 
b/src/mesa/drivers/dri/i965/brw_context.c
index ea56859..9401a4a 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -613,6 +613,12 @@ brw_initialize_context_constants(struct brw_context *brw)
/* ARB_gpu_shader5 */
if (brw->gen >= 7)
   ctx->Const.MaxVertexStreams = MIN2(4, MAX_VERTEX_STREAMS);
+
+   /* ARB_framebuffer_no_attachments */
+   ctx->Const.MaxFramebufferWidth = ctx->Const.MaxViewportWidth;
+   ctx->Const.MaxFramebufferHeight = ctx->Const.MaxViewportHeight;
+   ctx->Const.MaxFramebufferLayers = ctx->Const.MaxArrayTextureLayers;
+   ctx->Const.MaxFramebufferSamples = max_samples;
 }
 
 static void
diff --git a/src/mesa/drivers/dri/i965/intel_extensions.c 
b/src/mesa/drivers/dri/i965/intel_extensions.c
index 18b69a0..1f38b5a 100644
--- a/src/mesa/drivers/dri/i965/intel_extensions.c
+++ b/src/mesa/drivers/dri/i965/intel_extensions.c
@@ -326,6 +326,7 @@ intelInitExtensions(struct gl_context *ctx)
if (brw->gen >= 7) {
   ctx->Extensions.ARB_conservative_depth = true;
   ctx->Extensions.ARB_derivative_control = true;
+  ctx->Extensions.ARB_framebuffer_no_attachments = true;
   ctx->Extensions.ARB_gpu_shader5 = true;
   ctx->Extensions.ARB_shader_atomic_counters = true;
   ctx->Extensions.ARB_texture_compression_bptc = true;
-- 
1.9.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [v4 PATCH 03/10] mesa: Complete ARB_framebuffer_no_attachments in Mesa core

2015-05-27 Thread Kevin Rogovin
Implement GL_ARB_framebuffer_no_attachments in Mesa core
 - changes to conditions for framebuffer completenss
 - implement set/get functions for framebuffers for 
   new functions in GL_ARB_framebuffer_no_attachments

v2:
 Spacing and exceed 80 characters per line fixes.

v3:
 Implement DSA functions of extension. 

v4:
 Formatting fixes.
 Add early return to functions when extension(s) not present.

Signed-off-by: Kevin Rogovin 
---
 src/mesa/main/fbobject.c | 220 ---
 1 file changed, 187 insertions(+), 33 deletions(-)

diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 4ac3f20..f9858ad 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -1156,14 +1156,48 @@ _mesa_test_framebuffer_completeness(struct gl_context 
*ctx,
   } else if (att_layer_count > max_layer_count) {
  max_layer_count = att_layer_count;
   }
+
+  /**
+   * The extension GL_ARB_framebuffer_no_attachments places additional
+   * requirement on each attachment. Those additional requirements are
+   * tighter that those of previous versions of GL. In interest of better
+   * compatibility, we will not enforce these restrictions. For the record
+   * those additional restrictions are quoted below:
+   *
+   * "The width and height of image are greater than zero and less than or
+   *  equal to the values of the implementation-dependent limits
+   *  MAX_FRAMEBUFFER_WIDTH and MAX_FRAMEBUFFER_HEIGHT, respectively."
+   *
+   * "If  is a three-dimensional texture or a one- or 
two-dimensional
+   *  array texture and the attachment is layered, the depth or layer count
+   *  of the texture is less than or equal to the implementation-dependent
+   *  limit MAX_FRAMEBUFFER_LAYERS."
+   *
+   * "If image has multiple samples, its sample count is less than or equal
+   *  to the value of the implementation-dependent limit
+   *  MAX_FRAMEBUFFER_SAMPLES."
+   *
+   * The same requirements are also in place for GL 4.5,
+   * Section 9.4.1 "Framebuffer Attachment Completeness", pg 310-311
+   */
}
 
fb->MaxNumLayers = max_layer_count;
 
if (numImages == 0) {
-  fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT;
-  fbo_incomplete(ctx, "no attachments", -1);
-  return;
+  fb->_HasAttachments = GL_FALSE;
+
+  if (!ctx->Extensions.ARB_framebuffer_no_attachments) {
+ fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT;
+ fbo_incomplete(ctx, "no attachments", -1);
+ return;
+  }
+
+  if (fb->DefaultGeometry.Width == 0 || fb->DefaultGeometry.Height == 0) {
+ fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT;
+ fbo_incomplete(ctx, "no attachments and default width or height is 
0", -1);
+ return;
+  }
}
 
if (_mesa_is_desktop_gl(ctx) && !ctx->Extensions.ARB_ES2_compatibility) {
@@ -1228,8 +1262,10 @@ _mesa_test_framebuffer_completeness(struct gl_context 
*ctx,
* renderbuffers/textures are different sizes, the framebuffer
* width/height will be set to the smallest width/height.
*/
-  fb->Width = minWidth;
-  fb->Height = minHeight;
+  if (numImages != 0) {
+ fb->Width = minWidth;
+ fb->Height = minHeight;
+  }
 
   /* finally, update the visual info for the framebuffer */
   _mesa_update_framebuffer_visual(ctx, fb);
@@ -1335,32 +1371,129 @@ _mesa_BindRenderbufferEXT(GLenum target, GLuint 
renderbuffer)
bind_renderbuffer(target, renderbuffer, true);
 }
 
-extern void GLAPIENTRY
+static void
+framebuffer_parameteri(struct gl_context *ctx, struct gl_framebuffer *fb,
+   GLenum pname, GLint param, const char *func)
+{
+   switch (pname) {
+   case GL_FRAMEBUFFER_DEFAULT_WIDTH:
+  if (param < 0 || param > ctx->Const.MaxFramebufferWidth)
+_mesa_error(ctx, GL_INVALID_VALUE, "%s", func);
+  else
+ fb->DefaultGeometry.Width = param;
+  break;
+   case GL_FRAMEBUFFER_DEFAULT_HEIGHT:
+  if (param < 0 || param > ctx->Const.MaxFramebufferHeight)
+_mesa_error(ctx, GL_INVALID_VALUE, "%s", func);
+  else
+ fb->DefaultGeometry.Height = param;
+  break;
+   case GL_FRAMEBUFFER_DEFAULT_LAYERS:
+  if (param < 0 || param > ctx->Const.MaxFramebufferLayers)
+_mesa_error(ctx, GL_INVALID_VALUE, "%s", func);
+  else
+ fb->DefaultGeometry.Layers = param;
+  break;
+   case GL_FRAMEBUFFER_DEFAULT_SAMPLES:
+  if (param < 0 || param > ctx->Const.MaxFramebufferSamples)
+_mesa_error(ctx, GL_INVALID_VALUE, "%s", func);
+  else
+fb->DefaultGeometry.NumSa

[Mesa-dev] [v4 PATCH 01/10] mesa: Define infrastructure for ARB_framebuffer_no_attachments

2015-05-27 Thread Kevin Rogovin
Define the infrastructure for the extension GL_ARB_framebuffer_no_attachments:
 - extension table
 - additions to gl_framebuffer

v2:
 Formatting fixes.

v3:
 mtypes.h: Correct comment on _HasAttachments.

v4:
 Formatting fixes.
 mtypes.h: Clarify comments
 

Signed-off-by: Kevin Rogovin 
---
 src/mesa/main/extensions.c  |  1 +
 src/mesa/main/fbobject.c|  1 +
 src/mesa/main/framebuffer.c |  1 +
 src/mesa/main/mtypes.h  | 48 -
 4 files changed, 46 insertions(+), 5 deletions(-)

diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c
index c82416a..3256b2c 100644
--- a/src/mesa/main/extensions.c
+++ b/src/mesa/main/extensions.c
@@ -117,6 +117,7 @@ static const struct extension extension_table[] = {
{ "GL_ARB_fragment_program",o(ARB_fragment_program),
GLL,2002 },
{ "GL_ARB_fragment_program_shadow", 
o(ARB_fragment_program_shadow), GLL,2003 },
{ "GL_ARB_fragment_shader", o(ARB_fragment_shader), 
GL, 2002 },
+   { "GL_ARB_framebuffer_no_attachments",  
o(ARB_framebuffer_no_attachments),  GL, 2012 },
{ "GL_ARB_framebuffer_object",  o(ARB_framebuffer_object),  
GL, 2005 },
{ "GL_ARB_framebuffer_sRGB",o(EXT_framebuffer_sRGB),
GL, 1998 },
{ "GL_ARB_get_program_binary",  o(dummy_true),  
GL, 2010 },
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 1859c27..8fea7f8 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -957,6 +957,7 @@ _mesa_test_framebuffer_completeness(struct gl_context *ctx,
fb->Height = 0;
fb->_AllColorBuffersFixedPoint = GL_TRUE;
fb->_HasSNormOrFloatColorBuffer = GL_FALSE;
+   fb->_HasAttachments = GL_TRUE;
 
/* Start at -2 to more easily loop over all attachment points.
 *  -2: depth buffer
diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c
index 665a5ba..c2cfb92 100644
--- a/src/mesa/main/framebuffer.c
+++ b/src/mesa/main/framebuffer.c
@@ -157,6 +157,7 @@ _mesa_initialize_window_framebuffer(struct gl_framebuffer 
*fb,
fb->_Status = GL_FRAMEBUFFER_COMPLETE_EXT;
fb->_AllColorBuffersFixedPoint = !visual->floatMode;
fb->_HasSNormOrFloatColorBuffer = visual->floatMode;
+   fb->_HasAttachments = GL_TRUE;
 
compute_depth_max(fb);
 }
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 8342517..5abbc0a 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -3146,12 +3146,29 @@ struct gl_framebuffer
 */
struct gl_config Visual;
 
-   GLuint Width, Height;   /**< size of frame buffer in pixels */
+   /**
+* Size of frame buffer in pixels. If there are no attachments, then both
+* of these are 0.
+*/
+   GLuint Width, Height;
+
+   /**
+* In the case that the framebuffer has no attachment (i.e.
+* GL_ARB_framebuffer_no_attachments) then the geometry of
+* the framebuffer is specified by the default values.
+*/
+   struct {
+ GLuint Width, Height, Layers, NumSamples;
+ GLboolean FixedSampleLocations;
+   } DefaultGeometry;
 
-   /** \name  Drawing bounds (Intersection of buffer size and scissor box) */
+   /** \name  Drawing bounds (Intersection of buffer size and scissor box)
+* The drawing region is given by [_Xmin, _Xmax) x [_Ymin, _Ymax),
+* (inclusive for _Xmin and _Ymin while exclusive for _Xmax and _Ymax)
+*/
/*@{*/
-   GLint _Xmin, _Xmax;  /**< inclusive */
-   GLint _Ymin, _Ymax;  /**< exclusive */
+   GLint _Xmin, _Xmax;
+   GLint _Ymin, _Ymax;
/*@}*/
 
/** \name  Derived Z buffer stuff */
@@ -3164,6 +3181,16 @@ struct gl_framebuffer
/** One of the GL_FRAMEBUFFER_(IN)COMPLETE_* tokens */
GLenum _Status;
 
+   /** Whether one of Attachment has Type != GL_NONE
+* NOTE: the values for Width and Height are set to 0 in case of having
+* no attachments, a backend driver supporting the extension
+* GL_ARB_framebuffer_no_attachments must check for the flag _HasAttachments
+* and if GL_FALSE, must then use the values in DefaultGeometry to 
initialize
+* its viewport, scissor and so on (in particular _Xmin, _Xmax, _Ymin and
+* _Ymax do NOT take into account _HasAttachments being false)
+*/
+   GLboolean _HasAttachments;
+
/** Integer color values */
GLboolean _IntegerColor;
 
@@ -3174,7 +3201,9 @@ struct gl_framebuffer
/**
 * The maximum number of layers in the framebuffer, or 0 if the framebuffer
 * is not layered.  For cube maps and cube map arrays, each cube face
-* counts as a layer.
+* counts as a layer. As the case for Width, Height a b

[Mesa-dev] [v4 PATCH 10/10] mark GL_ARB_framebuffer_no_attachments as done for i965

2015-05-27 Thread Kevin Rogovin
Mark GL_ARB_framebuffer_no_attachments as done for i965.

v2:
 File added to patch series

v3:
 docs/GL3.txt : add done mark under GLES3.1
 docs/relnotes/10.6.0.html : maintain alphabetical order 

v4:
 Move mark from 10.6.0.html to 10.7.0.html.

Reviewed-by: Ian Romanick  (v2)
Signed-off-by: Kevin Rogovin 
---
 docs/GL3.txt  | 4 ++--
 docs/relnotes/10.7.0.html | 4 +++-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/docs/GL3.txt b/docs/GL3.txt
index 9d56ee5..fae8253 100644
--- a/docs/GL3.txt
+++ b/docs/GL3.txt
@@ -157,7 +157,7 @@ GL 4.3, GLSL 4.30:
   GL_KHR_debug DONE (all drivers)
   GL_ARB_explicit_uniform_location DONE (all drivers that 
support GLSL)
   GL_ARB_fragment_layer_viewport   DONE (nv50, nvc0, r600, 
llvmpipe)
-  GL_ARB_framebuffer_no_attachmentsnot started
+  GL_ARB_framebuffer_no_attachmentsDONE (i965)
   GL_ARB_internalformat_query2 not started
   GL_ARB_invalidate_subdataDONE (all drivers)
   GL_ARB_multi_draw_indirect   DONE (i965, nvc0, r600, 
radeonsi, llvmpipe, softpipe)
@@ -216,7 +216,7 @@ GLES3.1, GLSL ES 3.1
   GL_ARB_compute_shaderin progress (jljusten)
   GL_ARB_draw_indirect DONE (i965, nvc0, r600, 
radeonsi, llvmpipe, softpipe)
   GL_ARB_explicit_uniform_location DONE (all drivers that 
support GLSL)
-  GL_ARB_framebuffer_no_attachmentsnot started
+  GL_ARB_framebuffer_no_attachmentsDONE (i965)
   GL_ARB_program_interface_query   DONE (all drivers)
   GL_ARB_shader_atomic_countersDONE (i965)
   GL_ARB_shader_image_load_store   in progress (curro)
diff --git a/docs/relnotes/10.7.0.html b/docs/relnotes/10.7.0.html
index 6206716..fbf07df 100644
--- a/docs/relnotes/10.7.0.html
+++ b/docs/relnotes/10.7.0.html
@@ -43,7 +43,9 @@ TBD.
 Note: some of the new features are only available with certain drivers.
 
 
-TBD.
+
+GL_ARB_framebuffer_no_attachments on i965
+
 
 Bug fixes
 
-- 
1.9.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [v4 PATCH 07/10] mesa: function for testing if current frag-shader has atomics

2015-05-27 Thread Kevin Rogovin
Add helper function that checks if current fragment shader active
of gl_context has atomic buffer access.

v3:
 Added in v3 of patch series.

v4:
 Formatting fixes.

Signed-off-by: Kevin Rogovin 
---
 src/mesa/main/mtypes.h | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 08316dc..4edba00 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -4462,7 +4462,12 @@ enum _debug
DEBUG_INCOMPLETE_FBO = (1 << 3)
 };
 
-
+static inline bool
+_mesa_active_fragment_shader_has_atomic_ops(const struct gl_context *ctx)
+{
+   return ctx->Shader._CurrentFragmentProgram != NULL &&
+  ctx->Shader._CurrentFragmentProgram->NumAtomicBuffers > 0;
+}
 
 #ifdef __cplusplus
 }
-- 
1.9.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [v4 PATCH 06/10] i965: Use _mesa_geometry_ functions appropriately

2015-05-27 Thread Kevin Rogovin
Change references to gl_framebuffer::Width, Height, MaxNumLayers
and Visual::samples to use the _mesa_geometry_ convenience functions
for those places where the geometry of the gl_framebuffer is needed
(in contrast to the geometry of the intersection of the attachments
of the gl_framebuffer).

This patch is to pave the way to enable GL_ARB_framebuffer_no_attachments
on Gen7 and higher in i965. 

v2:
 Remove changes that would only be active in Gen4/5.
 Type and casting changes for consistency and readability.
 
v3:
 Updates for rebase against master.

v4:
 Use unsigned int inplace of int and remove casts to int.
 Formatting fixes.

Signed-off-by: Kevin Rogovin 
---
 src/mesa/drivers/dri/i965/brw_clip_state.c |  9 ++---
 src/mesa/drivers/dri/i965/brw_misc_state.c |  9 ++---
 src/mesa/drivers/dri/i965/brw_sf_state.c   |  6 ++
 src/mesa/drivers/dri/i965/brw_state_upload.c   |  6 --
 src/mesa/drivers/dri/i965/brw_wm.c |  7 ---
 src/mesa/drivers/dri/i965/brw_wm_surface_state.c   | 12 +++-
 src/mesa/drivers/dri/i965/gen6_clip_state.c| 10 +++---
 src/mesa/drivers/dri/i965/gen6_multisample_state.c |  3 ++-
 src/mesa/drivers/dri/i965/gen6_scissor_state.c | 12 +---
 src/mesa/drivers/dri/i965/gen6_sf_state.c  |  3 ++-
 src/mesa/drivers/dri/i965/gen6_viewport_state.c|  5 +++--
 src/mesa/drivers/dri/i965/gen6_wm_state.c  |  3 ++-
 src/mesa/drivers/dri/i965/gen7_sf_state.c  |  3 ++-
 src/mesa/drivers/dri/i965/gen7_viewport_state.c|  5 +++--
 src/mesa/drivers/dri/i965/gen7_wm_state.c  |  3 ++-
 src/mesa/drivers/dri/i965/gen8_viewport_state.c|  8 +---
 16 files changed, 70 insertions(+), 34 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_clip_state.c 
b/src/mesa/drivers/dri/i965/brw_clip_state.c
index 3223834..dee74db 100644
--- a/src/mesa/drivers/dri/i965/brw_clip_state.c
+++ b/src/mesa/drivers/dri/i965/brw_clip_state.c
@@ -32,6 +32,7 @@
 #include "brw_context.h"
 #include "brw_state.h"
 #include "brw_defines.h"
+#include "main/framebuffer.h"
 
 static void
 upload_clip_vp(struct brw_context *brw)
@@ -59,7 +60,9 @@ brw_upload_clip_unit(struct brw_context *brw)
struct brw_clip_unit_state *clip;
 
/* _NEW_BUFFERS */
-   struct gl_framebuffer *fb = ctx->DrawBuffer;
+   const struct gl_framebuffer *fb = ctx->DrawBuffer;
+   const float fb_width = (float)_mesa_geometric_width(fb);
+   const float fb_height = (float)_mesa_geometric_height(fb);
 
upload_clip_vp(brw);
 
@@ -127,8 +130,8 @@ brw_upload_clip_unit(struct brw_context *brw)
/* enable guardband clipping if we can */
if (ctx->ViewportArray[0].X == 0 &&
ctx->ViewportArray[0].Y == 0 &&
-   ctx->ViewportArray[0].Width == (float) fb->Width &&
-   ctx->ViewportArray[0].Height == (float) fb->Height)
+   ctx->ViewportArray[0].Width == fb_width &&
+   ctx->ViewportArray[0].Height == fb_height)
{
   clip->clip5.guard_band_enable = 1;
   clip->clip6.clipper_viewport_state_ptr =
diff --git a/src/mesa/drivers/dri/i965/brw_misc_state.c 
b/src/mesa/drivers/dri/i965/brw_misc_state.c
index 67a693b..5a4515b 100644
--- a/src/mesa/drivers/dri/i965/brw_misc_state.c
+++ b/src/mesa/drivers/dri/i965/brw_misc_state.c
@@ -39,6 +39,7 @@
 #include "brw_state.h"
 #include "brw_defines.h"
 
+#include "main/framebuffer.h"
 #include "main/fbobject.h"
 #include "main/glformats.h"
 
@@ -46,12 +47,14 @@
 static void upload_drawing_rect(struct brw_context *brw)
 {
struct gl_context *ctx = &brw->ctx;
+   const struct gl_framebuffer *fb = ctx->DrawBuffer;
+   const unsigned int fb_width = _mesa_geometric_width(fb);
+   const unsigned int fb_height = _mesa_geometric_height(fb);
 
BEGIN_BATCH(4);
OUT_BATCH(_3DSTATE_DRAWING_RECTANGLE << 16 | (4 - 2));
OUT_BATCH(0); /* xmin, ymin */
-   OUT_BATCH(((ctx->DrawBuffer->Width - 1) & 0x) |
-   ((ctx->DrawBuffer->Height - 1) << 16));
+   OUT_BATCH(((fb_width - 1) & 0x) | ((fb_height - 1) << 16));
OUT_BATCH(0);
ADVANCE_BATCH();
 }
@@ -767,7 +770,7 @@ static void upload_polygon_stipple_offset(struct 
brw_context *brw)
 * works just fine, and there's no window system to worry about.
 */
if (_mesa_is_winsys_fbo(ctx->DrawBuffer))
-  OUT_BATCH((32 - (ctx->DrawBuffer->Height & 31)) & 31);
+  OUT_BATCH((32 - (_mesa_geometric_height(ctx->DrawBuffer) & 31)) & 31);
else
   OUT_BATCH(0);
ADVANCE_BATCH();
diff --git a/src/mesa/drivers/dri/i965/brw_sf_state.c 
b/src/mesa/drivers/dri/i965/brw_sf_state.c
index 014b434..5d98922 100644
--- a/src/mesa/drivers/dri/i965/brw_sf_state.c
+++ b/src/mesa/drivers/dri/i965/brw_sf_state.c
@@ -52,6 +52,12 @@ static void upload_sf_vp(s

[Mesa-dev] [PATCH] i965: Fix intel_miptree_copy_teximage for GL_TEXTURE_1D_ARRAY

2015-04-23 Thread kevin . rogovin
From: Noone 

For GL_TEXTURE_1D_ARRAY targets we store the depth of the array
in the Height field and leave Depth=1 in the underlying texture
object. When we call intel_miptree_copy_teximage in the process
of re-creating a miptree (possibily because the number of miplevels
has changed) we didn't account for this, so we where only copying
texture images for the first slice.

Reviewed-by: Jason Ekstrand 
---
 src/mesa/drivers/dri/i965/intel_mipmap_tree.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c 
b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
index 26e137d..11f1876 100644
--- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
+++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
@@ -1249,7 +1249,12 @@ intel_miptree_copy_teximage(struct brw_context *brw,
   intel_texture_object(intelImage->base.Base.TexObject);
int level = intelImage->base.Base.Level;
int face = intelImage->base.Base.Face;
-   GLuint depth = intelImage->base.Base.Depth;
+
+   GLuint depth;
+   if (intel_obj->base.Target == GL_TEXTURE_1D_ARRAY)
+  depth = intelImage->base.Base.Height;
+   else
+  depth = intelImage->base.Base.Depth;
 
if (!invalidate) {
   for (int slice = 0; slice < depth; slice++) {
-- 
1.9.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] i965: Fix intel_miptree_copy_teximage for GL_TEXTURE_1D_ARRAY

2015-04-23 Thread kevin . rogovin
From: Noone 

For GL_TEXTURE_1D_ARRAY targets we store the depth of the array
in the Height field and leave Depth=1 in the underlying texture
object. When we call intel_miptree_copy_teximage in the process
of re-creating a miptree (possibily because the number of miplevels
has changed) we didn't account for this, so we where only copying
texture images for the first slice.

---
 src/mesa/drivers/dri/i965/intel_mipmap_tree.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c 
b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
index 26e137d..11f1876 100644
--- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
+++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
@@ -1249,7 +1249,12 @@ intel_miptree_copy_teximage(struct brw_context *brw,
   intel_texture_object(intelImage->base.Base.TexObject);
int level = intelImage->base.Base.Level;
int face = intelImage->base.Base.Face;
-   GLuint depth = intelImage->base.Base.Depth;
+
+   GLuint depth;
+   if (intel_obj->base.Target == GL_TEXTURE_1D_ARRAY)
+  depth = intelImage->base.Base.Height;
+   else
+  depth = intelImage->base.Base.Depth;
 
if (!invalidate) {
   for (int slice = 0; slice < depth; slice++) {
-- 
1.9.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 1/7] Define extension ARB_framebuffer_no_attachments and additions to gl_framebuffer for extension ARB_framebuffer_no_attachments

2015-04-23 Thread kevin . rogovin
From: Kevin Rogovin 

Add extension flag and constant values for ARB_framebuffer_no_attachments.

---
 src/mesa/main/extensions.c  |  1 +
 src/mesa/main/fbobject.c|  1 +
 src/mesa/main/framebuffer.c |  1 +
 src/mesa/main/mtypes.h  | 52 -
 4 files changed, 50 insertions(+), 5 deletions(-)

diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c
index 3d4965c..43b5c0b 100644
--- a/src/mesa/main/extensions.c
+++ b/src/mesa/main/extensions.c
@@ -118,6 +118,7 @@ static const struct extension extension_table[] = {
{ "GL_ARB_fragment_program_shadow", 
o(ARB_fragment_program_shadow), GLL,2003 },
{ "GL_ARB_fragment_shader", o(ARB_fragment_shader), 
GL, 2002 },
{ "GL_ARB_framebuffer_object",  o(ARB_framebuffer_object),  
GL, 2005 },
+   { "GL_ARB_framebuffer_no_attachments",  
o(ARB_framebuffer_no_attachments),  GL, 2012 },
{ "GL_ARB_framebuffer_sRGB",o(EXT_framebuffer_sRGB),
GL, 1998 },
{ "GL_ARB_get_program_binary",  o(dummy_true),  
GL, 2010 },
{ "GL_ARB_gpu_shader5", o(ARB_gpu_shader5), 
GLC,2010 },
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 27cf97f..eabbb96 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -914,6 +914,7 @@ _mesa_test_framebuffer_completeness(struct gl_context *ctx,
fb->Height = 0;
fb->_AllColorBuffersFixedPoint = GL_TRUE;
fb->_HasSNormOrFloatColorBuffer = GL_FALSE;
+   fb->_HasAttachments = GL_TRUE;
 
/* Start at -2 to more easily loop over all attachment points.
 *  -2: depth buffer
diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c
index 4f7736a..4e4d896 100644
--- a/src/mesa/main/framebuffer.c
+++ b/src/mesa/main/framebuffer.c
@@ -157,6 +157,7 @@ _mesa_initialize_window_framebuffer(struct gl_framebuffer 
*fb,
fb->_Status = GL_FRAMEBUFFER_COMPLETE_EXT;
fb->_AllColorBuffersFixedPoint = !visual->floatMode;
fb->_HasSNormOrFloatColorBuffer = visual->floatMode;
+   fb->_HasAttachments = GL_TRUE;
 
compute_depth_max(fb);
 }
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index fb41430..38a3817 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -3133,12 +3133,29 @@ struct gl_framebuffer
 */
struct gl_config Visual;
 
-   GLuint Width, Height;   /**< size of frame buffer in pixels */
+   /**
+* size of frame buffer in pixels, 
+* no attachments has these values as 0 
+*/
+   GLuint Width, Height;   
+
+   /**
+* In the case that the framebuffer has no attachment (i.e. 
+* GL_ARB_framebuffer_no_attachments) then the geometry of
+* the framebuffer is specified by the default values.
+*/
+   struct {
+ GLuint Width, Height, Layers, NumSamples;
+ GLboolean FixedSampleLocations;
+   } DefaultGeometry;
 
-   /** \name  Drawing bounds (Intersection of buffer size and scissor box) */
+   /** \name  Drawing bounds (Intersection of buffer size and scissor box) 
+* The drawing region is given by [_Xmin, _Xmax) x [_Ymin, _Ymax),
+* (inclusive for _Xmin and _Ymin while exclusive for _Xmax and _Ymax)
+*/
/*@{*/
-   GLint _Xmin, _Xmax;  /**< inclusive */
-   GLint _Ymin, _Ymax;  /**< exclusive */
+   GLint _Xmin, _Xmax;  
+   GLint _Ymin, _Ymax;  
/*@}*/
 
/** \name  Derived Z buffer stuff */
@@ -3151,6 +3168,20 @@ struct gl_framebuffer
/** One of the GL_FRAMEBUFFER_(IN)COMPLETE_* tokens */
GLenum _Status;
 
+   /** True if both of the conditions:
+*  - one of Attachment has gl_renderbuffer_attachment::Type != GL_NONE
+*  - _Status is GL_FRAMEBUFFER_COMPLETE_EXT
+* NOTE: the values for Width and Height are set to 0 in the
+* case of no attachments, a backend driver supporting 
+* GL_ARB_framebuffer_no_attachments must check for 
+* the flag _HasAttachments and if GL_FALSE, must then
+* use the values in DefaultGeometry to initialize its
+* viewport, scissor and so on (in particular _Xmin, _Xmax,
+* _Ymin and _Ymax do NOT take into account _HasAttachments
+* being false
+*/
+   GLboolean _HasAttachments;
+
/** Integer color values */
GLboolean _IntegerColor;
 
@@ -3161,7 +3192,9 @@ struct gl_framebuffer
/**
 * The maximum number of layers in the framebuffer, or 0 if the framebuffer
 * is not layered.  For cube maps and cube map arrays, each cube face
-* counts as a layer.
+* counts as a layer. As the case for Width, Height a backend driver
+* supporting GL_ARB_framebuffer_no_attachments must use DefaultGeo

[Mesa-dev] [PATCH 6/7] i965: ensure execution of fragment shader when fragment shader has atomic buffer access

2015-04-23 Thread kevin . rogovin
From: Kevin Rogovin 

Ensure that the GPU spawns the fragment shader thread for those
fragment shaders with atomic buffer access. 

---
 src/mesa/drivers/dri/i965/gen7_wm_state.c | 7 +++
 src/mesa/drivers/dri/i965/gen8_ps_state.c | 4 
 2 files changed, 11 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/gen7_wm_state.c 
b/src/mesa/drivers/dri/i965/gen7_wm_state.c
index 82e116c..fa04221 100644
--- a/src/mesa/drivers/dri/i965/gen7_wm_state.c
+++ b/src/mesa/drivers/dri/i965/gen7_wm_state.c
@@ -77,6 +77,13 @@ upload_wm_state(struct brw_context *brw)
   dw1 |= GEN7_WM_KILL_ENABLE;
}
 
+   /* pixel shader must run if it has side-effects
+*/
+   if (brw->ctx.Shader._CurrentFragmentProgram!=NULL &&
+   brw->ctx.Shader._CurrentFragmentProgram->NumAtomicBuffers > 0) {
+ dw1 |= GEN7_WM_DISPATCH_ENABLE;
+   }
+
/* _NEW_BUFFERS | _NEW_COLOR */
if (brw_color_buffer_write_enabled(brw) || writes_depth ||
dw1 & GEN7_WM_KILL_ENABLE) {
diff --git a/src/mesa/drivers/dri/i965/gen8_ps_state.c 
b/src/mesa/drivers/dri/i965/gen8_ps_state.c
index 5f39e12..614bc9b 100644
--- a/src/mesa/drivers/dri/i965/gen8_ps_state.c
+++ b/src/mesa/drivers/dri/i965/gen8_ps_state.c
@@ -62,6 +62,10 @@ upload_ps_extra(struct brw_context *brw)
if (prog_data->uses_omask)
   dw1 |= GEN8_PSX_OMASK_TO_RENDER_TARGET;
 
+   if (brw->ctx.Shader._CurrentFragmentProgram!=NULL &&
+   brw->ctx.Shader._CurrentFragmentProgram->NumAtomicBuffers > 0)
+  dw1 |= GEN8_PSX_SHADER_HAS_UAV;
+
BEGIN_BATCH(2);
OUT_BATCH(_3DSTATE_PS_EXTRA << 16 | (2 - 2));
OUT_BATCH(dw1);
-- 
1.9.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 2/7] Define constants and functions for ARB_framebuffer_no_attachment extension

2015-04-23 Thread kevin . rogovin
From: Kevin Rogovin 

Define enumerations, functions and associated glGet's for 
extension ARB_framebuffer_no_attachment.

---
 .../glapi/gen/ARB_framebuffer_no_attachments.xml   | 33 ++
 src/mapi/glapi/gen/Makefile.am |  1 +
 src/mapi/glapi/gen/gl_API.xml  |  1 +
 src/mesa/main/fbobject.c   | 12 +++
 src/mesa/main/fbobject.h   |  7 
 src/mesa/main/get.c|  3 ++
 src/mesa/main/get_hash_params.py   | 40 ++
 7 files changed, 97 insertions(+)
 create mode 100644 src/mapi/glapi/gen/ARB_framebuffer_no_attachments.xml

diff --git a/src/mapi/glapi/gen/ARB_framebuffer_no_attachments.xml 
b/src/mapi/glapi/gen/ARB_framebuffer_no_attachments.xml
new file mode 100644
index 000..60e40d0
--- /dev/null
+++ b/src/mapi/glapi/gen/ARB_framebuffer_no_attachments.xml
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/mapi/glapi/gen/Makefile.am b/src/mapi/glapi/gen/Makefile.am
index 1c4b86a..9a0e944 100644
--- a/src/mapi/glapi/gen/Makefile.am
+++ b/src/mapi/glapi/gen/Makefile.am
@@ -130,6 +130,7 @@ API_XML = \
ARB_ES2_compatibility.xml \
ARB_ES3_compatibility.xml \
ARB_framebuffer_object.xml \
+   ARB_framebuffer_no_attachments.xml \
ARB_geometry_shader4.xml \
ARB_get_program_binary.xml \
ARB_gpu_shader_fp64.xml \
diff --git a/src/mapi/glapi/gen/gl_API.xml b/src/mapi/glapi/gen/gl_API.xml
index a8a6db6..4eea396 100644
--- a/src/mapi/glapi/gen/gl_API.xml
+++ b/src/mapi/glapi/gen/gl_API.xml
@@ -8325,6 +8325,7 @@
 
 
 
+http://www.w3.org/2001/XInclude"/>
 
 
 
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index eabbb96..5c78c40 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -1292,6 +1292,18 @@ _mesa_BindRenderbufferEXT(GLenum target, GLuint 
renderbuffer)
bind_renderbuffer(target, renderbuffer, true);
 }
 
+extern void GLAPIENTRY
+_mesa_FramebufferParameteri(GLenum target, GLenum pname, GLint param)
+{
+  /* to be implemented */
+}
+
+extern void GLAPIENTRY
+_mesa_GetFramebufferParameteriv(GLenum target, GLenum pname, GLint *params)
+{
+  /* to be implemented */
+}
+
 
 /**
  * Remove the specified renderbuffer or texture from any attachment point in
diff --git a/src/mesa/main/fbobject.h b/src/mesa/main/fbobject.h
index 61aa1f5..76adb92 100644
--- a/src/mesa/main/fbobject.h
+++ b/src/mesa/main/fbobject.h
@@ -211,4 +211,11 @@ extern void GLAPIENTRY
 _mesa_DiscardFramebufferEXT(GLenum target, GLsizei numAttachments,
 const GLenum *attachments);
 
+
+extern void GLAPIENTRY
+_mesa_FramebufferParameteri(GLenum target, GLenum pname, GLint param);
+
+extern void GLAPIENTRY
+_mesa_GetFramebufferParameteriv(GLenum target, GLenum pname, GLint *params);
+
 #endif /* FBOBJECT_H */
diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
index a881bc5..ca9d13c 100644
--- a/src/mesa/main/get.c
+++ b/src/mesa/main/get.c
@@ -393,6 +393,7 @@ EXTRA_EXT(INTEL_performance_query);
 EXTRA_EXT(ARB_explicit_uniform_location);
 EXTRA_EXT(ARB_clip_control);
 EXTRA_EXT(EXT_polygon_offset_clamp);
+EXTRA_EXT(ARB_framebuffer_no_attachments);
 
 static const int
 extra_ARB_color_buffer_float_or_glcore[] = {
@@ -466,6 +467,8 @@ static const int 
extra_core_ARB_color_buffer_float_and_new_buffers[] = {
  * remaining combinations. To look up the enums valid in a given API
  * we will use a hash table specific to that API. These tables are in
  * turn generated at build time and included through get_hash.h.
+ * To add an entry (i.e. a new enumeration for glGet that is taken
+ * from the table) add an entry to get_hash_params.py.
  */
 
 #include "get_hash.h"
diff --git a/src/mesa/main/get_hash_params.py b/src/mesa/main/get_hash_params.py
index 41cb2c1..8712c46 100644
--- a/src/mesa/main/get_hash_params.py
+++ b/src/mesa/main/get_hash_params.py
@@ -1,3 +1,35 @@
+# glGet pnames possible, organized first by GL version
+# and then organized by GL extension.
+# There is a list for different combinations of GL_ version
+# that combination is specified by the field "apis".
+# The field "params" is a list of entries describing
+# how glGet* operates when passed a pname.
+# To add a pname for glGet* to handle, the entry is of the form
+# a) [ "PnameX", "LOC_CUSTOM, TypeX, ExtraRequirementX" ]
+# OR
+# b) [ "PnameX", "OffsetX, ExtraRequirement" ]
+#
+#   - PnameX is the name of the pname passed to glGet without the GL_ prefix
+#   - ExtraRequirement is extra requirment declared in get.c listing
+# GL requirements (such as extension requirements). If no extra
+# requirement is needed, then it is NO_EXTRA
+#
+# Form a) is for those pnames whose glGet implementation is
+# not a direct take of the value from

[Mesa-dev] [PATCH 3/7] Complete implementation for ARB_framebuffer_no_attachment in Mesa core: implement GetFramebufferParameteriv, FramebufferParameteri and changes to _mesa_test_framebuffer_complete

2015-04-24 Thread kevin . rogovin
From: Kevin Rogovin 

Complete the implementation of ARB_framebuffer_no_attachment in Mesa core:
  1. Implement _mesa_GetFramebufferParameteriv() and 
_mesa_FramebufferParameteri()
  2. Additions to _mesa_test_framebuffer_completeness() 

---
 src/mesa/main/fbobject.c | 153 ---
 1 file changed, 144 insertions(+), 9 deletions(-)

diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 5c78c40..6c0c2b0 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -1113,14 +1113,49 @@ _mesa_test_framebuffer_completeness(struct gl_context 
*ctx,
   } else if (att_layer_count > max_layer_count) {
  max_layer_count = att_layer_count;
   }
+
+  /**
+   * The extension GL_ARB_framebuffer_no_attachments places the additional
+   * requirement on each attachment that
+   *
+   * "The width and height of image are greater than zero and less than or 
equal
+   *  to the values of the implementation-dependent limits 
MAX_FRAMEBUFFER_-
+   *  WIDTH and MAX_FRAMEBUFFER_HEIGHT , respectively. "
+   *
+   * "If  is a three-dimensional texture or a one- or 
two-dimensional
+   *  array texture and the attachment is layered, the depth or layer 
count of
+   *  the texture is less than or equal to the implementation-dependent 
limit
+   *  MAX_FRAMEBUFFER_LAYERS."
+   *
+   * "If image has multiple samples, its sample count is less than or 
equal to
+   * the value of the implementation-dependent limit MAX_FRAMEBUFFER_-
+   * SAMPLES ."
+   *
+   * The same requirements are also in place for GL 4.5,
+   * Section 9.4.1 "Framebuffer Attachment Completeness", pg 310-311
+   *
+   * However, this is a tighter restriction than previous version of GL.
+   * In interest of better compatibility, we will not enforce these
+   * restrictions.
+   */
}
 
fb->MaxNumLayers = max_layer_count;
 
if (numImages == 0) {
-  fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT;
-  fbo_incomplete(ctx, "no attachments", -1);
-  return;
+  fb->_HasAttachments = GL_FALSE;
+
+  if (!ctx->Extensions.ARB_framebuffer_no_attachments) {
+ fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT;
+ fbo_incomplete(ctx, "no attachments", -1);
+ return;
+  }
+
+  if (fb->DefaultGeometry.Width == 0 || fb->DefaultGeometry.Height == 0) {
+ fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT;
+ fbo_incomplete(ctx, "no attachments and default width or height is 
0", -1);
+ return;
+  }
}
 
if (_mesa_is_desktop_gl(ctx) && !ctx->Extensions.ARB_ES2_compatibility) {
@@ -1185,8 +1220,10 @@ _mesa_test_framebuffer_completeness(struct gl_context 
*ctx,
* renderbuffers/textures are different sizes, the framebuffer
* width/height will be set to the smallest width/height.
*/
-  fb->Width = minWidth;
-  fb->Height = minHeight;
+  if (numImages != 0) {
+ fb->Width = minWidth;
+ fb->Height = minHeight;
+  }
 
   /* finally, update the visual info for the framebuffer */
   _mesa_update_framebuffer_visual(ctx, fb);
@@ -1292,16 +1329,114 @@ _mesa_BindRenderbufferEXT(GLenum target, GLuint 
renderbuffer)
bind_renderbuffer(target, renderbuffer, true);
 }
 
-extern void GLAPIENTRY
+static void
+framebuffer_parameteri(struct gl_context *ctx, struct gl_framebuffer *fb,
+   GLenum pname, GLint param, const char *func)
+{
+   switch (pname) {
+   case GL_FRAMEBUFFER_DEFAULT_WIDTH:
+  if (param < 0 || param > ctx->Const.MaxFramebufferWidth)
+_mesa_error(ctx, GL_INVALID_VALUE, "%s", func);
+  else
+ fb->DefaultGeometry.Width = param;
+  break;
+   case GL_FRAMEBUFFER_DEFAULT_HEIGHT:
+  if (param < 0 || param > ctx->Const.MaxFramebufferHeight)
+_mesa_error(ctx, GL_INVALID_VALUE, "%s", func);
+  else
+ fb->DefaultGeometry.Height = param;
+  break;
+   case GL_FRAMEBUFFER_DEFAULT_LAYERS:
+  if (param < 0 || param > ctx->Const.MaxFramebufferLayers)
+_mesa_error(ctx, GL_INVALID_VALUE, "%s", func);
+  else
+ fb->DefaultGeometry.Layers = param;
+  break;
+   case GL_FRAMEBUFFER_DEFAULT_SAMPLES:
+  if (param < 0 || param > ctx->Const.MaxFramebufferSamples)
+_mesa_error(ctx, GL_INVALID_VALUE, "%s", func);
+  else
+fb->DefaultGeometry.NumSamples = param;
+  break;
+   case GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS:
+  fb->DefaultGeometry.FixedSampleLocations = param;
+  break;
+   default:
+  _mesa_error(ctx, GL_INVALID_ENUM,
+  "%s(pname=0x%x

[Mesa-dev] [PATCH 7/7] i965: enable ARB_framebuffer_no_attachment extension

2015-04-24 Thread kevin . rogovin
From: Kevin Rogovin 

Enable extension GL_ARB_framebuffer_no_attachment in i965 for Gen7 
and higher. Lower gens are left disabled because those generations
do not support fragment shaders with side effects.

---
 src/mesa/drivers/dri/i965/brw_context.c  | 6 ++
 src/mesa/drivers/dri/i965/intel_extensions.c | 1 +
 2 files changed, 7 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/brw_context.c 
b/src/mesa/drivers/dri/i965/brw_context.c
index 9d90360..5c9577f 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -608,6 +608,12 @@ brw_initialize_context_constants(struct brw_context *brw)
/* ARB_gpu_shader5 */
if (brw->gen >= 7)
   ctx->Const.MaxVertexStreams = MIN2(4, MAX_VERTEX_STREAMS);
+
+   /* ARB_framebuffer_no_attachments */
+   ctx->Const.MaxFramebufferWidth = ctx->Const.MaxViewportWidth;
+   ctx->Const.MaxFramebufferHeight = ctx->Const.MaxViewportHeight;
+   ctx->Const.MaxFramebufferLayers = ctx->Const.MaxArrayTextureLayers;
+   ctx->Const.MaxFramebufferSamples = max_samples;
 }
 
 /**
diff --git a/src/mesa/drivers/dri/i965/intel_extensions.c 
b/src/mesa/drivers/dri/i965/intel_extensions.c
index 48064e1..65cf2bb 100644
--- a/src/mesa/drivers/dri/i965/intel_extensions.c
+++ b/src/mesa/drivers/dri/i965/intel_extensions.c
@@ -304,6 +304,7 @@ intelInitExtensions(struct gl_context *ctx)
if (brw->gen >= 7) {
   ctx->Extensions.ARB_conservative_depth = true;
   ctx->Extensions.ARB_texture_view = true;
+  ctx->Extensions.ARB_framebuffer_no_attachments = true;
   if (can_do_pipelined_register_writes(brw)) {
  ctx->Extensions.ARB_transform_feedback2 = true;
  ctx->Extensions.ARB_transform_feedback3 = true;
-- 
1.9.1

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 4/7] helper-conveniance functions for drivers to implement ARB_framebuffer_no_attachment

2015-04-24 Thread kevin . rogovin
From: Kevin Rogovin 

To assist drivers to implement ARB_framebuffer_no_attachment, provide
a set of convenience functions that check for gl_framebuffer::_HasAttachments
that return the geometry of the gl_framebuffer.

---
 src/mesa/main/framebuffer.c | 49 ++---
 src/mesa/main/framebuffer.h | 29 +++
 src/mesa/main/mtypes.h  | 21 ++-
 3 files changed, 74 insertions(+), 25 deletions(-)

diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c
index 4e4d896..7d8921b 100644
--- a/src/mesa/main/framebuffer.c
+++ b/src/mesa/main/framebuffer.c
@@ -357,30 +357,20 @@ update_framebuffer_size(struct gl_context *ctx, struct 
gl_framebuffer *fb)
 }
 
 
+
 /**
- * Calculate the inclusive bounding box for the scissor of a specific viewport
+ * Given a bounding box, intersect the bounding box with the scirros of
+ * a specified vieport.
  *
  * \param ctx GL context.
- * \param buffer  Framebuffer to be checked against
  * \param idx Index of the desired viewport
  * \param bboxBounding box for the scissored viewport.  Stored as xmin,
  *xmax, ymin, ymax.
- *
- * \warning This function assumes that the framebuffer dimensions are up to
- * date (e.g., update_framebuffer_size has been recently called on \c buffer).
- *
- * \sa _mesa_clip_to_region
  */
-void
-_mesa_scissor_bounding_box(const struct gl_context *ctx,
-   const struct gl_framebuffer *buffer,
-   unsigned idx, int *bbox)
+extern void
+_mesa_intersect_scissor_bounding_box(const struct gl_context *ctx,
+ unsigned idx, int *bbox)
 {
-   bbox[0] = 0;
-   bbox[2] = 0;
-   bbox[1] = buffer->Width;
-   bbox[3] = buffer->Height;
-
if (ctx->Scissor.EnableFlags & (1u << idx)) {
   if (ctx->Scissor.ScissorArray[idx].X > bbox[0]) {
  bbox[0] = ctx->Scissor.ScissorArray[idx].X;
@@ -402,6 +392,33 @@ _mesa_scissor_bounding_box(const struct gl_context *ctx,
  bbox[2] = bbox[3];
   }
}
+}
+
+/**
+ * Calculate the inclusive bounding box for the scissor of a specific viewport
+ *
+ * \param ctx GL context.
+ * \param buffer  Framebuffer to be checked against
+ * \param idx Index of the desired viewport
+ * \param bboxBounding box for the scissored viewport.  Stored as xmin,
+ *xmax, ymin, ymax.
+ *
+ * \warning This function assumes that the framebuffer dimensions are up to
+ * date (e.g., update_framebuffer_size has been recently called on \c buffer).
+ *
+ * \sa _mesa_clip_to_region
+ */
+void
+_mesa_scissor_bounding_box(const struct gl_context *ctx,
+   const struct gl_framebuffer *buffer,
+   unsigned idx, int *bbox)
+{
+   bbox[0] = 0;
+   bbox[2] = 0;
+   bbox[1] = buffer->Width;
+   bbox[3] = buffer->Height;
+
+   _mesa_intersect_scissor_bounding_box(ctx, idx, bbox);
 
assert(bbox[0] <= bbox[1]);
assert(bbox[2] <= bbox[3]);
diff --git a/src/mesa/main/framebuffer.h b/src/mesa/main/framebuffer.h
index a427421..8b84d26 100644
--- a/src/mesa/main/framebuffer.h
+++ b/src/mesa/main/framebuffer.h
@@ -76,6 +76,35 @@ _mesa_scissor_bounding_box(const struct gl_context *ctx,
const struct gl_framebuffer *buffer,
unsigned idx, int *bbox);
 
+extern void
+_mesa_intersect_scissor_bounding_box(const struct gl_context *ctx,
+ unsigned idx, int *bbox);
+
+static inline  GLuint
+_mesa_geometric_width(const struct gl_framebuffer *buffer)
+{
+   return buffer->_HasAttachments ? buffer->Width : 
buffer->DefaultGeometry.Width;
+}
+
+
+static inline  GLuint
+_mesa_geometric_height(const struct gl_framebuffer *buffer)
+{
+   return buffer->_HasAttachments ? buffer->Height : 
buffer->DefaultGeometry.Height;
+}
+
+static inline  GLuint
+_mesa_geometric_samples(const struct gl_framebuffer *buffer)
+{
+   return buffer->_HasAttachments ? buffer->Visual.samples : 
buffer->DefaultGeometry.NumSamples;
+}
+
+static inline  GLuint
+_mesa_geometric_layers(const struct gl_framebuffer *buffer)
+{
+   return buffer->_HasAttachments ? buffer->MaxNumLayers : 
buffer->DefaultGeometry.Layers;
+}
+
 extern void 
 _mesa_update_draw_buffer_bounds(struct gl_context *ctx);
 
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 38a3817..ac7cdb6 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -3134,13 +3134,13 @@ struct gl_framebuffer
struct gl_config Visual;
 
/**
-* size of frame buffer in pixels, 
-* no attachments has these values as 0 
+* size of frame buffer in pixels,
+* no attachments has these values as 0
 */
-   GLuint Width, Height;   
+   GLuint Width, Height;
 
/**
-* In the case that the framebuffer has no atta

[Mesa-dev] [PATCH 5/7] i965: use _mesa_geometry_width/height/layers/samples for programming geometry of framebuffer to GEN

2015-04-24 Thread kevin . rogovin
From: Kevin Rogovin 

To prepare for i965 to support ARB_framebuffer_no_attachment, use
the convenience functions mesa_geometry_width/height/layers/samples
to specify the geometry of the render target surfaces to the GPU.


---
 src/mesa/drivers/dri/i965/brw_clip_state.c |  9 -
 src/mesa/drivers/dri/i965/brw_misc_state.c | 12 --
 src/mesa/drivers/dri/i965/brw_sf_state.c   | 46 --
 src/mesa/drivers/dri/i965/brw_state_upload.c   |  7 +++-
 src/mesa/drivers/dri/i965/brw_wm.c |  7 ++--
 src/mesa/drivers/dri/i965/brw_wm_surface_state.c   | 13 --
 src/mesa/drivers/dri/i965/gen6_clip_state.c| 11 --
 src/mesa/drivers/dri/i965/gen6_multisample_state.c |  3 +-
 src/mesa/drivers/dri/i965/gen6_scissor_state.c | 14 +--
 src/mesa/drivers/dri/i965/gen6_sf_state.c  |  3 +-
 src/mesa/drivers/dri/i965/gen6_viewport_state.c|  3 +-
 src/mesa/drivers/dri/i965/gen6_wm_state.c  |  3 +-
 src/mesa/drivers/dri/i965/gen7_sf_state.c  |  3 +-
 src/mesa/drivers/dri/i965/gen7_viewport_state.c|  3 +-
 src/mesa/drivers/dri/i965/gen7_wm_state.c  |  3 +-
 src/mesa/drivers/dri/i965/gen8_viewport_state.c|  9 +++--
 16 files changed, 108 insertions(+), 41 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_clip_state.c 
b/src/mesa/drivers/dri/i965/brw_clip_state.c
index 3223834..3aa679f 100644
--- a/src/mesa/drivers/dri/i965/brw_clip_state.c
+++ b/src/mesa/drivers/dri/i965/brw_clip_state.c
@@ -32,6 +32,7 @@
 #include "brw_context.h"
 #include "brw_state.h"
 #include "brw_defines.h"
+#include "main/framebuffer.h"
 
 static void
 upload_clip_vp(struct brw_context *brw)
@@ -60,6 +61,10 @@ brw_upload_clip_unit(struct brw_context *brw)
 
/* _NEW_BUFFERS */
struct gl_framebuffer *fb = ctx->DrawBuffer;
+   GLint fb_width, fb_height;
+
+   fb_width = _mesa_geometric_width(fb);
+   fb_height = _mesa_geometric_height(fb);
 
upload_clip_vp(brw);
 
@@ -127,8 +132,8 @@ brw_upload_clip_unit(struct brw_context *brw)
/* enable guardband clipping if we can */
if (ctx->ViewportArray[0].X == 0 &&
ctx->ViewportArray[0].Y == 0 &&
-   ctx->ViewportArray[0].Width == (float) fb->Width &&
-   ctx->ViewportArray[0].Height == (float) fb->Height)
+   ctx->ViewportArray[0].Width == (float) fb_width &&
+   ctx->ViewportArray[0].Height == (float) fb_height)
{
   clip->clip5.guard_band_enable = 1;
   clip->clip6.clipper_viewport_state_ptr =
diff --git a/src/mesa/drivers/dri/i965/brw_misc_state.c 
b/src/mesa/drivers/dri/i965/brw_misc_state.c
index 78a46cb..ef94a6e 100644
--- a/src/mesa/drivers/dri/i965/brw_misc_state.c
+++ b/src/mesa/drivers/dri/i965/brw_misc_state.c
@@ -39,6 +39,7 @@
 #include "brw_state.h"
 #include "brw_defines.h"
 
+#include "main/framebuffer.h"
 #include "main/fbobject.h"
 #include "main/glformats.h"
 
@@ -46,12 +47,17 @@
 static void upload_drawing_rect(struct brw_context *brw)
 {
struct gl_context *ctx = &brw->ctx;
+   GLint fb_width, fb_height;
+   struct gl_framebuffer *fb = ctx->DrawBuffer;
+
+   fb_width = _mesa_geometric_width(fb);
+   fb_height = _mesa_geometric_height(fb);
 
BEGIN_BATCH(4);
OUT_BATCH(_3DSTATE_DRAWING_RECTANGLE << 16 | (4 - 2));
OUT_BATCH(0); /* xmin, ymin */
-   OUT_BATCH(((ctx->DrawBuffer->Width - 1) & 0x) |
-   ((ctx->DrawBuffer->Height - 1) << 16));
+   OUT_BATCH(((fb_width - 1) & 0x) |
+   ((fb_height - 1) << 16));
OUT_BATCH(0);
ADVANCE_BATCH();
 }
@@ -767,7 +773,7 @@ static void upload_polygon_stipple_offset(struct 
brw_context *brw)
 * works just fine, and there's no window system to worry about.
 */
if (_mesa_is_winsys_fbo(ctx->DrawBuffer))
-  OUT_BATCH((32 - (ctx->DrawBuffer->Height & 31)) & 31);
+  OUT_BATCH((32 - (_mesa_geometric_height(ctx->DrawBuffer) & 31)) & 31);
else
   OUT_BATCH(0);
ADVANCE_BATCH();
diff --git a/src/mesa/drivers/dri/i965/brw_sf_state.c 
b/src/mesa/drivers/dri/i965/brw_sf_state.c
index 014b434..1fa3d44 100644
--- a/src/mesa/drivers/dri/i965/brw_sf_state.c
+++ b/src/mesa/drivers/dri/i965/brw_sf_state.c
@@ -35,6 +35,7 @@
 #include "main/macros.h"
 #include "main/fbobject.h"
 #include "main/viewport.h"
+#include "main/framebuffer.h"
 #include "brw_context.h"
 #include "brw_state.h"
 #include "brw_defines.h"
@@ -47,18 +48,42 @@ static void upload_sf_vp(struct brw_context *brw)
GLfloat y_scale, y_bias;
double scale[3], translate[3];
const bool render_to_fbo = _mesa_is_user_fbo(ctx->DrawBuffer);
+   GLint fb_width, fb_height, xmin, xmax, ymin, ymax;
 
sfv = brw_state_batch(brw, AUB_TRACE_SF_VP_ST

[Mesa-dev] [PATCH 04/18] i965: assign BindingTableEntryCount of INTERFACE_DESCRIPTOR_DATA

2017-11-13 Thread kevin . rogovin
From: Kevin Rogovin 

Signed-off-by: Kevin Rogovin 
---
 src/mesa/drivers/dri/i965/genX_state_upload.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/mesa/drivers/dri/i965/genX_state_upload.c 
b/src/mesa/drivers/dri/i965/genX_state_upload.c
index 453b8e4add..1474d9a150 100644
--- a/src/mesa/drivers/dri/i965/genX_state_upload.c
+++ b/src/mesa/drivers/dri/i965/genX_state_upload.c
@@ -4249,6 +4249,7 @@ genX(upload_cs_state)(struct brw_context *brw)
   .SamplerStatePointer = stage_state->sampler_offset,
   .SamplerCount = DIV_ROUND_UP(CLAMP(stage_state->sampler_count, 0, 16), 
4),
   .BindingTablePointer = stage_state->bind_bo_offset,
+  .BindingTableEntryCount = prog_data->binding_table.size_bytes / 4,
   .ConstantURBEntryReadLength = cs_prog_data->push.per_thread.regs,
   .NumberofThreadsinGPGPUThreadGroup = cs_prog_data->threads,
   .SharedLocalMemorySize = encode_slm_size(GEN_GEN,
-- 
2.14.2

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 02/18] intel/tools: define BatchbufferLogger application interface

2017-11-13 Thread kevin . rogovin
From: Kevin Rogovin 

Define the application interface to BatchbufferLogger. The
BatchbufferLogger needs from the application when a GL/GLES
API call is issues and returns. It will use this information
to correctly correlate batchbuffer additions to GL/GLES API
calls.

In addition, because the BatchbufferLogger will be intercepting
drmIoctl, an application does NOT link against it. Instead, one
needs to LD_PRELOAD the .so.

Signed-off-by: Kevin Rogovin 
---
 src/intel/tools/i965_batchbuffer_logger_app.h | 157 ++
 1 file changed, 157 insertions(+)
 create mode 100644 src/intel/tools/i965_batchbuffer_logger_app.h

diff --git a/src/intel/tools/i965_batchbuffer_logger_app.h 
b/src/intel/tools/i965_batchbuffer_logger_app.h
new file mode 100644
index 00..b8405cd475
--- /dev/null
+++ b/src/intel/tools/i965_batchbuffer_logger_app.h
@@ -0,0 +1,157 @@
+/*
+ * Copyright © 2017 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#ifndef I965_BATCHBUFFER_LOGGER_APP_H
+#define I965_BATCHBUFFER_LOGGER_APP_H
+
+#include 
+#include 
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Enumeration value specifying the kind of data to write;
+ * Data written to a a i965_batchbuffer_logger_session
+ * can mark the start of a block, then end of a block
+ * of item within a block. Eac type has an optional
+ * name and value strings.
+ */
+enum i965_batchbuffer_logger_message_type_t {
+   I965_BATCHBUFFER_LOGGER_MESSAGE_BLOCK_BEGIN, /* start of a block */
+   I965_BATCHBUFFER_LOGGER_MESSAGE_BLOCK_END,   /* end of a block */
+   I965_BATCHBUFFER_LOGGER_MESSAGE_VALUE,   /* value in block */
+};
+
+/**
+ * An i965_batchbuffer_logger_session_params represents how
+ * to emit batchbuffer logger data.
+ */
+struct i965_batchbuffer_logger_session_params {
+   /**
+* Client data opaque pointer passed back to
+* function callbacks.
+*/
+   void *client_data;
+
+   /**
+* Function called by i965_batchbuffer_logger_app to write
+* data for the sessions.
+* \param client_data the pointer value in
+*i965_batchbuffer_logger_session_params::client_data
+* \param tp the message type
+* \param name of the data
+* \param name_length length of the name data
+* \param value of the data
+* \param value_length length of the value data
+*/
+   void (*write)(void *client_data,
+ enum i965_batchbuffer_logger_message_type_t tp,
+ const void *name, uint32_t name_length,
+ const void *value, uint32_t value_length);
+
+   /**
+* Function called by i965_batchbuffer_logger_app just
+* before an execbuffer2 call is sent to the kernel.
+* \param client_data the pointer value in
+*i965_batchbuffer_logger_session_params::client_data
+* \param id The unique ID of the execbuffer2 ioctl, this ID
+*   is written in the block information of each execbuffer2
+*   ioctl via write().
+*/
+   void (*pre_execbuffer2_ioctl)(void *client_data, unsigned int id);
+
+   /**
+* Function called by i965_batchbuffer_logger_app to close,
+* i.e. delete the session.
+*/
+   void (*close)(void *client_data);
+};
+
+/**
+ * An i965_batchbuffer_logger_session represents a logging
+ * session created; the batchbuffer logger can have multiple
+ * sessions active simutaneously.
+ */
+struct i965_batchbuffer_logger_session {
+   void *opaque;
+};
+
+/**
+ * An i965_batchbuffer_logger_app represents the hooking
+ * of an application into an i965_batchbuffer_logger
+ */
+struct i965_batchbuffer_logger_app {
+  /**
+   * To be called by the app before a GL/GLES or GLX/EGL call
+   */
+  void (*pre_call)(struct i965_batchbuffer_logger_app*,
+   unsigned int call_id, const char *call_detailed,
+   const char *fcn_name

[Mesa-dev] [PATCH 03/18] intel/tools: BatchBufferLogger define output file format of tool

2017-11-13 Thread kevin . rogovin
From: Kevin Rogovin 

Define the output format of the BatchbufferLogger. The output
is a sequence of blocks where blocks can have member blocks
or values. The top level blocks come from the application
calling into the BatchBufferLogger when an GL/GLES API call
is started and returns.

Signed-off-by: Kevin Rogovin 
---
 src/intel/tools/i965_batchbuffer_logger_output.h | 66 
 1 file changed, 66 insertions(+)
 create mode 100644 src/intel/tools/i965_batchbuffer_logger_output.h

diff --git a/src/intel/tools/i965_batchbuffer_logger_output.h 
b/src/intel/tools/i965_batchbuffer_logger_output.h
new file mode 100644
index 00..4e4c988d3c
--- /dev/null
+++ b/src/intel/tools/i965_batchbuffer_logger_output.h
@@ -0,0 +1,66 @@
+/*
+ * Copyright © 2017 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#ifndef I965_BATCHBUFFER_LOGGER_OUTPUT_H
+#define I965_BATCHBUFFER_LOGGER_OUTPUT_H
+
+#include 
+#include "i965_batchbuffer_logger_app.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * FILE format of the log is a seqence of (HEADER, NAME-DATA, VALUE-DATA)
+ * tuples where HEADER is the struct i965_batchbuffer_logger_header packed
+ * via fwrite, NAME-DATA is a sequence of HEADER.name_length characers and
+ * VALUE-DATA is a seqnece of HEADER.value_length characters. The start
+ * and end of blocks are used to give nested structure to the data (for
+ * example to make better JSON or XML output). Block endings will have that
+ * the name and value lengths are both ALWAYS 0. For other types, name should
+ * never be zero, but value can be (typically for blocks).
+ */
+
+struct i965_batchbuffer_logger_header {
+   enum i965_batchbuffer_logger_message_type_t type;
+
+   /**
+* length of the string for the name must be 0 for type
+* I965_BATCHBUFFER_LOGGER_MESSAGE_BLOCK_END
+*/
+   uint32_t name_length;
+
+   /**
+* length of the string for the value, must be 0 for types
+* I965_BATCHBUFFER_LOGGER_MESSAGE_BLOCK_BEGIN and
+* I965_BATCHBUFFER_LOGGER_MESSAGE_BLOCK_END
+*/
+   uint32_t value_length;
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
-- 
2.14.2

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 01/18] intel/tools: define BatchBufferLogger driver interface

2017-11-13 Thread kevin . rogovin
From: Kevin Rogovin 

Define the driver interface for BatchbufferLogger. The
interface assumes that for any -thread- there is only
one batchbuffer to which commands are to be added. A
driver needs to provide the information on what is the
active batchbuffer on a calling thread and also a function
that given a batchbuffer, returns where in the batchbuffer
the driver is currently "at".

Signed-off-by: Kevin Rogovin 
---
 src/intel/tools/i965_batchbuffer_logger.h | 186 ++
 1 file changed, 186 insertions(+)
 create mode 100644 src/intel/tools/i965_batchbuffer_logger.h

diff --git a/src/intel/tools/i965_batchbuffer_logger.h 
b/src/intel/tools/i965_batchbuffer_logger.h
new file mode 100644
index 00..bc219dfea4
--- /dev/null
+++ b/src/intel/tools/i965_batchbuffer_logger.h
@@ -0,0 +1,186 @@
+/*
+ * Copyright © 2017 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#ifndef I965_BATCHBUFFER_LOGGER_DRIVER_H
+#define I965_BATCHBUFFER_LOGGER_DRIVER_H
+
+#include 
+#include 
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * i965_batchbuffer_logger tracks a batchbuffers
+ * by the pair (GEM-BO handle, File descriptor)
+ * pair.
+ */
+struct i965_logged_batchbuffer {
+   /**
+* GEM BO of the batch buffer, this is the BO
+* sent to kernel to execute commands on the
+* GPU
+*/
+   uint32_t gem_bo;
+
+   /**
+* The file descriptor of the GEM BO
+*/
+   int fd;
+
+   /**
+* Opaque pointer used by the driver associated
+* to the batch buffer; an i965_batchbuffer_logger
+* does NOT use this value to identify a batchbuffer.
+* It is for the driver to use to help it compute
+* where it is in a specified batchbuffer.
+*/
+   const void *driver_data;
+};
+
+/**
+ * A counter is to be used by a driver to provide counts of elements
+ * added to a batchbuffer when the counter is active. Actions acting
+ * on a counter are placed on the active batchbuffer of the calling
+ * thread, not executed immediately. The actual counting (in addition
+ * to activation, deactivation, reset, and relase) are performed when
+ * the batchbuffer is intercepted by the logger.
+ */
+struct i965_batchbuffer_counter {
+   void *opaque;
+};
+
+/**
+ * An i965_batchbuffer_logger object represents the hooking
+ * of a GPU driver.
+ */
+struct i965_batchbuffer_logger {
+   /**
+* To be called by the driver to inform the batchbuffer logger
+* that a batch buffer was created, but NOT sent to the kernel
+* to be executed by the driver.
+*/
+   void (*aborted_batchbuffer)(struct i965_batchbuffer_logger *logger,
+   int fd, uint32_t gem_bo);
+
+   /**
+* To be called by the driver if it migrates commands from one
+* batchbuffer to another batchbuffer.
+*/
+   void (*migrate_batchbuffer)(struct i965_batchbuffer_logger *logger,
+   const struct i965_logged_batchbuffer *from,
+   const struct i965_logged_batchbuffer *to);
+
+   /**
+* To be called by the driver to add log-message data to the
+* batchbuffer log. The message will be added to the log of
+* the batchbuffer dst. If counter is non-NULL the values
+* in the counter are also emitted to the log.
+*/
+   void (*add_message)(struct i965_batchbuffer_logger *logger,
+   const struct i965_logged_batchbuffer *dst,
+   const char *fmt, va_list ap);
+
+   /**
+* call to release the i965_batchbuffer_logger
+*/
+   void (*release_driver)(struct i965_batchbuffer_logger *logger);
+
+   /**
+* Create a counter object. If filename is non-NULL, then
+* the values of the counter will be emitted to the named
+* file when the counter is deleted.
+*/
+   struct i965_batchbuffer_counter(*create_counter)

[Mesa-dev] [PATCH 05/18] i965: Enable BatchbufferLogger in i965 driver

2017-11-13 Thread kevin . rogovin
From: Kevin Rogovin 

The interface for BatchbufferLogger is that it is active
only if it is LD_PRELOAD'ed. Thus, the i965 driver is to
use dlsym to see if it is there, and if so fetch the object
at intel_screen creation.

Signed-off-by: Kevin Rogovin 
---
 src/mesa/drivers/dri/i965/brw_bufmgr.c| 22 -
 src/mesa/drivers/dri/i965/brw_bufmgr.h|  8 -
 src/mesa/drivers/dri/i965/brw_context.c   | 34 
 src/mesa/drivers/dri/i965/brw_context.h   | 12 +++
 src/mesa/drivers/dri/i965/intel_batchbuffer.c | 29 +++--
 src/mesa/drivers/dri/i965/intel_screen.c  | 46 +--
 src/mesa/drivers/dri/i965/intel_screen.h  |  3 ++
 7 files changed, 146 insertions(+), 8 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_bufmgr.c 
b/src/mesa/drivers/dri/i965/brw_bufmgr.c
index 17036b53bc..6a70fc50d8 100644
--- a/src/mesa/drivers/dri/i965/brw_bufmgr.c
+++ b/src/mesa/drivers/dri/i965/brw_bufmgr.c
@@ -65,6 +65,8 @@
 #include "string.h"
 
 #include "i915_drm.h"
+#include "intel_screen.h"
+#include "tools/i965_batchbuffer_logger.h"
 
 #ifdef HAVE_VALGRIND
 #include 
@@ -104,6 +106,7 @@ struct bo_cache_bucket {
 };
 
 struct brw_bufmgr {
+   struct intel_screen *screen;
int fd;
 
mtx_t lock;
@@ -621,9 +624,14 @@ bo_unreference_final(struct brw_bo *bo, time_t time)
 {
struct brw_bufmgr *bufmgr = bo->bufmgr;
struct bo_cache_bucket *bucket;
+   struct i965_batchbuffer_logger *bb_logger =
+  bufmgr->screen->batchbuffer_logger;
 
DBG("bo_unreference final: %d (%s)\n", bo->gem_handle, bo->name);
 
+   if(bb_logger != NULL) {
+  bb_logger->aborted_batchbuffer(bb_logger, bufmgr->fd, bo->gem_handle);
+   }
bucket = bucket_for_size(bufmgr, bo->size);
/* Put the buffer into our internal cache for reuse if we can. */
if (bufmgr->bo_reuse && bo->reusable && bucket != NULL &&
@@ -1064,6 +1072,12 @@ brw_bufmgr_destroy(struct brw_bufmgr *bufmgr)
free(bufmgr);
 }
 
+int
+brw_bufmgr_fd(const struct brw_bufmgr *bufmgr)
+{
+   return bufmgr->fd;
+}
+
 static int
 bo_set_tiling_internal(struct brw_bo *bo, uint32_t tiling_mode,
uint32_t stride)
@@ -1367,9 +1381,14 @@ gem_param(int fd, int name)
  * \param fd File descriptor of the opened DRM device.
  */
 struct brw_bufmgr *
-brw_bufmgr_init(struct gen_device_info *devinfo, int fd)
+brw_bufmgr_init(struct intel_screen *screen)
 {
struct brw_bufmgr *bufmgr;
+   struct gen_device_info *devinfo;
+   int fd;
+
+   devinfo = &screen->devinfo;
+   fd = screen->driScrnPriv->fd;
 
bufmgr = calloc(1, sizeof(*bufmgr));
if (bufmgr == NULL)
@@ -1385,6 +1404,7 @@ brw_bufmgr_init(struct gen_device_info *devinfo, int fd)
 * fd so that its namespace does not clash with another.
 */
bufmgr->fd = fd;
+   bufmgr->screen = screen;
 
if (mtx_init(&bufmgr->lock, mtx_plain) != 0) {
   free(bufmgr);
diff --git a/src/mesa/drivers/dri/i965/brw_bufmgr.h 
b/src/mesa/drivers/dri/i965/brw_bufmgr.h
index ee91324043..f4bffef4e4 100644
--- a/src/mesa/drivers/dri/i965/brw_bufmgr.h
+++ b/src/mesa/drivers/dri/i965/brw_bufmgr.h
@@ -46,6 +46,7 @@ extern "C" {
 
 struct gen_device_info;
 struct brw_context;
+struct intel_screen;
 
 struct brw_bo {
/**
@@ -274,6 +275,11 @@ void brw_bo_wait_rendering(struct brw_bo *bo);
  */
 void brw_bufmgr_destroy(struct brw_bufmgr *bufmgr);
 
+/**
+ * Returns the file descriptor of the buffer manager
+ */
+int brw_bufmgr_fd(const struct brw_bufmgr *bufmgr);
+
 /**
  * Get the current tiling (and resulting swizzling) mode for the bo.
  *
@@ -313,7 +319,7 @@ int brw_bo_busy(struct brw_bo *bo);
 int brw_bo_madvise(struct brw_bo *bo, int madv);
 
 /* drm_bacon_bufmgr_gem.c */
-struct brw_bufmgr *brw_bufmgr_init(struct gen_device_info *devinfo, int fd);
+struct brw_bufmgr *brw_bufmgr_init(struct intel_screen *screen);
 struct brw_bo *brw_bo_gem_create_from_name(struct brw_bufmgr *bufmgr,
const char *name,
unsigned int handle);
diff --git a/src/mesa/drivers/dri/i965/brw_context.c 
b/src/mesa/drivers/dri/i965/brw_context.c
index 19d5a2e350..456316deb7 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -75,6 +75,8 @@
 #include "util/debug.h"
 #include "isl/isl.h"
 
+#include "tools/i965_batchbuffer_logger.h"
+
 /***
  * Mesa's Driver Functions
  ***/
@@ -1062,6 +1064,7 @@ brwCreateContext(gl_api api,
 
vbo_use_buffer_objects(ctx);
vbo_always_unmap_buffers(ctx);
+   brw->have_active_batchbuffer = true;
 
brw_disk_cache_init(brw);
 
@@ -1076,6 +1079,7 @@ intelDestroyContext(__DRIcontext * driContextPriv)
  

[Mesa-dev] [PATCH 00/18] Batchbuffer Logger for Intel GPU (v2)

2017-11-13 Thread kevin . rogovin
From: Kevin Rogovin 

This patch series defines and implements a BatchbufferLogger
for Intel GEN. The main purpose of the BatchbufferLogger is
to strongly correlate API calls to data added to a batchbuffer.
In addition to this function, the BatchbufferLogger also tracks
GPU state (respecting HW context as well). The logger intercepts
drmIoctl recording the information needed to decode a bachbuffer
(such as GEM BO creation/deletion, HW context create/delete,
and most importantly execbuffer2). When the execbuffer2 returns
from the kernel, the BatchbufferLogger will log information
in its log of what was added when and in addition log the
GPU state (at the point in the batchbuffer) of 3DPRIMITIVE and
GPGPU_WALKER commands.

It is an application's requirment to tell the BatchbufferLogger
just before and just after an API call. Because of the need
to intercept drmIoctl, having an application link against
BatchbufferLogger is not robust. Instead, an application is
to use dlsym to fetch the correction a function pointer that
returns the BatchbufferLogger's application interface. The
interface of the BatchbufferLogger is defined in patch 0002.
A script is also provided to use the BatchbufferLogger in
an easier way than needing to set environmental variables.

On the subject of application integration, I have a -very-
small patch series that enabled BatchbufferLogger for
apitrace. I can share these patches if anyone asks, but I
cannot submit them to apitrace until atleast the BatchbufferLogger
is in Mesa with a stable application interface.

The log emitted by the BatchbufferLogger is a sequence of blocks
with possibility of blocks being elements of blocks. The top level
blocks are the API call markers created from the calls into the
BatchbufferLogger from the application. An application starts
and ends a logging session. A session provides callbacks to
write the block data; with the interface of a callback a log
does not need to just write to a file, it could also write
over a network to remote application for the purpose of remote
debugging. A specific interface is also provided to write to a
file and additional tools are included to convert the log to JSON,
XML and text. The simple file format should allow others to be able
to take the data and use it however they see fit. The JSON output
alone can be quite illuminating to use when debugging/enhancing the
i965 driver for a single frame (or even single draw call) of a troublesome
application.

It is worth noting that i965 already has a batchbuffer decoder
dumper (also making use src/intel/tools/gen_decoder). However,
BatchbufferLogger has the following features which are not in the
current dumper and are likely quite tricky to implement into it.

 1. The biggest feature is that this BatchbufferLogger contents are
annotated by the GL/GLES API calls and driver text as well.
 2. This BatchbufferLogger provides an interface to application space
to allow for applications to start/end logging sessions as
they see fit. In addition, an application can have multilpe
independent sessions active.
 3. This BatchbufferLogger repeats the state of the GPU and HW
context on 3DPRIMITIVE and GPGPU_WALKER commands. By doing
so one can see the precise state the GPU is in at that command.
Coupled with (1), one can see what precise GPU state one
has when an application issues draw commands. Moreover, coupled
with the (previously) posted patches for apitrace, one
can compare differences at specific trace points within a
trace from apitrace to help diagnose regressions.

In addition, as suggested by Chris Wilson, I have also implemented an
i965 blackbox recorded at https://github.com/krogueintel/i965-blackbox
which will perform the necessary GL/GLES API interception to
produce annotated batchbuffer recordings to assist in GPU hang
debugging. The BatchbufferLogger (again at Chris Wilson's suggestion)
has the ability to walk batchbuffers BEFORE kernel submit and to
also add an EXEC_OBJECT_CAPTURE execobject2 whose contents are
the ID of the execbuffer2 ioctl submitted. The aim is to greatly
assist in GPU hang debugging for troublesome applications.

For those interested, this BatchbufferLogger is available on
github at https://github.com/krogueintel/asem/tree/batchbuffer-logger.

The patch series is organized into the following blocks:

0001-0003: Define the BatchbufferLogger interfaces
0004-0004: Minor fix to i965 driver
0005-0005: Hooking of BatchbufferLogger into i965
0006-0011: Fixes and enhancements to intel/compiler,
   intel/tools and intel/common.
0012-0014: Implementation of BatchBufferLogger
0015-0017: Tools to decode log to JSON, XML and text
0018-0018: Command line tool for disassembling shader
   binaries.

v2:
  bug fix (spotted by Chris Wilson) for when i965 moves batchbuffer content
  add application session interface for more customizable logging
  add driver interface to add annotation to batchbu

[Mesa-dev] [PATCH 06/18] intel/common/gen_decoder: make useable from C++ source

2017-11-13 Thread kevin . rogovin
From: Kevin Rogovin 

Signed-off-by: Kevin Rogovin 
---
 src/intel/common/gen_decoder.h | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/src/intel/common/gen_decoder.h b/src/intel/common/gen_decoder.h
index 8b00b6edc2..e3b2457dfd 100644
--- a/src/intel/common/gen_decoder.h
+++ b/src/intel/common/gen_decoder.h
@@ -34,6 +34,10 @@
 extern "C" {
 #endif
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 struct gen_spec;
 struct gen_group;
 struct gen_field;
@@ -185,6 +189,9 @@ void gen_print_group(FILE *out,
  struct gen_group *group,
  uint64_t offset, const uint32_t *p,
  bool color);
+#ifdef __cplusplus
+}
+#endif
 
 #ifdef __cplusplus
 }
-- 
2.14.2

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 10/18] intel/tools/disasm: add gen_disasm_assembly_length function

2017-11-13 Thread kevin . rogovin
From: Kevin Rogovin 

The length function is needed if one wishes to save GEN binary
shaders to file.

Signed-off-by: Kevin Rogovin 
---
 src/intel/tools/disasm.c | 7 +++
 src/intel/tools/gen_disasm.h | 2 ++
 2 files changed, 9 insertions(+)

diff --git a/src/intel/tools/disasm.c b/src/intel/tools/disasm.c
index 27f99e21f9..6109727d56 100644
--- a/src/intel/tools/disasm.c
+++ b/src/intel/tools/disasm.c
@@ -106,6 +106,13 @@ gen_disasm_disassemble(struct gen_disasm *disasm, const 
void *assembly,
ralloc_free(annotation_info.mem_ctx);
 }
 
+int
+gen_disasm_assembly_length(struct gen_disasm *disasm,
+   const void *assembly, int start)
+{
+   return gen_disasm_find_end(disasm, assembly, start) - start;
+}
+
 struct gen_disasm *
 gen_disasm_create(int pciid)
 {
diff --git a/src/intel/tools/gen_disasm.h b/src/intel/tools/gen_disasm.h
index 8d82a58617..8b95a710e2 100644
--- a/src/intel/tools/gen_disasm.h
+++ b/src/intel/tools/gen_disasm.h
@@ -33,6 +33,8 @@ struct gen_disasm;
 struct gen_disasm *gen_disasm_create(int pciid);
 void gen_disasm_disassemble(struct gen_disasm *disasm,
 const void *assembly, int start, FILE *out);
+int gen_disasm_assembly_length(struct gen_disasm *disasm,
+   const void *assembly, int start);
 
 void gen_disasm_destroy(struct gen_disasm *disasm);
 
-- 
2.14.2

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 09/18] intel/tools/disasm: gen_disasm_disassemble to take const void* instead of void*

2017-11-13 Thread kevin . rogovin
From: Kevin Rogovin 

Signed-off-by: Kevin Rogovin 
---
 src/intel/tools/disasm.c | 6 +++---
 src/intel/tools/gen_disasm.h | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/intel/tools/disasm.c b/src/intel/tools/disasm.c
index 251acd313d..27f99e21f9 100644
--- a/src/intel/tools/disasm.c
+++ b/src/intel/tools/disasm.c
@@ -44,14 +44,14 @@ is_send(uint32_t opcode)
 }
 
 static int
-gen_disasm_find_end(struct gen_disasm *disasm, void *assembly, int start)
+gen_disasm_find_end(struct gen_disasm *disasm, const void *assembly, int start)
 {
struct gen_device_info *devinfo = &disasm->devinfo;
int offset = start;
 
/* This loop exits when send-with-EOT or when opcode is 0 */
while (true) {
-  brw_inst *insn = assembly + offset;
+  const brw_inst *insn = assembly + offset;
 
   if (brw_inst_cmpt_control(devinfo, insn)) {
  offset += 8;
@@ -70,7 +70,7 @@ gen_disasm_find_end(struct gen_disasm *disasm, void 
*assembly, int start)
 }
 
 void
-gen_disasm_disassemble(struct gen_disasm *disasm, void *assembly,
+gen_disasm_disassemble(struct gen_disasm *disasm, const void *assembly,
int start, FILE *out)
 {
struct gen_device_info *devinfo = &disasm->devinfo;
diff --git a/src/intel/tools/gen_disasm.h b/src/intel/tools/gen_disasm.h
index d2764bb90b..8d82a58617 100644
--- a/src/intel/tools/gen_disasm.h
+++ b/src/intel/tools/gen_disasm.h
@@ -32,7 +32,7 @@ struct gen_disasm;
 
 struct gen_disasm *gen_disasm_create(int pciid);
 void gen_disasm_disassemble(struct gen_disasm *disasm,
-void *assembly, int start, FILE *out);
+const void *assembly, int start, FILE *out);
 
 void gen_disasm_destroy(struct gen_disasm *disasm);
 
-- 
2.14.2

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 11/18] intel/tools/disasm: make sure that entire range is disassembled

2017-11-13 Thread kevin . rogovin
From: Kevin Rogovin 

Without this patch, if a shader has errors, the disassembly of the
shader often stops after the first opcode that has errors.

Signed-off-by: Kevin Rogovin 
---
 src/intel/tools/disasm.c | 13 +
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/src/intel/tools/disasm.c b/src/intel/tools/disasm.c
index 6109727d56..aaad8a4dfa 100644
--- a/src/intel/tools/disasm.c
+++ b/src/intel/tools/disasm.c
@@ -74,7 +74,7 @@ gen_disasm_disassemble(struct gen_disasm *disasm, const void 
*assembly,
int start, FILE *out)
 {
struct gen_device_info *devinfo = &disasm->devinfo;
-   int end = gen_disasm_find_end(disasm, assembly, start);
+   int i, offset, end = gen_disasm_find_end(disasm, assembly, start);
 
/* Make a dummy annotation structure that brw_validate_instructions
 * can work from.
@@ -92,15 +92,20 @@ gen_disasm_disassemble(struct gen_disasm *disasm, const 
void *assembly,
brw_validate_instructions(devinfo, assembly, start, end, &annotation_info);
struct annotation *annotation = annotation_info.ann;
 
-   for (int i = 0; i < annotation_info.ann_count; i++) {
-  int start_offset = annotation[i].offset;
+   for (i = 0, offset = start; i < annotation_info.ann_count; i++) {
   int end_offset = annotation[i + 1].offset;
 
-  brw_disassemble(devinfo, assembly, start_offset, end_offset, out);
+  brw_disassemble(devinfo, assembly, offset, end_offset, out);
 
   if (annotation[i].error) {
  fputs(annotation[i].error, out);
   }
+
+  offset = end_offset;
+   }
+
+   if (offset < end) {
+  brw_disassemble(devinfo, assembly, offset, end, out);
}
 
ralloc_free(annotation_info.mem_ctx);
-- 
2.14.2

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 14/18] intel/tools/BatchbufferLogger : add shell script for batchbuffer logger

2017-11-13 Thread kevin . rogovin
From: Kevin Rogovin 

Signed-off-by: Kevin Rogovin 
---
 src/intel/Makefile.tools.am   |   8 ++
 src/intel/tools/.gitignore|   1 +
 src/intel/tools/i965_batchbuffer_logger_sh.in | 108 ++
 3 files changed, 117 insertions(+)
 create mode 100644 src/intel/tools/i965_batchbuffer_logger_sh.in

diff --git a/src/intel/Makefile.tools.am b/src/intel/Makefile.tools.am
index c308b816f9..062c225c89 100644
--- a/src/intel/Makefile.tools.am
+++ b/src/intel/Makefile.tools.am
@@ -19,6 +19,7 @@
 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 # IN THE SOFTWARE.
 
+intelbindir = $(bindir)
 intellibdir = $(libdir)
 intelincludedir = $(includedir)
 
@@ -29,6 +30,9 @@ noinst_PROGRAMS += \
 intellib_LTLIBRARIES = \
tools/libi965_batchbuffer_logger.la
 
+intelbin_SCRIPTS = tools/i965_batchbuffer_logger_sh
+CLEANFILES += $(intelbin_SCRIPTS)
+
 intelinclude_HEADERS = tools/i965_batchbuffer_logger_app.h \
tools/i965_batchbuffer_logger_output.h
 
@@ -90,3 +94,7 @@ tools_libi965_batchbuffer_logger_la_CXXFLAGS = \
 
 tools_libi965_batchbuffer_logger_la_LDFLAGS = \
-no-undefined -module -avoid-version -shared -shrext .so
+
+intel_sed_prefix_vars = sed -e 's,[@]libdir[@],$(intellibdir),g'
+tools/i965_batchbuffer_logger_sh: tools/i965_batchbuffer_logger_sh.in
+   $(intel_sed_prefix_vars) < tools/i965_batchbuffer_logger_sh.in > 
tools/i965_batchbuffer_logger_sh
diff --git a/src/intel/tools/.gitignore b/src/intel/tools/.gitignore
index 27437f9eef..fa9bf70808 100644
--- a/src/intel/tools/.gitignore
+++ b/src/intel/tools/.gitignore
@@ -1,2 +1,3 @@
 /aubinator
 /aubinator_error_decode
+/i965_batchbuffer_logger_sh
diff --git a/src/intel/tools/i965_batchbuffer_logger_sh.in 
b/src/intel/tools/i965_batchbuffer_logger_sh.in
new file mode 100644
index 00..0746173417
--- /dev/null
+++ b/src/intel/tools/i965_batchbuffer_logger_sh.in
@@ -0,0 +1,108 @@
+#!/bin/bash
+# -*- mode: sh -*-
+
+function show_help() {
+cat <https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 08/18] intel/compiler:add function to give option to print offsets into assembly

2017-11-13 Thread kevin . rogovin
From: Kevin Rogovin 

Signed-off-by: Kevin Rogovin 
---
 src/intel/compiler/brw_eu.c | 11 ++-
 src/intel/compiler/brw_eu.h |  3 +++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/src/intel/compiler/brw_eu.c b/src/intel/compiler/brw_eu.c
index bc297a21b3..8969ae5bda 100644
--- a/src/intel/compiler/brw_eu.c
+++ b/src/intel/compiler/brw_eu.c
@@ -339,6 +339,15 @@ const unsigned *brw_get_program( struct brw_codegen *p,
 void
 brw_disassemble(const struct gen_device_info *devinfo,
 const void *assembly, int start, int end, FILE *out)
+{
+   brw_disassemble_print_offset_option(devinfo, assembly, start, end, out,
+   false);
+}
+
+void
+brw_disassemble_print_offset_option(const struct gen_device_info *devinfo,
+const void *assembly, int start, int end,
+FILE *out, bool print_offsets)
 {
bool dump_hex = (INTEL_DEBUG & DEBUG_HEX) != 0;
 
@@ -346,7 +355,7 @@ brw_disassemble(const struct gen_device_info *devinfo,
   const brw_inst *insn = assembly + offset;
   brw_inst uncompacted;
   bool compacted = brw_inst_cmpt_control(devinfo, insn);
-  if (0)
+  if (print_offsets)
  fprintf(out, "0x%08x: ", offset);
 
   if (compacted) {
diff --git a/src/intel/compiler/brw_eu.h b/src/intel/compiler/brw_eu.h
index 95503d5513..497cf9e575 100644
--- a/src/intel/compiler/brw_eu.h
+++ b/src/intel/compiler/brw_eu.h
@@ -128,6 +128,9 @@ int brw_disassemble_inst(FILE *file, const struct 
gen_device_info *devinfo,
  const struct brw_inst *inst, bool is_compacted);
 void brw_disassemble(const struct gen_device_info *devinfo,
  const void *assembly, int start, int end, FILE *out);
+void brw_disassemble_print_offset_option(const struct gen_device_info *devinfo,
+ const void *assembly, int start, int 
end,
+ FILE *out, bool print_offsets);
 const unsigned *brw_get_program( struct brw_codegen *p, unsigned *sz );
 
 brw_inst *brw_next_insn(struct brw_codegen *p, unsigned opcode);
-- 
2.14.2

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 07/18] intel/compiler: fix for memmove argument on annotating error

2017-11-13 Thread kevin . rogovin
From: Kevin Rogovin 

Without this fix, disassembling of GEN shaders with GPU commands
that the disassembler does not know would result in errors being
added to the annotator which would crash when more than one error
was added.

Signed-off-by: Kevin Rogovin 
---
 src/intel/compiler/intel_asm_annotation.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/intel/compiler/intel_asm_annotation.c 
b/src/intel/compiler/intel_asm_annotation.c
index b07a545a12..7aa222f04e 100644
--- a/src/intel/compiler/intel_asm_annotation.c
+++ b/src/intel/compiler/intel_asm_annotation.c
@@ -181,8 +181,9 @@ annotation_insert_error(struct annotation_info *annotation, 
unsigned offset,
  continue;
 
   if (offset + sizeof(brw_inst) != next->offset) {
- memmove(next, cur,
- (annotation->ann_count - i + 2) * sizeof(struct annotation));
+ int count;
+ count = annotation->ann_count - i - 1;
+ memmove(next, cur, count * sizeof(struct annotation));
  cur->error = NULL;
  cur->error_length = 0;
  cur->block_end = NULL;
-- 
2.14.2

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 15/18] intel/tools/BatchbufferLogger (txt-output): example txt dumper

2017-11-13 Thread kevin . rogovin
From: Kevin Rogovin 

Signed-off-by: Kevin Rogovin 
---
 src/intel/Makefile.tools.am  |   5 ++
 src/intel/tools/.gitignore   |   1 +
 src/intel/tools/i965_batchbuffer_dump_show.c | 129 +++
 3 files changed, 135 insertions(+)
 create mode 100644 src/intel/tools/i965_batchbuffer_dump_show.c

diff --git a/src/intel/Makefile.tools.am b/src/intel/Makefile.tools.am
index 062c225c89..d1a87e6991 100644
--- a/src/intel/Makefile.tools.am
+++ b/src/intel/Makefile.tools.am
@@ -30,6 +30,8 @@ noinst_PROGRAMS += \
 intellib_LTLIBRARIES = \
tools/libi965_batchbuffer_logger.la
 
+intelbin_PROGRAMS = tools/i965_batchbuffer_dump_show
+
 intelbin_SCRIPTS = tools/i965_batchbuffer_logger_sh
 CLEANFILES += $(intelbin_SCRIPTS)
 
@@ -98,3 +100,6 @@ tools_libi965_batchbuffer_logger_la_LDFLAGS = \
 intel_sed_prefix_vars = sed -e 's,[@]libdir[@],$(intellibdir),g'
 tools/i965_batchbuffer_logger_sh: tools/i965_batchbuffer_logger_sh.in
$(intel_sed_prefix_vars) < tools/i965_batchbuffer_logger_sh.in > 
tools/i965_batchbuffer_logger_sh
+
+tools_i965_batchbuffer_dump_show_SOURCES = \
+   tools/i965_batchbuffer_dump_show.c
diff --git a/src/intel/tools/.gitignore b/src/intel/tools/.gitignore
index fa9bf70808..7d95bcdf3a 100644
--- a/src/intel/tools/.gitignore
+++ b/src/intel/tools/.gitignore
@@ -1,3 +1,4 @@
 /aubinator
 /aubinator_error_decode
 /i965_batchbuffer_logger_sh
+/i965_batchbuffer_dump_show
diff --git a/src/intel/tools/i965_batchbuffer_dump_show.c 
b/src/intel/tools/i965_batchbuffer_dump_show.c
new file mode 100644
index 00..0e8c372e63
--- /dev/null
+++ b/src/intel/tools/i965_batchbuffer_dump_show.c
@@ -0,0 +1,129 @@
+/*
+ * Copyright © 2017 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+#include "tools/i965_batchbuffer_logger_output.h"
+
+static
+void
+print_tabs(int l)
+{
+   for(int i = 0; i < l; ++i) {
+  printf("\t");
+   }
+}
+
+static
+void
+print_instrumentation_message(int block_level,
+  const struct i965_batchbuffer_logger_header *hdr,
+  FILE *pfile)
+{
+   bool line_start;
+   uint32_t i;
+   char c = 0;
+   size_t num_read;
+
+   /* assume name has no EOLs */
+   print_tabs(block_level);
+   for (i = 0; !feof(pfile) && i < hdr->name_length; ++i) {
+  num_read = fread(&c, sizeof(c), 1, pfile);
+  if (num_read != 1)
+ return;
+  printf("%c", c);
+   }
+
+   if (hdr->value_length > 0) {
+  printf(" : ");
+   }
+
+   /* print the value (if there is one). */
+   for (i = 0, line_start = false; !feof(pfile) && i < hdr->value_length; ++i) 
{
+  num_read = fread(&c, sizeof(c), 1, pfile);
+
+  if (num_read != 1)
+ break;
+
+  if (line_start) {
+ print_tabs(block_level);
+  }
+
+  printf("%c", c);
+  line_start = (c == '\n');
+   }
+
+   if (c != '\n') {
+  printf("\n");
+   }
+}
+
+
+int
+main(int argc, char **argv)
+{
+   FILE *pfile;
+   int block_level = 0;
+
+   if (argc != 2) {
+  return -1;
+   }
+
+   pfile = fopen(argv[1], "r");
+   if (pfile == NULL) {
+  return -1;
+   }
+
+   while (!feof(pfile)) {
+  struct i965_batchbuffer_logger_header hdr;
+  size_t num_read;
+
+  num_read = fread(&hdr, sizeof(hdr), 1, pfile);
+  if (num_read != 1)
+ break;
+
+  switch(hdr.type) {
+ case I965_BATCHBUFFER_LOGGER_MESSAGE_BLOCK_BEGIN: {
+print_instrumentation_message(block_level, &hdr, pfile);
+++block_level;
+ }
+ break;
+
+ case I965_BATCHBUFFER_LOGGER_MESSAGE_BLOCK_END: {
+--block_level;
+

[Mesa-dev] [PATCH 17/18] intel/tools/BatchbufferLogger (output-json): add json outputter

2017-11-13 Thread kevin . rogovin
From: Kevin Rogovin 

Signed-off-by: Kevin Rogovin 
---
 src/intel/Makefile.tools.am|   6 +-
 src/intel/tools/.gitignore |   1 +
 .../tools/i965_batchbuffer_dump_show_json.cpp  | 253 +
 3 files changed, 259 insertions(+), 1 deletion(-)
 create mode 100644 src/intel/tools/i965_batchbuffer_dump_show_json.cpp

diff --git a/src/intel/Makefile.tools.am b/src/intel/Makefile.tools.am
index 32b30edc4e..dd68d8f173 100644
--- a/src/intel/Makefile.tools.am
+++ b/src/intel/Makefile.tools.am
@@ -31,7 +31,8 @@ intellib_LTLIBRARIES = \
tools/libi965_batchbuffer_logger.la
 
 intelbin_PROGRAMS = tools/i965_batchbuffer_dump_show \
-   tools/i965_batchbuffer_dump_show_xml
+   tools/i965_batchbuffer_dump_show_xml \
+   tools/i965_batchbuffer_dump_show_json
 
 intelbin_SCRIPTS = tools/i965_batchbuffer_logger_sh
 CLEANFILES += $(intelbin_SCRIPTS)
@@ -107,3 +108,6 @@ tools_i965_batchbuffer_dump_show_SOURCES = \
 
 tools_i965_batchbuffer_dump_show_xml_SOURCES = \
tools/i965_batchbuffer_dump_show_xml.cpp
+
+tools_i965_batchbuffer_dump_show_json_SOURCES = \
+   tools/i965_batchbuffer_dump_show_json.cpp
diff --git a/src/intel/tools/.gitignore b/src/intel/tools/.gitignore
index 7180e4ba4b..ea4dc23c20 100644
--- a/src/intel/tools/.gitignore
+++ b/src/intel/tools/.gitignore
@@ -3,3 +3,4 @@
 /i965_batchbuffer_logger_sh
 /i965_batchbuffer_dump_show
 /i965_batchbuffer_dump_show_xml
+/i965_batchbuffer_dump_show_json
diff --git a/src/intel/tools/i965_batchbuffer_dump_show_json.cpp 
b/src/intel/tools/i965_batchbuffer_dump_show_json.cpp
new file mode 100644
index 00..bf48396424
--- /dev/null
+++ b/src/intel/tools/i965_batchbuffer_dump_show_json.cpp
@@ -0,0 +1,253 @@
+/*
+ * Copyright © 2017 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "tools/i965_batchbuffer_logger_output.h"
+
+static
+std::string
+json_name_from_file(unsigned int len, std::FILE *pfile)
+{
+   std::string return_value;
+   unsigned int i;
+   char c;
+
+   for(i = 0; i < len; ++i) {
+  if (std::fread(&c, sizeof(char), 1, pfile) != sizeof(char)) {
+ break;
+  }
+  if(c != '\n') {
+ return_value.push_back(c);
+  }
+   }
+
+   return return_value;
+}
+
+static
+std::string
+json_block_name_from_file(const struct i965_batchbuffer_logger_header *hdr,
+  std::FILE *pfile)
+{
+   std::ostringstream return_value;
+
+   return_value << json_name_from_file(hdr->name_length, pfile);
+   if (hdr->value_length > 0) {
+  return_value << ":" << json_name_from_file(hdr->value_length, pfile);
+   }
+
+   return return_value.str();
+}
+
+static
+void
+json_print_value_line(std::vector::const_iterator begin,
+  std::vector::const_iterator end)
+{
+   for(; begin != end; ++begin) {
+  switch(*begin) {
+  case '\t':
+ std::cout << "\\t";
+ break;
+  case '\"':
+ std::cout << "\\\"";
+ break;
+  case '\\':
+ /* This is silly but required; apirtace will place control
+  * character codes (sometimes) within string values (typically
+  * from shader sources). So for example if a shader source
+  * has (within a comment) something like "Famous"
+  * then the detailed function value will have then \"Famour\"
+  * within its string value. The below silly block of code
+  * just checks if there is a non-white character and if so,
+  * just assume that the \ is a control code.
+  */
+ if (begin != end) {
+  

[Mesa-dev] [PATCH 13/18] intel/tools/BatchbufferLogger: install i965_batchbuffer non-driver interface headers

2017-11-13 Thread kevin . rogovin
From: Kevin Rogovin 

Signed-off-by: Kevin Rogovin 
---
 src/intel/Makefile.tools.am | 4 
 1 file changed, 4 insertions(+)

diff --git a/src/intel/Makefile.tools.am b/src/intel/Makefile.tools.am
index 9919b5f241..c308b816f9 100644
--- a/src/intel/Makefile.tools.am
+++ b/src/intel/Makefile.tools.am
@@ -20,6 +20,7 @@
 # IN THE SOFTWARE.
 
 intellibdir = $(libdir)
+intelincludedir = $(includedir)
 
 noinst_PROGRAMS += \
tools/aubinator \
@@ -28,6 +29,9 @@ noinst_PROGRAMS += \
 intellib_LTLIBRARIES = \
tools/libi965_batchbuffer_logger.la
 
+intelinclude_HEADERS = tools/i965_batchbuffer_logger_app.h \
+   tools/i965_batchbuffer_logger_output.h
+
 tools_aubinator_SOURCES = \
tools/aubinator.c \
tools/disasm.c \
-- 
2.14.2

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 18/18] intel/tools: add command line GEN shader disassembler tool

2017-11-13 Thread kevin . rogovin
From: Kevin Rogovin 

Signed-off-by: Kevin Rogovin 
---
 src/intel/Makefile.tools.am   |  21 ++-
 src/intel/tools/.gitignore|   1 +
 src/intel/tools/gen_shader_disassembler.c | 221 ++
 3 files changed, 242 insertions(+), 1 deletion(-)
 create mode 100644 src/intel/tools/gen_shader_disassembler.c

diff --git a/src/intel/Makefile.tools.am b/src/intel/Makefile.tools.am
index dd68d8f173..71eb3253c3 100644
--- a/src/intel/Makefile.tools.am
+++ b/src/intel/Makefile.tools.am
@@ -32,7 +32,8 @@ intellib_LTLIBRARIES = \
 
 intelbin_PROGRAMS = tools/i965_batchbuffer_dump_show \
tools/i965_batchbuffer_dump_show_xml \
-   tools/i965_batchbuffer_dump_show_json
+   tools/i965_batchbuffer_dump_show_json \
+   tools/gen_shader_disassembler
 
 intelbin_SCRIPTS = tools/i965_batchbuffer_logger_sh
 CLEANFILES += $(intelbin_SCRIPTS)
@@ -111,3 +112,21 @@ tools_i965_batchbuffer_dump_show_xml_SOURCES = \
 
 tools_i965_batchbuffer_dump_show_json_SOURCES = \
tools/i965_batchbuffer_dump_show_json.cpp
+
+tools_gen_shader_disassembler_SOURCES = \
+   tools/gen_shader_disassembler.c \
+   tools/disasm.c \
+   tools/gen_disasm.h
+
+tools_gen_shader_disassembler_LDADD = \
+   common/libintel_common.la \
+   compiler/libintel_compiler.la \
+   $(top_builddir)/src/util/libmesautil.la \
+   $(PTHREAD_LIBS) \
+   $(EXPAT_LIBS) \
+   $(ZLIB_LIBS)
+
+tools_gen_shader_disassembler_CFLAGS = \
+   $(AM_CFLAGS) \
+   $(EXPAT_CFLAGS) \
+   $(ZLIB_CFLAGS)
diff --git a/src/intel/tools/.gitignore b/src/intel/tools/.gitignore
index ea4dc23c20..e9b22c89aa 100644
--- a/src/intel/tools/.gitignore
+++ b/src/intel/tools/.gitignore
@@ -4,3 +4,4 @@
 /i965_batchbuffer_dump_show
 /i965_batchbuffer_dump_show_xml
 /i965_batchbuffer_dump_show_json
+/gen_shader_disassembler
diff --git a/src/intel/tools/gen_shader_disassembler.c 
b/src/intel/tools/gen_shader_disassembler.c
new file mode 100644
index 00..bd6c400fcc
--- /dev/null
+++ b/src/intel/tools/gen_shader_disassembler.c
@@ -0,0 +1,221 @@
+/*
+ * Copyright © 2017 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "compiler/brw_inst.h"
+#include "compiler/brw_eu.h"
+
+static
+void
+print_opcodes(const void *data, int data_sz,
+  struct gen_device_info *devinfo,
+  bool print_offsets)
+{
+   for (int offset = 0; offset < data_sz;) {
+  const brw_inst *insn = data + offset;
+  bool compacted;
+  brw_inst uncompacted;
+  enum opcode opcode;
+  const struct opcode_desc *desc;
+
+  if (print_offsets) {
+ printf("0x%08x: ", offset);
+  }
+
+  compacted = brw_inst_cmpt_control(devinfo, insn);
+  if (compacted) {
+ brw_compact_inst *compacted_insn;
+ compacted_insn = (void*)insn;
+ brw_uncompact_instruction(devinfo, &uncompacted, compacted_insn);
+ insn = &uncompacted;
+ offset += 8;
+  } else {
+ offset += 16;
+  }
+
+  opcode = brw_inst_opcode(devinfo, insn);
+  desc = brw_opcode_desc(devinfo, opcode);
+  if (desc) {
+ printf("(0x%08x) %s", opcode, desc->name);
+  } else {
+ printf("(0x%08x) UnknownOpcode", opcode);
+  }
+
+  if (compacted) {
+ printf(" {Compacted}");
+  }
+
+  printf("\n");
+   }
+}
+
+static
+void
+print_disassembly(const void *data, int data_sz,
+  struct gen_device_info *devinfo,
+  bool print_offsets)
+{
+   struct annotation_info annotation_info = {
+  .ann_count = 1,
+  .ann_size = 2,
+   };
+   annotation_info.mem_ctx = ralloc_context(NULL);
+   annotation_inf

[Mesa-dev] [PATCH 16/18] intel/tools/BatchbufferLogger (output-xml): add outputter to XML

2017-11-13 Thread kevin . rogovin
From: Kevin Rogovin 

Signed-off-by: Kevin Rogovin 
---
 src/intel/Makefile.tools.am|   6 +-
 src/intel/tools/.gitignore |   1 +
 src/intel/tools/i965_batchbuffer_dump_show_xml.cpp | 217 +
 3 files changed, 223 insertions(+), 1 deletion(-)
 create mode 100644 src/intel/tools/i965_batchbuffer_dump_show_xml.cpp

diff --git a/src/intel/Makefile.tools.am b/src/intel/Makefile.tools.am
index d1a87e6991..32b30edc4e 100644
--- a/src/intel/Makefile.tools.am
+++ b/src/intel/Makefile.tools.am
@@ -30,7 +30,8 @@ noinst_PROGRAMS += \
 intellib_LTLIBRARIES = \
tools/libi965_batchbuffer_logger.la
 
-intelbin_PROGRAMS = tools/i965_batchbuffer_dump_show
+intelbin_PROGRAMS = tools/i965_batchbuffer_dump_show \
+   tools/i965_batchbuffer_dump_show_xml
 
 intelbin_SCRIPTS = tools/i965_batchbuffer_logger_sh
 CLEANFILES += $(intelbin_SCRIPTS)
@@ -103,3 +104,6 @@ tools/i965_batchbuffer_logger_sh: 
tools/i965_batchbuffer_logger_sh.in
 
 tools_i965_batchbuffer_dump_show_SOURCES = \
tools/i965_batchbuffer_dump_show.c
+
+tools_i965_batchbuffer_dump_show_xml_SOURCES = \
+   tools/i965_batchbuffer_dump_show_xml.cpp
diff --git a/src/intel/tools/.gitignore b/src/intel/tools/.gitignore
index 7d95bcdf3a..7180e4ba4b 100644
--- a/src/intel/tools/.gitignore
+++ b/src/intel/tools/.gitignore
@@ -2,3 +2,4 @@
 /aubinator_error_decode
 /i965_batchbuffer_logger_sh
 /i965_batchbuffer_dump_show
+/i965_batchbuffer_dump_show_xml
diff --git a/src/intel/tools/i965_batchbuffer_dump_show_xml.cpp 
b/src/intel/tools/i965_batchbuffer_dump_show_xml.cpp
new file mode 100644
index 00..64916897ea
--- /dev/null
+++ b/src/intel/tools/i965_batchbuffer_dump_show_xml.cpp
@@ -0,0 +1,217 @@
+/*
+ * Copyright © 2017 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "tools/i965_batchbuffer_logger_output.h"
+
+static
+std::string
+xml_value_from_file(unsigned int len, std::FILE *pfile)
+{
+   std::ostringstream str;
+   unsigned int i;
+   char c;
+
+   str << "";
+   return str.str();
+}
+
+static
+std::string
+xml_string_from_file(unsigned int len, std::FILE *pfile)
+{
+   std::ostringstream str;
+   unsigned int i;
+   char c;
+
+   for(i = 0; i < len; ++i) {
+  if (std::fread(&c, sizeof(char), 1, pfile) != sizeof(char)) {
+ break;
+  }
+  switch(c) {
+  case '<':
+ str << "<";
+ break;
+  case '>':
+ str << ">";
+ break;
+  case '&':
+ str << "&";
+ break;
+  case '\n':
+ str << "
";
+ break;
+  case '\"':
+ str << """;
+ break;
+  default:
+ str << c;
+  }
+   }
+
+   return str.str();
+}
+
+static
+bool
+legal_tag_char(char c)
+{
+   switch(c)
+   {
+   case '-':
+   case '_':
+   case '.':
+  return true;
+   }
+   return !std::isspace(c) && std::isalnum(c);
+}
+
+static
+std::string
+xml_tag_from_file(unsigned int len, std::FILE *pfile)
+{
+   std::string return_value;
+   unsigned int i;
+   char c;
+
+   for(i = 0; i < len; ++i) {
+  if (std::fread(&c, sizeof(char), 1, pfile) != sizeof(char)) {
+ break;
+  }
+  if (legal_tag_char(c)) {
+ if (i == 0 && (std::isdigit(c) || c == '.' || c == '-')) {
+return_value.push_back('_');
+ }
+ return_value.push_back(c);
+  } else {
+ return_value.push_back('_');
+  }
+   }
+
+   return return_value;
+}
+
+static
+void

[Mesa-dev] [PATCH 0/5] i965: ASTC5x5 workaround

2017-12-01 Thread kevin . rogovin
From: Kevin Rogovin 

This patch series implements a needed workaround for Gen9 for ASTC5x5
sampler reads. The crux of the work around is to make sure that the
sampler does not read an ASTC5x5 texture and a surface with an auxilary
buffer without having a texture cache invalidate between such accesses.


Kevin Rogovin (5):
  i965: define astc5x5 workaround infrastructure
  i965: ASTC5x5 workaround logic for blorp
  i965: set ASTC5x5 workaround texture type tracking on texture validate
  i965: use ASTC5x5 workaround in brw_draw
  i965: use ASTC5x5 workaround in brw_compute

 src/mesa/drivers/dri/i965/brw_compute.c  |  6 +++
 src/mesa/drivers/dri/i965/brw_context.c  | 63 
 src/mesa/drivers/dri/i965/brw_context.h  | 23 +
 src/mesa/drivers/dri/i965/brw_draw.c |  6 +++
 src/mesa/drivers/dri/i965/brw_wm_surface_state.c |  5 ++
 src/mesa/drivers/dri/i965/genX_blorp_exec.c  |  5 ++
 src/mesa/drivers/dri/i965/intel_batchbuffer.c|  1 +
 src/mesa/drivers/dri/i965/intel_tex_image.c  | 16 --
 src/mesa/drivers/dri/i965/intel_tex_validate.c   | 13 +
 9 files changed, 134 insertions(+), 4 deletions(-)

-- 
2.14.2

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 2/5] i965: ASTC5x5 workaround logic for blorp

2017-12-01 Thread kevin . rogovin
From: Kevin Rogovin 

Blorp will only read from an ASTC5x5 texture if it copies from
such a surface, that can only if an application is fetching
such pixels. Because an ASTC5x3 texture can never be a render
target, we do not need to worry about blorp reading such surfaces
on framebuffer blits, or any other copying from a framebuffer.

Signed-off-by: Kevin Rogovin 
---
 src/mesa/drivers/dri/i965/genX_blorp_exec.c |  5 +
 src/mesa/drivers/dri/i965/intel_tex_image.c | 16 
 2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/genX_blorp_exec.c 
b/src/mesa/drivers/dri/i965/genX_blorp_exec.c
index 87e90fde91..73f72d2603 100644
--- a/src/mesa/drivers/dri/i965/genX_blorp_exec.c
+++ b/src/mesa/drivers/dri/i965/genX_blorp_exec.c
@@ -230,6 +230,11 @@ genX(blorp_exec)(struct blorp_batch *batch,
struct gl_context *ctx = &brw->ctx;
bool check_aperture_failed_once = false;
 
+   if (brw->astc5x5_wa.blorp_sampling_from_astc5x5) {
+  brw_set_astc5x5_wa_mode(brw, BRW_ASTC5x5_WA_MODE_HAS_ASTC5x5);
+   } else {
+  brw_set_astc5x5_wa_mode(brw, BRW_ASTC5x5_WA_MODE_HAS_AUX);
+   }
/* Flush the sampler and render caches.  We definitely need to flush the
 * sampler cache so that we get updated contents from the render cache for
 * the glBlitFramebuffer() source.  Also, we are sometimes warned in the
diff --git a/src/mesa/drivers/dri/i965/intel_tex_image.c 
b/src/mesa/drivers/dri/i965/intel_tex_image.c
index 37c8e24f03..60028bb67a 100644
--- a/src/mesa/drivers/dri/i965/intel_tex_image.c
+++ b/src/mesa/drivers/dri/i965/intel_tex_image.c
@@ -759,10 +759,18 @@ intel_get_tex_sub_image(struct gl_context *ctx,
DBG("%s\n", __func__);
 
if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) {
-  if (intel_gettexsubimage_blorp(brw, texImage,
- xoffset, yoffset, zoffset,
- width, height, depth, format, type,
- pixels, &ctx->Pack))
+  bool blorp_success;
+
+  brw->astc5x5_wa.blorp_sampling_from_astc5x5 =
+ (texImage->TexFormat == MESA_FORMAT_RGBA_ASTC_5x5 ||
+  texImage->TexFormat == MESA_FORMAT_SRGB8_ALPHA8_ASTC_5x5);
+  blorp_success = intel_gettexsubimage_blorp(brw, texImage,
+ xoffset, yoffset, zoffset,
+ width, height, depth,
+ format, type, pixels,
+ &ctx->Pack);
+  brw->astc5x5_wa.blorp_sampling_from_astc5x5 = false;
+  if (blorp_success)
  return;
 
   perf_debug("%s: fallback to CPU mapping in PBO case\n", __func__);
-- 
2.14.2

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 5/5] i965: use ASTC5x5 workaround in brw_compute

2017-12-01 Thread kevin . rogovin
From: Kevin Rogovin 

Perform the ASTC5x5 workaround tasks for compute; note that
the function does not do anything and immediately returns
if the bug is not present on the hardware.

Signed-off-by: Kevin Rogovin 
---
 src/mesa/drivers/dri/i965/brw_compute.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/brw_compute.c 
b/src/mesa/drivers/dri/i965/brw_compute.c
index 9be7523bab..e338539dc1 100644
--- a/src/mesa/drivers/dri/i965/brw_compute.c
+++ b/src/mesa/drivers/dri/i965/brw_compute.c
@@ -179,6 +179,12 @@ brw_dispatch_compute_common(struct gl_context *ctx)
 
brw_predraw_resolve_inputs(brw, false);
 
+   /* if necessary, perform astc5x5 workarounds to make sure any sampler does
+* not sample sample from a surface using an auxilary buffer within the
+* same batch of sampling from a surface with an ASTC5x5 format
+*/
+   brw_astc5x5_perform_wa(brw);
+
/* Flush the batch if the batch/state buffers are nearly full.  We can
 * grow them if needed, but this is not free, so we'd like to avoid it.
 */
-- 
2.14.2

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 1/5] i965: define astc5x5 workaround infrastructure

2017-12-01 Thread kevin . rogovin
From: Kevin Rogovin 

Some GEN's have a bug in the sample where if the sampler accesses
a texture with an auxialry surface and an ASTC5x5 texture without
having the texture cache invalidated between such accesses, then
the GPU will hang. This patch defines the infrastructure to
implement the needed workaround for such hardware.

Signed-off-by: Kevin Rogovin 
---
 src/mesa/drivers/dri/i965/brw_context.c   | 63 +++
 src/mesa/drivers/dri/i965/brw_context.h   | 23 ++
 src/mesa/drivers/dri/i965/intel_batchbuffer.c |  1 +
 3 files changed, 87 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/brw_context.c 
b/src/mesa/drivers/dri/i965/brw_context.c
index dd55b43669..f2e9b9779a 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -1060,6 +1060,12 @@ brwCreateContext(gl_api api,
if (ctx->Extensions.INTEL_performance_query)
   brw_init_performance_queries(brw);
 
+   brw->astc5x5_wa.required = (devinfo->gen == 9);
+   brw->astc5x5_wa.mode = BRW_ASTC5x5_WA_MODE_NONE;
+   brw->astc5x5_wa.texture_astc5x5_present = false;
+   brw->astc5x5_wa.texture_with_auxilary_present = false;
+   brw->astc5x5_wa.blorp_sampling_from_astc5x5 = false;
+
vbo_use_buffer_objects(ctx);
vbo_always_unmap_buffers(ctx);
 
@@ -1134,6 +1140,63 @@ intelDestroyContext(__DRIcontext * driContextPriv)
driContextPriv->driverPrivate = NULL;
 }
 
+void
+brw_set_astc5x5_wa_mode(struct brw_context *brw,
+enum brw_astc5x5_wa_mode_t mode)
+{
+   if (!brw->astc5x5_wa.required ||
+   mode == BRW_ASTC5x5_WA_MODE_NONE ||
+   brw->astc5x5_wa.mode == mode) {
+  return;
+   }
+
+   if (brw->astc5x5_wa.mode != BRW_ASTC5x5_WA_MODE_NONE) {
+  brw_emit_pipe_control_flush(brw, PIPE_CONTROL_TEXTURE_CACHE_INVALIDATE);
+   }
+
+   brw->astc5x5_wa.mode = mode;
+}
+
+static void
+resolve_to_disable_aux_on_samplers(struct brw_context *brw)
+{
+   struct gl_context *ctx = &brw->ctx;
+   const int max_enabled_unit = ctx->Texture._MaxEnabledTexImageUnit;
+
+   for (int unit = 0; unit <= max_enabled_unit; unit++) {
+  struct gl_texture_unit *tex_unit = &ctx->Texture.Unit[unit];
+  struct gl_texture_object *tex_obj = tex_unit->_Current;
+  if (tex_obj) {
+ struct intel_mipmap_tree *mt = intel_texture_object(tex_obj)->mt;
+ if (mt && mt->aux_usage != ISL_AUX_USAGE_NONE) {
+intel_miptree_prepare_access(brw, mt,
+ 0, INTEL_REMAINING_LEVELS,
+ 0, INTEL_REMAINING_LAYERS,
+ ISL_AUX_USAGE_NONE, false);
+ }
+  }
+   }
+}
+
+void
+brw_astc5x5_perform_wa(struct brw_context *brw)
+{
+   if (!brw->astc5x5_wa.required) {
+  return;
+   }
+
+   if (brw->astc5x5_wa.texture_astc5x5_present) {
+  if (brw->astc5x5_wa.texture_with_auxilary_present) {
+ /* resolve so that auxilary buffers are not needed
+  * by any sampler */
+ resolve_to_disable_aux_on_samplers(brw);
+  }
+  brw_set_astc5x5_wa_mode(brw, BRW_ASTC5x5_WA_MODE_HAS_ASTC5x5);
+   } else if (brw->astc5x5_wa.texture_with_auxilary_present) {
+  brw_set_astc5x5_wa_mode(brw, BRW_ASTC5x5_WA_MODE_HAS_AUX);
+   }
+}
+
 GLboolean
 intelUnbindContext(__DRIcontext * driContextPriv)
 {
diff --git a/src/mesa/drivers/dri/i965/brw_context.h 
b/src/mesa/drivers/dri/i965/brw_context.h
index b3d7c6baf8..37dfe45592 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -165,6 +165,12 @@ enum brw_cache_id {
BRW_MAX_CACHE
 };
 
+enum brw_astc5x5_wa_mode_t {
+   BRW_ASTC5x5_WA_MODE_NONE,
+   BRW_ASTC5x5_WA_MODE_HAS_ASTC5x5,
+   BRW_ASTC5x5_WA_MODE_HAS_AUX,
+};
+
 enum brw_state_id {
/* brw_cache_ids must come first - see brw_program_cache.c */
BRW_STATE_URB_FENCE = BRW_MAX_CACHE,
@@ -1230,6 +1236,18 @@ struct brw_context
 */
bool draw_aux_buffer_disabled[MAX_DRAW_BUFFERS];
 
+   /* Certain GEN's have a hardware bug where the sampler hangs if it attempts
+* to access auxilary buffers and an ASTC5x5 compressed buffer. The 
workaround
+* is to invalidate the texture cache between such access.
+*/
+   struct {
+  bool required;
+  enum brw_astc5x5_wa_mode_t mode;
+  bool texture_astc5x5_present;
+  bool texture_with_auxilary_present;
+  bool blorp_sampling_from_astc5x5;
+   } astc5x5_wa;
+
__DRIcontext *driContext;
struct intel_screen *screen;
 };
@@ -1663,6 +1681,11 @@ void brw_query_internal_format(struct gl_context *ctx, 
GLenum target,
GLenum internalFormat, GLenum pname,
GLint *params);
 
+/* brw_context::astc5x5_wa */
+void brw_set_astc5x5_wa_mode(struct brw_context *brw,
+ enum brw_astc5x5_wa_mode_t mode

[Mesa-dev] [PATCH 4/5] i965: use ASTC5x5 workaround in brw_draw

2017-12-01 Thread kevin . rogovin
From: Kevin Rogovin 

Perform the ASTC5x5 workaround tasks for drawing; note that
the function does not do anything and immediately returns
if the bug is not present on the hardware.

Signed-off-by: Kevin Rogovin 
---
 src/mesa/drivers/dri/i965/brw_draw.c | 6 ++
 src/mesa/drivers/dri/i965/brw_wm_surface_state.c | 5 +
 2 files changed, 11 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/brw_draw.c 
b/src/mesa/drivers/dri/i965/brw_draw.c
index 7e29dcfd4e..f335c2bd64 100644
--- a/src/mesa/drivers/dri/i965/brw_draw.c
+++ b/src/mesa/drivers/dri/i965/brw_draw.c
@@ -684,6 +684,12 @@ brw_prepare_drawing(struct gl_context *ctx,
brw_predraw_resolve_inputs(brw, true);
brw_predraw_resolve_framebuffer(brw);
 
+   /* if necessary, perform astc5x5 workarounds to make sure any sampler does
+* not sample sample from a surface using an auxilary buffer within the
+* same batch of sampling from a surface with an ASTC5x5 format
+*/
+   brw_astc5x5_perform_wa(brw);
+
/* Bind all inputs, derive varying and size information:
 */
brw_merge_inputs(brw, arrays);
diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c 
b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
index adf60a840b..ccdb537227 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
@@ -447,6 +447,11 @@ brw_aux_surface_disabled(const struct brw_context *brw,
 {
const struct gl_framebuffer *fb = brw->ctx.DrawBuffer;
 
+   if (brw->astc5x5_wa.required &&
+   brw->astc5x5_wa.texture_astc5x5_present) {
+  return true;
+   }
+
for (unsigned i = 0; i < fb->_NumColorDrawBuffers; i++) {
   const struct intel_renderbuffer *irb =
  intel_renderbuffer(fb->_ColorDrawBuffers[i]);
-- 
2.14.2

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 3/5] i965: set ASTC5x5 workaround texture type tracking on texture validate

2017-12-01 Thread kevin . rogovin
From: Kevin Rogovin 

One of the presteps in each draw (and compute) call is to validate
the textures. This is the perfect place (since all texture units
are looped through) to see if ASTC5x5 and/or textures with an
auxilary surface are accessed by the GPU.

Signed-off-by: Kevin Rogovin 
---
 src/mesa/drivers/dri/i965/intel_tex_validate.c | 13 +
 1 file changed, 13 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/intel_tex_validate.c 
b/src/mesa/drivers/dri/i965/intel_tex_validate.c
index 2b7798c940..812c0c7793 100644
--- a/src/mesa/drivers/dri/i965/intel_tex_validate.c
+++ b/src/mesa/drivers/dri/i965/intel_tex_validate.c
@@ -188,11 +188,24 @@ brw_validate_textures(struct brw_context *brw)
struct gl_context *ctx = &brw->ctx;
const int max_enabled_unit = ctx->Texture._MaxEnabledTexImageUnit;
 
+   brw->astc5x5_wa.texture_astc5x5_present = false;
+   brw->astc5x5_wa.texture_with_auxilary_present = false;
for (int unit = 0; unit <= max_enabled_unit; unit++) {
   struct gl_texture_unit *tex_unit = &ctx->Texture.Unit[unit];
 
   if (tex_unit->_Current) {
+ struct intel_texture_object *tex =
+intel_texture_object(tex_unit->_Current);
+ struct intel_mipmap_tree *mt = tex->mt;
+
  intel_finalize_mipmap_tree(brw, unit);
+ if (mt && mt->aux_usage != ISL_AUX_USAGE_NONE) {
+brw->astc5x5_wa.texture_with_auxilary_present = true;
+ }
+ if (tex->_Format == MESA_FORMAT_RGBA_ASTC_5x5 ||
+ tex->_Format == MESA_FORMAT_SRGB8_ALPHA8_ASTC_5x5) {
+brw->astc5x5_wa.texture_astc5x5_present = true;
+ }
   }
}
 }
-- 
2.14.2

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 0/3] GEM BO padding to find OOB buffer writes

2017-12-08 Thread kevin . rogovin
From: Kevin Rogovin 

This patch series adds a new debug option to pad each GEM BO
allocated by the brw_bufmgr with random noise values which
are then checked after each batchbuffer dispatch to the kernel.
This can be quite valuable to find diffucult to track down
heisenberg style bugs.

A possible follow-up series would be to write to stderr (or
another logging mechanism) if the OOB write is to a GEM BO that
backs a GL buffer object; that features would be quite useful for
application developers.

Kevin Rogovin (3):
  intel/common:add debug flag for adding and checking padding on BO's
  i965: add noise padding to buffer object and function to check if
noise is correct
  i965: if DEBUG_OUT_OF_BOUND_CHK is up, check that noise padding for
each bo used in batchbuffer is correct

 src/intel/common/gen_debug.c  |  1 +
 src/intel/common/gen_debug.h  |  1 +
 src/mesa/drivers/dri/i965/brw_bufmgr.c| 68 ++-
 src/mesa/drivers/dri/i965/brw_bufmgr.h| 12 +
 src/mesa/drivers/dri/i965/intel_batchbuffer.c | 15 ++
 5 files changed, 96 insertions(+), 1 deletion(-)

-- 
2.7.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 2/3] i965: add noise padding to buffer object and function to check if noise is correct

2017-12-08 Thread kevin . rogovin
From: Kevin Rogovin 

Signed-off-by: Kevin Rogovin 
---
 src/mesa/drivers/dri/i965/brw_bufmgr.c | 68 +-
 src/mesa/drivers/dri/i965/brw_bufmgr.h | 12 ++
 2 files changed, 79 insertions(+), 1 deletion(-)

diff --git a/src/mesa/drivers/dri/i965/brw_bufmgr.c 
b/src/mesa/drivers/dri/i965/brw_bufmgr.c
index 52b5bf9..7167165 100644
--- a/src/mesa/drivers/dri/i965/brw_bufmgr.c
+++ b/src/mesa/drivers/dri/i965/brw_bufmgr.c
@@ -367,7 +367,14 @@ retry:
   bo->size = bo_size;
   bo->idle = true;
 
-  struct drm_i915_gem_create create = { .size = bo_size };
+  bo->padding.size = 0;
+  bo->padding.value = NULL;
+  bo->padding.tmp = NULL;
+  if (unlikely(INTEL_DEBUG & DEBUG_OUT_OF_BOUND_CHK)) {
+ bo->padding.size = getpagesize();
+  }
+
+  struct drm_i915_gem_create create = { .size = bo_size + bo->padding.size 
};
 
   /* All new BOs we get from the kernel are zeroed, so we don't need to
* worry about that here.
@@ -378,6 +385,31 @@ retry:
  goto err;
   }
 
+  if (unlikely(bo->padding.size > 0)) {
+ struct drm_i915_gem_pwrite pwrite;
+
+ bo->padding.value = calloc(bo->padding.size, 1);
+ bo->padding.tmp = calloc(bo->padding.size, 1);
+ if (!bo->padding.value || !bo->padding.tmp) {
+goto err_free;
+ }
+
+ for (uint32_t i = 0; i < bo->padding.size; ++i) {
+bo->padding.value[i] = rand() & 0xFF;
+ }
+
+ pwrite.handle = create.handle;
+ pwrite.pad = 0;
+ pwrite.offset = bo_size;
+ pwrite.size = bo->padding.size;
+ pwrite.data_ptr = (__u64) (uintptr_t) bo->padding.value;
+ ret = drmIoctl(bufmgr->fd, DRM_IOCTL_I915_GEM_PWRITE, &pwrite);
+
+ if (ret != 0) {
+goto err_free;
+ }
+  }
+
   bo->gem_handle = create.handle;
 
   bo->bufmgr = bufmgr;
@@ -424,6 +456,26 @@ err:
return NULL;
 }
 
+bool
+brw_bo_padding_is_good(struct brw_bo *bo)
+{
+   if (bo->padding.size > 0) {
+  struct drm_i915_gem_pread pread;
+  int ret;
+
+  assert(bo->padding.tmp && bo->padding.value);
+  pread.handle = bo->gem_handle;
+  pread.pad = 0;
+  pread.offset = bo->size;
+  pread.size = bo->padding.size;
+  pread.data_ptr = (__u64) (uintptr_t) bo->padding.tmp;
+  ret = drmIoctl(bo->bufmgr->fd, DRM_IOCTL_I915_GEM_PREAD, &pread);
+  assert(ret == 0);
+  return memcmp(bo->padding.tmp, bo->padding.value, bo->padding.size) == 0;
+   }
+   return true;
+}
+
 struct brw_bo *
 brw_bo_alloc(struct brw_bufmgr *bufmgr,
  const char *name, uint64_t size, uint64_t alignment)
@@ -598,6 +650,17 @@ bo_free(struct brw_bo *bo)
   DBG("DRM_IOCTL_GEM_CLOSE %d failed (%s): %s\n",
   bo->gem_handle, bo->name, strerror(errno));
}
+
+   if (unlikely(INTEL_DEBUG & DEBUG_OUT_OF_BOUND_CHK)) {
+  if (bo->padding.value) {
+ free(bo->padding.value);
+  }
+
+  if (bo->padding.tmp) {
+ free(bo->padding.tmp);
+  }
+   }
+
free(bo);
 }
 
@@ -1156,6 +1219,9 @@ brw_bo_gem_create_from_prime(struct brw_bufmgr *bufmgr, 
int prime_fd)
bo->name = "prime";
bo->reusable = false;
bo->external = true;
+   bo->padding.size = 0;
+   bo->padding.value = NULL;
+   bo->padding.tmp = NULL;
 
struct drm_i915_gem_get_tiling get_tiling = { .handle = bo->gem_handle };
if (drmIoctl(bufmgr->fd, DRM_IOCTL_I915_GEM_GET_TILING, &get_tiling))
diff --git a/src/mesa/drivers/dri/i965/brw_bufmgr.h 
b/src/mesa/drivers/dri/i965/brw_bufmgr.h
index 0ae541c..4fff866 100644
--- a/src/mesa/drivers/dri/i965/brw_bufmgr.h
+++ b/src/mesa/drivers/dri/i965/brw_bufmgr.h
@@ -165,6 +165,16 @@ struct brw_bo {
 * Boolean of whether this buffer is cache coherent
 */
bool cache_coherent;
+
+   /**
+* pointer and size to memory holding values for padding for the
+* purpose of checking out-of-bound writes.
+*/
+   struct {
+  uint32_t size;
+  uint8_t *value;
+  uint8_t *tmp;
+   } padding;
 };
 
 #define BO_ALLOC_BUSY   (1<<0)
@@ -342,6 +352,8 @@ uint32_t brw_bo_export_gem_handle(struct brw_bo *bo);
 int brw_reg_read(struct brw_bufmgr *bufmgr, uint32_t offset,
  uint64_t *result);
 
+bool brw_bo_padding_is_good(struct brw_bo *bo);
+
 /** @{ */
 
 #if defined(__cplusplus)
-- 
2.7.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 1/3] intel/common:add debug flag for adding and checking padding on BO's

2017-12-08 Thread kevin . rogovin
From: Kevin Rogovin 

Signed-off-by: Kevin Rogovin 
---
 src/intel/common/gen_debug.c | 1 +
 src/intel/common/gen_debug.h | 1 +
 2 files changed, 2 insertions(+)

diff --git a/src/intel/common/gen_debug.c b/src/intel/common/gen_debug.c
index a978f2f..2154b23 100644
--- a/src/intel/common/gen_debug.c
+++ b/src/intel/common/gen_debug.c
@@ -85,6 +85,7 @@ static const struct debug_control debug_control[] = {
{ "nohiz",   DEBUG_NO_HIZ },
{ "color",   DEBUG_COLOR },
{ "reemit",  DEBUG_REEMIT },
+   { "check_oob",   DEBUG_OUT_OF_BOUND_CHK },
{ NULL,0 }
 };
 
diff --git a/src/intel/common/gen_debug.h b/src/intel/common/gen_debug.h
index da5b5a5..92fc68b 100644
--- a/src/intel/common/gen_debug.h
+++ b/src/intel/common/gen_debug.h
@@ -83,6 +83,7 @@ extern uint64_t INTEL_DEBUG;
 #define DEBUG_NO_HIZ  (1ull << 39)
 #define DEBUG_COLOR   (1ull << 40)
 #define DEBUG_REEMIT  (1ull << 41)
+#define DEBUG_OUT_OF_BOUND_CHK(1ull << 42)
 
 #ifdef HAVE_ANDROID_PLATFORM
 #define LOG_TAG "INTEL-MESA"
-- 
2.7.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 3/3] i965: if DEBUG_OUT_OF_BOUND_CHK is up, check that noise padding for each bo used in batchbuffer is correct

2017-12-08 Thread kevin . rogovin
From: Kevin Rogovin 

Signed-off-by: Kevin Rogovin 
---
 src/mesa/drivers/dri/i965/intel_batchbuffer.c | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/intel_batchbuffer.c 
b/src/mesa/drivers/dri/i965/intel_batchbuffer.c
index 91a6506..549ea3e 100644
--- a/src/mesa/drivers/dri/i965/intel_batchbuffer.c
+++ b/src/mesa/drivers/dri/i965/intel_batchbuffer.c
@@ -758,6 +758,7 @@ execbuffer(int fd,
};
 
unsigned long cmd = DRM_IOCTL_I915_GEM_EXECBUFFER2;
+   bool detected_out_of_bounds_write = false;
 
if (in_fence != -1) {
   execbuf.rsvd2 = in_fence;
@@ -787,6 +788,20 @@ execbuffer(int fd,
  batch->validation_list[i].offset);
  bo->gtt_offset = batch->validation_list[i].offset;
   }
+
+  if (unlikely(INTEL_DEBUG & DEBUG_OUT_OF_BOUND_CHK)) {
+ if (!brw_bo_padding_is_good(bo)) {
+detected_out_of_bounds_write = true;
+fprintf(stderr,
+"Detected buffer out-of-bounds write from brw_bo %p "
+"(GEM %u, label = \"%s\")\n",
+bo, bo->gem_handle, bo->name);
+ }
+  }
+   }
+
+   if (unlikely(detected_out_of_bounds_write)) {
+  abort();
}
 
if (ret == 0 && out_fence != NULL)
-- 
2.7.4

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 01/16] intel/tools: define BatchBufferLogger driver interface

2017-12-11 Thread kevin . rogovin
From: Kevin Rogovin 

Define the driver interface for BatchbufferLogger. The
interface assumes that for any -thread- there is only
one batchbuffer to which commands are to be added. A
driver needs to provide the information on what is the
active batchbuffer on a calling thread and also a function
that given a batchbuffer, returns where in the batchbuffer
the driver is currently "at".

Signed-off-by: Kevin Rogovin 
---
 src/intel/tools/i965_batchbuffer_logger.h | 185 ++
 1 file changed, 185 insertions(+)
 create mode 100644 src/intel/tools/i965_batchbuffer_logger.h

diff --git a/src/intel/tools/i965_batchbuffer_logger.h 
b/src/intel/tools/i965_batchbuffer_logger.h
new file mode 100644
index 00..d174af0e05
--- /dev/null
+++ b/src/intel/tools/i965_batchbuffer_logger.h
@@ -0,0 +1,185 @@
+/*
+ * Copyright © 2017 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#ifndef I965_BATCHBUFFER_LOGGER_DRIVER_H
+#define I965_BATCHBUFFER_LOGGER_DRIVER_H
+
+#include 
+#include 
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * i965_batchbuffer_logger tracks a batchbuffers
+ * by the pair (GEM-BO handle, File descriptor)
+ * pair.
+ */
+struct i965_logged_batchbuffer {
+   /**
+* GEM BO of the batch buffer, this is the BO
+* sent to kernel to execute commands on the
+* GPU
+*/
+   uint32_t gem_bo;
+
+   /**
+* The file descriptor of the GEM BO
+*/
+   int fd;
+
+   /**
+* Opaque pointer used by the driver associated
+* to the batch buffer; an i965_batchbuffer_logger
+* does NOT use this value to identify a batchbuffer.
+* It is for the driver to use to help it compute
+* where it is in a specified batchbuffer.
+*/
+   const void *driver_data;
+};
+
+/**
+ * A counter is to be used by a driver to provide counts of elements
+ * added to a batchbuffer when the counter is active. Actions acting
+ * on a counter are placed on the active batchbuffer of the calling
+ * thread, not executed immediately. The actual counting (in addition
+ * to activation, deactivation, reset, and relase) are performed when
+ * the batchbuffer is intercepted by the logger.
+ */
+struct i965_batchbuffer_counter {
+   void *opaque;
+};
+
+/**
+ * An i965_batchbuffer_logger object represents the hooking
+ * of a GPU driver.
+ */
+struct i965_batchbuffer_logger {
+   /**
+* To be called by the driver to instruct the batchbuffer logger
+* to clear the log associated to a GEM BO from an FD.
+*/
+   void (*clear_batchbuffer_log)(struct i965_batchbuffer_logger *logger,
+ int fd, uint32_t gem_bo);
+
+   /**
+* To be called by the driver if it migrates commands from one
+* batchbuffer to another batchbuffer.
+*/
+   void (*migrate_batchbuffer)(struct i965_batchbuffer_logger *logger,
+   const struct i965_logged_batchbuffer *from,
+   const struct i965_logged_batchbuffer *to);
+
+   /**
+* To be called by the driver to add log-message data to the
+* batchbuffer log. The message will be added to the log of
+* the batchbuffer dst. If counter is non-NULL the values
+* in the counter are also emitted to the log.
+*/
+   void (*add_message)(struct i965_batchbuffer_logger *logger,
+   const struct i965_logged_batchbuffer *dst,
+   const char *txt);
+
+   /**
+* call to release the i965_batchbuffer_logger
+*/
+   void (*release_driver)(struct i965_batchbuffer_logger *logger);
+
+   /**
+* Create a counter object. If filename is non-NULL, then
+* the values of the counter will be emitted to the named
+* file when the counter is deleted.
+*/
+   struct i965_batchbuffer_counter(*create_counter)(struct 
i965_batchbuffer_logger *logger,
+

[Mesa-dev] [PATCH 02/16] intel/tools: define BatchbufferLogger application interface

2017-12-11 Thread kevin . rogovin
From: Kevin Rogovin 

Define the application interface to BatchbufferLogger. The
BatchbufferLogger needs from the application when a GL/GLES
API call is issues and returns. It will use this information
to correctly correlate batchbuffer additions to GL/GLES API
calls.

In addition, because the BatchbufferLogger will be intercepting
drmIoctl, an application does NOT link against it. Instead, one
needs to LD_PRELOAD the .so.

Signed-off-by: Kevin Rogovin 
---
 src/intel/tools/i965_batchbuffer_logger_app.h | 186 ++
 1 file changed, 186 insertions(+)
 create mode 100644 src/intel/tools/i965_batchbuffer_logger_app.h

diff --git a/src/intel/tools/i965_batchbuffer_logger_app.h 
b/src/intel/tools/i965_batchbuffer_logger_app.h
new file mode 100644
index 00..6f131646e1
--- /dev/null
+++ b/src/intel/tools/i965_batchbuffer_logger_app.h
@@ -0,1 +1,186 @@
+/*
+ * Copyright © 2017 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#ifndef I965_BATCHBUFFER_LOGGER_APP_H
+#define I965_BATCHBUFFER_LOGGER_APP_H
+
+#include 
+#include 
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Enumeration value specifying the kind of data to write;
+ * Data written to a a i965_batchbuffer_logger_session
+ * can mark the start of a block, then end of a block
+ * of item within a block. Eac type has an optional
+ * name and value strings.
+ */
+enum i965_batchbuffer_logger_message_type_t {
+   I965_BATCHBUFFER_LOGGER_MESSAGE_BLOCK_BEGIN, /* start of a block */
+   I965_BATCHBUFFER_LOGGER_MESSAGE_BLOCK_END,   /* end of a block */
+   I965_BATCHBUFFER_LOGGER_MESSAGE_VALUE,   /* value in block */
+};
+
+/**
+ * An i965_batchbuffer_logger_session_params represents how
+ * to emit batchbuffer logger data. The batchbuffer logger
+ * is controlled by the following environmental variables:
+ * - I965_DECODE_BEFORE_IOCTL if non-zero, emit batchbuffer log data
+ *BEFORE calling the kernel ioctl.
+ * - I965_EMIT_TOTAL_STATS gives a filename to which to emit the total
+ * counts and lengths of GPU commands emitted
+ *  - I965_PCI_ID pci_id Give a hexadecimal value of the PCI ID value for
+ *   the GPU the BatchbufferLogger to decode for; this
+ *   value is used if and only if the driver fails to
+ *   tell the BatchbufferLogger a valid PCI ID value to
+ *   use
+ *  - I965_DECODE_LEVEL controls the level of batchbuffer decoding
+ * - no_decode do not decode batchbuffer at all
+ * - instruction_decode decode instruction name only
+ * - instruction_details_decode decode instruction contents
+ *  - I965_PRINT_RELOC_LEVEL controls at what level to print reloc data
+ * - print_reloc_nothing do not print reloc data
+ * - print_reloc_gem_gpu_updates print reloc data GEM by GEM
+ *  - I965_DECODE_SHADERS if set and is 0, shader binaries are written to
+ *file;  otherwise their disassembly is emitted
+ *in each session
+ */
+struct i965_batchbuffer_logger_session_params {
+   /**
+* Client data opaque pointer passed back to
+* function callbacks.
+*/
+   void *client_data;
+
+   /**
+* Function called by i965_batchbuffer_logger_app to write
+* data for the sessions.
+* \param client_data the pointer value in
+*i965_batchbuffer_logger_session_params::client_data
+* \param tp the message type
+* \param name of the data
+* \param name_length length of the name data
+* \param value of the data
+* \param value_length length of the value data
+*/
+   void (*write)(void *client_data,
+ enum i965_batchbuffer_logger_message_type_t tp,
+ const void *name, uint32_t name_length,
+ const void

[Mesa-dev] [PATCH 00/16] Batchbuffer Logger for Intel GPU (v3)

2017-12-11 Thread kevin . rogovin
From: Kevin Rogovin 

This patch series defines and implements a BatchbufferLogger
for Intel GEN. The main purpose of the BatchbufferLogger is
to strongly correlate API calls to data added to a batchbuffer.
In addition to this function, the BatchbufferLogger also tracks
GPU state (respecting HW context as well). The logger intercepts
drmIoctl recording the information needed to decode a bachbuffer
(such as GEM BO creation/deletion, HW context create/delete,
and most importantly execbuffer2). When the execbuffer2 returns
from the kernel, the BatchbufferLogger will log information
in its log of what was added when and in addition log the
GPU state (at the point in the batchbuffer) of 3DPRIMITIVE and
GPGPU_WALKER commands.

It is an application's requirment to tell the BatchbufferLogger
just before and just after an API call. Because of the need
to intercept drmIoctl, having an application link against
BatchbufferLogger is not robust. Instead, an application is
to use dlsym to fetch the correction a function pointer that
returns the BatchbufferLogger's application interface. The
interface of the BatchbufferLogger is defined in patch 0002.
A script is also provided to use the BatchbufferLogger in
an easier way than needing to set environmental variables.

On the subject of application integration, I have a -very-
small patch series that enabled BatchbufferLogger for
apitrace. I can share these patches if anyone asks, but I
cannot submit them to apitrace until atleast the BatchbufferLogger
is in Mesa with a stable application interface.

The log emitted by the BatchbufferLogger is a sequence of blocks
with possibility of blocks being elements of blocks. There is an
environmental variable to control if the top level blocks are
API call markers created from the calls into the BatchbufferLogger
from the application OR the actual ioctl intercepted with the
next level being the API call markers. An application starts
and ends a logging session. A session provides callbacks to
write the block data; with the interface of a callback a log
does not need to just write to a file, it could also write
over a network to remote application for the purpose of remote
debugging. A specific interface is also provided to write to a
file and additional tools are included to convert the log to JSON,
XML and text. The simple file format should allow others to be able
to take the data and use it however they see fit. The JSON output
alone can be quite illuminating to use when debugging/enhancing the
i965 driver for a single frame (or even single draw call) of a troublesome
application.

It is worth noting that i965 already has a batchbuffer decoder
dumper (also making use src/intel/tools/gen_decoder). However,
BatchbufferLogger has the following features which are not in the
current dumper and are likely quite tricky to implement into it.

 1. The biggest feature is that this BatchbufferLogger contents are
annotated by the GL/GLES API calls and driver text as well.
 2. This BatchbufferLogger provides an interface to application space
to allow for applications to start/end logging sessions as
they see fit. In addition, an application can have multilpe
independent sessions active.
 3. This BatchbufferLogger repeats the state of the GPU and HW
context on 3DPRIMITIVE and GPGPU_WALKER commands. By doing
so one can see the precise state the GPU is in at that command.
Coupled with (1), one can see what precise GPU state one
has when an application issues draw commands. Moreover, coupled
with the (previously) posted patches for apitrace, one
can compare differences at specific trace points within a
trace from apitrace to help diagnose regressions.

In addition, as suggested by Chris Wilson, I have also implemented an
i965 blackbox recorder at https://github.com/krogueintel/i965-blackbox
which will perform the necessary GL/GLES API interception to
produce annotated batchbuffer recordings to assist in GPU hang
debugging. The BatchbufferLogger (again at Chris Wilson's suggestion)
has the ability to walk batchbuffers BEFORE kernel submit and to
also add an EXEC_OBJECT_CAPTURE execobject2 whose contents are
the ID of the execbuffer2 ioctl submitted. The aim is to greatly
assist in GPU hang debugging for troublesome applications.

For those interested, this BatchbufferLogger is available on
github at https://github.com/krogueintel/asem/tree/batchbuffer-logger-v3.

The patch series is organized into the following blocks:

0001-0003: Define the BatchbufferLogger interfaces
0004-0004: Minor fix to i965 driver
0005-0005: Hooking of BatchbufferLogger into i965
0006-0009: Fixes and enhancements to intel/compiler,
   intel/tools and intel/common.
0010-0011: Implementation of BatchBufferLogger
0012-0014: Tools to decode log to JSON, XML and text
0015-0015: Command line tool for disassembling shader
   binaries.
0016-0016: Meson build support

v3:
  As requested by Matt Turner, inst

[Mesa-dev] [PATCH 05/16] i965: Enable BatchbufferLogger in i965 driver

2017-12-11 Thread kevin . rogovin
From: Kevin Rogovin 

The interface for BatchbufferLogger is that it is active
only if it is LD_PRELOAD'ed. Thus, the i965 driver is to
use dlsym to see if it is there, and if so fetch the object
at intel_screen creation.

Signed-off-by: Kevin Rogovin 
---
 src/mesa/drivers/dri/i965/brw_bufmgr.c| 22 -
 src/mesa/drivers/dri/i965/brw_bufmgr.h|  8 -
 src/mesa/drivers/dri/i965/brw_context.c   | 37 +
 src/mesa/drivers/dri/i965/brw_context.h   | 12 +++
 src/mesa/drivers/dri/i965/intel_batchbuffer.c | 30 +++--
 src/mesa/drivers/dri/i965/intel_screen.c  | 46 +--
 src/mesa/drivers/dri/i965/intel_screen.h  |  3 ++
 7 files changed, 150 insertions(+), 8 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_bufmgr.c 
b/src/mesa/drivers/dri/i965/brw_bufmgr.c
index 52b5bf97a1..c5b1bfb83d 100644
--- a/src/mesa/drivers/dri/i965/brw_bufmgr.c
+++ b/src/mesa/drivers/dri/i965/brw_bufmgr.c
@@ -65,6 +65,8 @@
 #include "string.h"
 
 #include "i915_drm.h"
+#include "intel_screen.h"
+#include "tools/i965_batchbuffer_logger.h"
 
 #ifdef HAVE_VALGRIND
 #include 
@@ -104,6 +106,7 @@ struct bo_cache_bucket {
 };
 
 struct brw_bufmgr {
+   struct intel_screen *screen;
int fd;
 
mtx_t lock;
@@ -631,9 +634,14 @@ bo_unreference_final(struct brw_bo *bo, time_t time)
 {
struct brw_bufmgr *bufmgr = bo->bufmgr;
struct bo_cache_bucket *bucket;
+   struct i965_batchbuffer_logger *bb_logger =
+  bufmgr->screen->batchbuffer_logger;
 
DBG("bo_unreference final: %d (%s)\n", bo->gem_handle, bo->name);
 
+   if(bb_logger != NULL) {
+  bb_logger->clear_batchbuffer_log(bb_logger, bufmgr->fd, bo->gem_handle);
+   }
bucket = bucket_for_size(bufmgr, bo->size);
/* Put the buffer into our internal cache for reuse if we can. */
if (bufmgr->bo_reuse && bo->reusable && bucket != NULL &&
@@ -1065,6 +1073,12 @@ brw_bufmgr_destroy(struct brw_bufmgr *bufmgr)
free(bufmgr);
 }
 
+int
+brw_bufmgr_fd(const struct brw_bufmgr *bufmgr)
+{
+   return bufmgr->fd;
+}
+
 static int
 bo_set_tiling_internal(struct brw_bo *bo, uint32_t tiling_mode,
uint32_t stride)
@@ -1369,9 +1383,14 @@ gem_param(int fd, int name)
  * \param fd File descriptor of the opened DRM device.
  */
 struct brw_bufmgr *
-brw_bufmgr_init(struct gen_device_info *devinfo, int fd)
+brw_bufmgr_init(struct intel_screen *screen)
 {
struct brw_bufmgr *bufmgr;
+   struct gen_device_info *devinfo;
+   int fd;
+
+   devinfo = &screen->devinfo;
+   fd = screen->driScrnPriv->fd;
 
bufmgr = calloc(1, sizeof(*bufmgr));
if (bufmgr == NULL)
@@ -1387,6 +1406,7 @@ brw_bufmgr_init(struct gen_device_info *devinfo, int fd)
 * fd so that its namespace does not clash with another.
 */
bufmgr->fd = fd;
+   bufmgr->screen = screen;
 
if (mtx_init(&bufmgr->lock, mtx_plain) != 0) {
   free(bufmgr);
diff --git a/src/mesa/drivers/dri/i965/brw_bufmgr.h 
b/src/mesa/drivers/dri/i965/brw_bufmgr.h
index 0ae541cda0..b5d724be7b 100644
--- a/src/mesa/drivers/dri/i965/brw_bufmgr.h
+++ b/src/mesa/drivers/dri/i965/brw_bufmgr.h
@@ -46,6 +46,7 @@ extern "C" {
 
 struct gen_device_info;
 struct brw_context;
+struct intel_screen;
 
 struct brw_bo {
/**
@@ -274,6 +275,11 @@ void brw_bo_wait_rendering(struct brw_bo *bo);
  */
 void brw_bufmgr_destroy(struct brw_bufmgr *bufmgr);
 
+/**
+ * Returns the file descriptor of the buffer manager
+ */
+int brw_bufmgr_fd(const struct brw_bufmgr *bufmgr);
+
 /**
  * Get the current tiling (and resulting swizzling) mode for the bo.
  *
@@ -313,7 +319,7 @@ int brw_bo_busy(struct brw_bo *bo);
 int brw_bo_madvise(struct brw_bo *bo, int madv);
 
 /* drm_bacon_bufmgr_gem.c */
-struct brw_bufmgr *brw_bufmgr_init(struct gen_device_info *devinfo, int fd);
+struct brw_bufmgr *brw_bufmgr_init(struct intel_screen *screen);
 struct brw_bo *brw_bo_gem_create_from_name(struct brw_bufmgr *bufmgr,
const char *name,
unsigned int handle);
diff --git a/src/mesa/drivers/dri/i965/brw_context.c 
b/src/mesa/drivers/dri/i965/brw_context.c
index 126c187f62..b5e041bb7b 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -75,6 +75,8 @@
 #include "util/debug.h"
 #include "isl/isl.h"
 
+#include "tools/i965_batchbuffer_logger.h"
+
 /***
  * Mesa's Driver Functions
  ***/
@@ -1075,6 +1077,7 @@ brwCreateContext(gl_api api,
 
vbo_use_buffer_objects(ctx);
vbo_always_unmap_buffers(ctx);
+   brw->have_active_batchbuffer = true;
 
brw_disk_cache_init(brw);
 
@@ -1089,6 +1092,7 @@ intelDestroyContext(__DRIcontext * driCont

[Mesa-dev] [PATCH 04/16] i965: assign BindingTableEntryCount of INTERFACE_DESCRIPTOR_DATA

2017-12-11 Thread kevin . rogovin
From: Kevin Rogovin 

Signed-off-by: Kevin Rogovin 
---
 src/mesa/drivers/dri/i965/genX_state_upload.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/mesa/drivers/dri/i965/genX_state_upload.c 
b/src/mesa/drivers/dri/i965/genX_state_upload.c
index 04a492539a..3643d79231 100644
--- a/src/mesa/drivers/dri/i965/genX_state_upload.c
+++ b/src/mesa/drivers/dri/i965/genX_state_upload.c
@@ -4259,6 +4259,7 @@ genX(upload_cs_state)(struct brw_context *brw)
   .SamplerStatePointer = stage_state->sampler_offset,
   .SamplerCount = DIV_ROUND_UP(CLAMP(stage_state->sampler_count, 0, 16), 
4),
   .BindingTablePointer = stage_state->bind_bo_offset,
+  .BindingTableEntryCount = prog_data->binding_table.size_bytes / 4,
   .ConstantURBEntryReadLength = cs_prog_data->push.per_thread.regs,
   .NumberofThreadsinGPGPUThreadGroup = cs_prog_data->threads,
   .SharedLocalMemorySize = encode_slm_size(GEN_GEN,
-- 
2.15.0

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


  1   2   >