[Mesa-dev] [PATCH 02/23] i965: Do better fake context setup in unit tests

Jason Ekstrand jason at jlekstrand.net
Fri Apr 17 19:11:42 PDT 2015


In future tests, we will start relying on devinfo and not just brw in the
compiler.  Changing this now keeps these tests from failing in the future.
---
 src/mesa/drivers/dri/i965/test_eu_compact.c                | 5 ++++-
 src/mesa/drivers/dri/i965/test_fs_cmod_propagation.cpp     | 6 +++++-
 src/mesa/drivers/dri/i965/test_fs_saturate_propagation.cpp | 6 +++++-
 src/mesa/drivers/dri/i965/test_vec4_copy_propagation.cpp   | 6 +++++-
 src/mesa/drivers/dri/i965/test_vec4_register_coalesce.cpp  | 6 +++++-
 5 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/test_eu_compact.c b/src/mesa/drivers/dri/i965/test_eu_compact.c
index d95d2c0..f461654 100644
--- a/src/mesa/drivers/dri/i965/test_eu_compact.c
+++ b/src/mesa/drivers/dri/i965/test_eu_compact.c
@@ -291,7 +291,10 @@ int
 main(int argc, char **argv)
 {
    struct brw_context *brw = calloc(1, sizeof(*brw));
-   brw->gen = 6;
+   struct brw_device_info *devinfo = calloc(1, sizeof(*devinfo));
+   brw->intelScreen = calloc(1, sizeof(*brw->intelScreen));
+   brw->intelScreen->devinfo = devinfo;
+   brw->gen = devinfo->gen = 6;
    bool fail = false;
 
    for (brw->gen = 6; brw->gen <= 7; brw->gen++) {
diff --git a/src/mesa/drivers/dri/i965/test_fs_cmod_propagation.cpp b/src/mesa/drivers/dri/i965/test_fs_cmod_propagation.cpp
index ed8744d..206a76e 100644
--- a/src/mesa/drivers/dri/i965/test_fs_cmod_propagation.cpp
+++ b/src/mesa/drivers/dri/i965/test_fs_cmod_propagation.cpp
@@ -31,6 +31,7 @@ class cmod_propagation_test : public ::testing::Test {
 
 public:
    struct brw_context *brw;
+   struct brw_device_info *devinfo;
    struct gl_context *ctx;
    struct brw_wm_prog_data *prog_data;
    struct gl_shader_program *shader_prog;
@@ -51,6 +52,9 @@ public:
 void cmod_propagation_test::SetUp()
 {
    brw = (struct brw_context *)calloc(1, sizeof(*brw));
+   devinfo = (struct brw_device_info *)calloc(1, sizeof(*brw));
+   brw->intelScreen = (struct intel_screen *)calloc(1, sizeof(*brw->intelScreen));
+   brw->intelScreen->devinfo = devinfo;
    ctx = &brw->ctx;
 
    fp = ralloc(NULL, struct brw_fragment_program);
@@ -61,7 +65,7 @@ void cmod_propagation_test::SetUp()
 
    _mesa_init_fragment_program(ctx, &fp->program, GL_FRAGMENT_SHADER, 0);
 
-   brw->gen = 4;
+   brw->gen = devinfo->gen = 4;
 }
 
 static fs_inst *
diff --git a/src/mesa/drivers/dri/i965/test_fs_saturate_propagation.cpp b/src/mesa/drivers/dri/i965/test_fs_saturate_propagation.cpp
index 6f762bc..4c91af3 100644
--- a/src/mesa/drivers/dri/i965/test_fs_saturate_propagation.cpp
+++ b/src/mesa/drivers/dri/i965/test_fs_saturate_propagation.cpp
@@ -31,6 +31,7 @@ class saturate_propagation_test : public ::testing::Test {
 
 public:
    struct brw_context *brw;
+   struct brw_device_info *devinfo;
    struct gl_context *ctx;
    struct brw_wm_prog_data *prog_data;
    struct gl_shader_program *shader_prog;
@@ -51,6 +52,9 @@ public:
 void saturate_propagation_test::SetUp()
 {
    brw = (struct brw_context *)calloc(1, sizeof(*brw));
+   devinfo = (struct brw_device_info *)calloc(1, sizeof(*brw));
+   brw->intelScreen = (struct intel_screen *)calloc(1, sizeof(*brw->intelScreen));
+   brw->intelScreen->devinfo = devinfo;
    ctx = &brw->ctx;
 
    fp = ralloc(NULL, struct brw_fragment_program);
@@ -61,7 +65,7 @@ void saturate_propagation_test::SetUp()
 
    _mesa_init_fragment_program(ctx, &fp->program, GL_FRAGMENT_SHADER, 0);
 
-   brw->gen = 4;
+   brw->gen = devinfo->gen = 4;
 }
 
 static fs_inst *
diff --git a/src/mesa/drivers/dri/i965/test_vec4_copy_propagation.cpp b/src/mesa/drivers/dri/i965/test_vec4_copy_propagation.cpp
index f9e4ce1..2ef52e9 100644
--- a/src/mesa/drivers/dri/i965/test_vec4_copy_propagation.cpp
+++ b/src/mesa/drivers/dri/i965/test_vec4_copy_propagation.cpp
@@ -34,6 +34,7 @@ class copy_propagation_test : public ::testing::Test {
 
 public:
    struct brw_context *brw;
+   struct brw_device_info *devinfo;
    struct gl_context *ctx;
    struct gl_shader_program *shader_prog;
    struct brw_vertex_program *vp;
@@ -93,6 +94,9 @@ protected:
 void copy_propagation_test::SetUp()
 {
    brw = (struct brw_context *)calloc(1, sizeof(*brw));
+   devinfo = (struct brw_device_info *)calloc(1, sizeof(*brw));
+   brw->intelScreen = (struct intel_screen *)calloc(1, sizeof(*brw->intelScreen));
+   brw->intelScreen->devinfo = devinfo;
    ctx = &brw->ctx;
 
    vp = ralloc(NULL, struct brw_vertex_program);
@@ -103,7 +107,7 @@ void copy_propagation_test::SetUp()
 
    _mesa_init_vertex_program(ctx, &vp->program, GL_VERTEX_SHADER, 0);
 
-   brw->gen = 4;
+   brw->gen = devinfo->gen = 4;
 }
 
 static void
diff --git a/src/mesa/drivers/dri/i965/test_vec4_register_coalesce.cpp b/src/mesa/drivers/dri/i965/test_vec4_register_coalesce.cpp
index 17bece5..c8c6757 100644
--- a/src/mesa/drivers/dri/i965/test_vec4_register_coalesce.cpp
+++ b/src/mesa/drivers/dri/i965/test_vec4_register_coalesce.cpp
@@ -36,6 +36,7 @@ class register_coalesce_test : public ::testing::Test {
 
 public:
    struct brw_context *brw;
+   struct brw_device_info *devinfo;
    struct gl_context *ctx;
    struct gl_shader_program *shader_prog;
    struct brw_vertex_program *vp;
@@ -96,6 +97,9 @@ protected:
 void register_coalesce_test::SetUp()
 {
    brw = (struct brw_context *)calloc(1, sizeof(*brw));
+   devinfo = (struct brw_device_info *)calloc(1, sizeof(*brw));
+   brw->intelScreen = (struct intel_screen *)calloc(1, sizeof(*brw->intelScreen));
+   brw->intelScreen->devinfo = devinfo;
    ctx = &brw->ctx;
 
    vp = ralloc(NULL, struct brw_vertex_program);
@@ -106,7 +110,7 @@ void register_coalesce_test::SetUp()
 
    _mesa_init_vertex_program(ctx, &vp->program, GL_VERTEX_SHADER, 0);
 
-   brw->gen = 4;
+   brw->gen = devinfo->gen = 4;
 }
 
 static void
-- 
2.3.5



More information about the mesa-dev mailing list