Re: [Mesa-dev] [PATCH 03/30] i965: Make brw_{program, shader, vec4, vs}.h safe to include from C++.

2013-08-21 Thread Paul Berry
On 20 August 2013 11:58, Kenneth Graunke kenn...@whitecape.org wrote:

 On 08/20/2013 11:30 AM, Paul Berry wrote:

 ---
   src/mesa/drivers/dri/i965/brw_**program.h  |  8 
   src/mesa/drivers/dri/i965/brw_**shader.cpp |  2 +-
   src/mesa/drivers/dri/i965/brw_**shader.h   |  7 ++-
   src/mesa/drivers/dri/i965/brw_**vec4.h | 12 ++--
   src/mesa/drivers/dri/i965/brw_**vs.h   |  8 
   5 files changed, 33 insertions(+), 4 deletions(-)


 I like the change to brw_program.h and brw_vs.h.  But I'm confused by the
 changes to brw_shader.h and brw_vec4.h---those are already only used by C++
 code, and full of C++ stuff.

 Perhaps you're making them safe to include from C, for some reason?


Yeah, sorry.  I got confused at some point while I was rebasing this series
and squashed together two unrelated patches.  You're right that the changes
to brw_shader.h and brw_vec4.h are to make them safe to include from C.
They're needed for patch 6 (i965/vec4: Move vec4 data structures and
functions to brw_vec4.{cpp,h}).  How about if I split those changes out to
their own patch, put it just before patch 6, and make the commit message
something like this?

Make brw_{shader,vec4}.h safe to include from C.

The patch that follows will move the definition of struct brw_vec4_prog_key
from brw_vs.h to brw_vec4.h, making it necessary for brw_vs.h to include
brw_vec4.h (because brw_vs.h defines struct brw_vs_prog_key, which contains
brw_vec4_prog_key as a member).  Since brw_vs.h is included from C source
files, that means that brw_vec4.h will need to be safe to include from C.
Same for brw_shader.h, since it is included by brw_vec4.h.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 03/30] i965: Make brw_{program, shader, vec4, vs}.h safe to include from C++.

2013-08-21 Thread Kenneth Graunke

On 08/21/2013 07:54 AM, Paul Berry wrote:

On 20 August 2013 11:58, Kenneth Graunke kenn...@whitecape.org
mailto:kenn...@whitecape.org wrote:

On 08/20/2013 11:30 AM, Paul Berry wrote:

---
   src/mesa/drivers/dri/i965/brw___program.h  |  8 
   src/mesa/drivers/dri/i965/brw___shader.cpp |  2 +-
   src/mesa/drivers/dri/i965/brw___shader.h   |  7 ++-
   src/mesa/drivers/dri/i965/brw___vec4.h | 12 ++--
   src/mesa/drivers/dri/i965/brw___vs.h   |  8 
   5 files changed, 33 insertions(+), 4 deletions(-)


I like the change to brw_program.h and brw_vs.h.  But I'm confused
by the changes to brw_shader.h and brw_vec4.h---those are already
only used by C++ code, and full of C++ stuff.

Perhaps you're making them safe to include from C, for some reason?


Yeah, sorry.  I got confused at some point while I was rebasing this
series and squashed together two unrelated patches.  You're right that
the changes to brw_shader.h and brw_vec4.h are to make them safe to
include from C.  They're needed for patch 6 (i965/vec4: Move vec4 data
structures and functions to brw_vec4.{cpp,h}).  How about if I split
those changes out to their own patch, put it just before patch 6, and
make the commit message something like this?

Make brw_{shader,vec4}.h safe to include from C.

The patch that follows will move the definition of struct
brw_vec4_prog_key from brw_vs.h to brw_vec4.h, making it necessary for
brw_vs.h to include brw_vec4.h (because brw_vs.h defines struct
brw_vs_prog_key, which contains brw_vec4_prog_key as a member).  Since
brw_vs.h is included from C source files, that means that brw_vec4.h
will need to be safe to include from C.  Same for brw_shader.h, since it
is included by brw_vec4.h.


Sounds good to me.  I don't know that you really need to split it into 
two patches, but some comments might be nice.


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


Re: [Mesa-dev] [PATCH 03/30] i965: Make brw_{program, shader, vec4, vs}.h safe to include from C++.

2013-08-20 Thread Kenneth Graunke

On 08/20/2013 11:30 AM, Paul Berry wrote:

---
  src/mesa/drivers/dri/i965/brw_program.h  |  8 
  src/mesa/drivers/dri/i965/brw_shader.cpp |  2 +-
  src/mesa/drivers/dri/i965/brw_shader.h   |  7 ++-
  src/mesa/drivers/dri/i965/brw_vec4.h | 12 ++--
  src/mesa/drivers/dri/i965/brw_vs.h   |  8 
  5 files changed, 33 insertions(+), 4 deletions(-)


