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

Paul Berry stereotype441 at gmail.com
Tue Aug 20 11:30:18 PDT 2013


---
 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(-)

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
-- 
1.8.3.4



More information about the mesa-dev mailing list