I like the change to brw_program.h and brw_vs.h.  But I'm confused by 
the changes to brw_shader.h and brw_vec4.h---those are already only used 
by C++ code, and full of C++ stuff.


Perhaps you're making them safe to include from C, for some reason?

I'll keep reading and see if it eventually makes sense.


diff --git a/src/mesa/drivers/dri/i965/brw_program.h 
b/src/mesa/drivers/dri/i965/brw_program.h
index a2997e7..e2ddaa8 100644
--- a/src/mesa/drivers/dri/i965/brw_program.h
+++ b/src/mesa/drivers/dri/i965/brw_program.h
@@ -42,6 +42,10 @@ struct brw_sampler_prog_key_data {
 uint16_t yuvtex_swap_mask; /** UV swaped */
  };

+#ifdef __cplusplus
+extern C {
+#endif
+
  void brw_populate_sampler_prog_key_data(struct gl_context *ctx,
const struct gl_program *prog,
  unsigned sampler_count,
@@ -51,4 +55,8 @@ bool brw_debug_recompile_sampler_key(struct brw_context *brw,
   const struct brw_sampler_prog_key_data 
*key);
  void brw_add_texrect_params(struct gl_program *prog);

+#ifdef __cplusplus
+} /* extern C */
+#endif
+
  #endif
diff --git a/src/mesa/drivers/dri/i965/brw_shader.cpp 
b/src/mesa/drivers/dri/i965/brw_shader.cpp
index 6c7e827..afa14c5 100644
--- a/src/mesa/drivers/dri/i965/brw_shader.cpp
+++ b/src/mesa/drivers/dri/i965/brw_shader.cpp
@@ -24,8 +24,8 @@
  extern C {
  #include main/macros.h
  #include brw_context.h
-#include brw_vs.h
  }
+#include brw_vs.h
  #include brw_fs.h
  #include glsl/ir_optimization.h
  #include glsl/glsl_parser_extras.h
diff --git a/src/mesa/drivers/dri/i965/brw_shader.h 
b/src/mesa/drivers/dri/i965/brw_shader.h
index e7d3fb6..55769ff 100644
--- a/src/mesa/drivers/dri/i965/brw_shader.h
+++ b/src/mesa/drivers/dri/i965/brw_shader.h
@@ -38,6 +38,8 @@ enum register_file {
 UNIFORM, /* prog_data-params[reg] */
  };

+#ifdef __cplusplus
+
  class backend_instruction : public exec_node {
  public:
 bool is_tex();
@@ -71,8 +73,11 @@ public:
 void dump_instructions();
  };

+uint32_t brw_texture_offset(ir_constant *offset);
+
+#endif /* __cplusplus */
+
  int brw_type_for_base_type(const struct glsl_type *type);
  uint32_t brw_conditional_for_comparison(unsigned int op);
  uint32_t brw_math_function(enum opcode op);
-uint32_t brw_texture_offset(ir_constant *offset);
  const char *brw_instruction_name(enum opcode op);
diff --git a/src/mesa/drivers/dri/i965/brw_vec4.h 
b/src/mesa/drivers/dri/i965/brw_vec4.h
index 111b105..b6d4c4e 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.h
+++ b/src/mesa/drivers/dri/i965/brw_vec4.h
@@ -28,15 +28,22 @@
  #include brw_shader.h
  #include main/compiler.h
  #include program/hash_table.h
+#include brw_vs.h

+#ifdef __cplusplus
  extern C {
-#include brw_vs.h
+#endif
+
  #include brw_context.h
  #include brw_eu.h
-};
+
+#ifdef __cplusplus
+}; /* extern C */
+#endif

  #include glsl/ir.h

+#ifdef __cplusplus
  namespace brw {

  class dst_reg;
@@ -614,5 +621,6 @@ private:
  };

  } /* namespace brw */
+#endif /* __cplusplus */

  #endif /* BRW_VEC4_H */
diff --git a/src/mesa/drivers/dri/i965/brw_vs.h 
b/src/mesa/drivers/dri/i965/brw_vs.h
index 3d0b852..d51d7b6 100644
--- a/src/mesa/drivers/dri/i965/brw_vs.h
+++ b/src/mesa/drivers/dri/i965/brw_vs.h
@@ -111,6 +111,10 @@ struct brw_vs_compile {
 struct brw_vertex_program *vp;
  };

+#ifdef __cplusplus
+extern C {
+#endif
+
  const unsigned *brw_vs_emit(struct brw_context *brw,
  struct gl_shader_program *prog,
  struct brw_vs_compile *c,
@@ -128,4 +132,8 @@ bool brw_vs_prog_data_compare(const void *a, const void *b,
  void brw_vec4_prog_data_free(const struct brw_vec4_prog_data *prog_data);
  void brw_vs_prog_data_free(const void *in_prog_data);

+#ifdef __cplusplus
+} /* extern C */
+#endif
+
  #endif



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