[Mesa-dev] [PATCH 18/42] i965/blorp: introduce separate eu-emitter for blit compiler
Topi Pohjolainen
topi.pohjolainen at intel.com
Fri Dec 20 06:38:47 PST 2013
Prepares for presenting blorp blit programs using FS IR that
allows EU-assembly generation using i965 glsl-compiler
backend (fs_generator).
Signed-off-by: Topi Pohjolainen <topi.pohjolainen at intel.com>
---
src/mesa/drivers/dri/i965/Makefile.sources | 1 +
src/mesa/drivers/dri/i965/brw_blorp_blit.cpp | 41 ++--------------
src/mesa/drivers/dri/i965/brw_blorp_blit_eu.cpp | 63 +++++++++++++++++++++++++
src/mesa/drivers/dri/i965/brw_blorp_blit_eu.h | 42 +++++++++++++++++
4 files changed, 111 insertions(+), 36 deletions(-)
create mode 100644 src/mesa/drivers/dri/i965/brw_blorp_blit_eu.cpp
create mode 100644 src/mesa/drivers/dri/i965/brw_blorp_blit_eu.h
diff --git a/src/mesa/drivers/dri/i965/Makefile.sources b/src/mesa/drivers/dri/i965/Makefile.sources
index 43f152e..2845844 100644
--- a/src/mesa/drivers/dri/i965/Makefile.sources
+++ b/src/mesa/drivers/dri/i965/Makefile.sources
@@ -30,6 +30,7 @@ i965_FILES = \
brw_binding_tables.c \
brw_blorp.cpp \
brw_blorp_blit.cpp \
+ brw_blorp_blit_eu.cpp \
brw_blorp_clear.cpp \
brw_cc.c \
brw_cfg.cpp \
diff --git a/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp b/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp
index 6de4dc2..836d5a6 100644
--- a/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp
+++ b/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp
@@ -25,13 +25,11 @@
#include "main/fbobject.h"
#include "main/renderbuffer.h"
-#include "glsl/ralloc.h"
-
#include "intel_fbo.h"
#include "brw_blorp.h"
#include "brw_context.h"
-#include "brw_eu.h"
+#include "brw_blorp_blit_eu.h"
#include "brw_state.h"
#define FILE_DEBUG_FLAG DEBUG_BLORP
@@ -624,12 +622,11 @@ enum sampler_message_arg
* (In these formulas, pitch is the number of bytes occupied by a single row
* of samples).
*/
-class brw_blorp_blit_program
+class brw_blorp_blit_program : public brw_blorp_eu_emitter
{
public:
brw_blorp_blit_program(struct brw_context *brw,
const brw_blorp_blit_prog_key *key);
- ~brw_blorp_blit_program();
const GLuint *compile(struct brw_context *brw, GLuint *program_size,
FILE *dump_file = stdout);
@@ -663,10 +660,8 @@ private:
*/
static const unsigned LOG2_MAX_BLEND_SAMPLES = 3;
- void *mem_ctx;
struct brw_context *brw;
const brw_blorp_blit_prog_key *key;
- struct brw_compile func;
/* Thread dispatch header */
struct brw_reg R0;
@@ -740,16 +735,10 @@ private:
brw_blorp_blit_program::brw_blorp_blit_program(
struct brw_context *brw,
const brw_blorp_blit_prog_key *key)
- : mem_ctx(ralloc_context(NULL)),
+ : brw_blorp_eu_emitter(brw),
brw(brw),
key(key)
{
- brw_init_compile(brw, &func, mem_ctx);
-}
-
-brw_blorp_blit_program::~brw_blorp_blit_program()
-{
- ralloc_free(mem_ctx);
}
const GLuint *
@@ -801,21 +790,6 @@ brw_blorp_blit_program::compile(struct brw_context *brw,
memset(&prog_data, 0, sizeof(prog_data));
prog_data.persample_msaa_dispatch = key->persample_msaa_dispatch;
- /*
- * By default everything is emitted as 16-wide with only a few expections
- * handled explicitly either here in the compiler or by one of the specific
- * code emission calls.
- * It should be also noted that here in this file any alterations of the
- * compression control settings are only used to affect the execution size
- * of the instructions. The instruction template used to initialise all the
- * instructions is effectively not altered -- the value stays at zero
- * representing either GEN6_COMPRESSION_1Q or GEN6_COMPRESSION_1H depending
- * on the context.
- * If any other settings are used in the instruction headers, they are set
- * elsewhere by the individual code emission calls.
- */
- brw_set_compression_control(&func, BRW_COMPRESSION_COMPRESSED);
-
alloc_regs();
compute_frag_coords();
@@ -923,12 +897,7 @@ brw_blorp_blit_program::compile(struct brw_context *brw,
*/
render_target_write();
- if (unlikely(INTEL_DEBUG & DEBUG_BLORP)) {
- printf("Native code for BLORP blit:\n");
- brw_dump_compile(&func, dump_file, 0, func.next_insn_offset);
- printf("\n");
- }
- return brw_get_program(&func, program_size);
+ return get_program(program_size, dump_file);
}
void
@@ -2367,7 +2336,7 @@ brw_blorp_blit_params::get_wm_prog(struct brw_context *brw,
&prog_offset, prog_data)) {
brw_blorp_blit_program prog(brw, &this->wm_prog_key);
GLuint program_size;
- const GLuint *program = prog.compile(brw, &program_size);
+ const GLuint *program = prog.compile(brw, &program_size, stdout);
brw_upload_cache(&brw->cache, BRW_BLORP_BLIT_PROG,
&this->wm_prog_key, sizeof(this->wm_prog_key),
program, program_size,
diff --git a/src/mesa/drivers/dri/i965/brw_blorp_blit_eu.cpp b/src/mesa/drivers/dri/i965/brw_blorp_blit_eu.cpp
new file mode 100644
index 0000000..8e24f80
--- /dev/null
+++ b/src/mesa/drivers/dri/i965/brw_blorp_blit_eu.cpp
@@ -0,0 +1,63 @@
+/*
+ * Copyright © 2013 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 "glsl/ralloc.h"
+#include "brw_blorp_blit_eu.h"
+
+brw_blorp_eu_emitter::brw_blorp_eu_emitter(struct brw_context *brw)
+ : mem_ctx(ralloc_context(NULL))
+{
+ brw_init_compile(brw, &func, mem_ctx);
+
+ /*
+ * By default everything is emitted as 16-wide with only a few expections
+ * handled explicitly either here in the compiler or by one of the specific
+ * code emission calls.
+ * It should be also noted that here in this file any alterations of the
+ * compression control settings are only used to affect the execution size
+ * of the instructions. The instruction template used to initialise all the
+ * instructions is effectively not altered -- the value stays at zero
+ * representing either GEN6_COMPRESSION_1Q or GEN6_COMPRESSION_1H depending
+ * on the context.
+ * If any other settings are used in the instruction headers, they are set
+ * elsewhere by the individual code emission calls.
+ */
+ brw_set_compression_control(&func, BRW_COMPRESSION_COMPRESSED);
+}
+
+brw_blorp_eu_emitter::~brw_blorp_eu_emitter()
+{
+ ralloc_free(mem_ctx);
+}
+
+const unsigned *
+brw_blorp_eu_emitter::get_program(unsigned *program_size, FILE *dump_file)
+{
+ if (unlikely(INTEL_DEBUG & DEBUG_BLORP)) {
+ printf("Native code for BLORP blit:\n");
+ brw_dump_compile(&func, dump_file, 0, func.next_insn_offset);
+ printf("\n");
+ }
+
+ return brw_get_program(&func, program_size);
+}
diff --git a/src/mesa/drivers/dri/i965/brw_blorp_blit_eu.h b/src/mesa/drivers/dri/i965/brw_blorp_blit_eu.h
new file mode 100644
index 0000000..1bcb0d9
--- /dev/null
+++ b/src/mesa/drivers/dri/i965/brw_blorp_blit_eu.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright © 2013 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 BRW_BLORP_BLIT_EU_H
+#define BRW_BLORP_BLIT_EU_H
+
+#include "brw_context.h"
+#include "brw_eu.h"
+
+class brw_blorp_eu_emitter
+{
+protected:
+ explicit brw_blorp_eu_emitter(struct brw_context *brw);
+ ~brw_blorp_eu_emitter();
+
+ const unsigned *get_program(unsigned *program_size, FILE *dump_file);
+
+ void *mem_ctx;
+ struct brw_compile func;
+};
+
+#endif /* BRW_BLORP_BLIT_EU_H */
--
1.8.3.1
More information about the mesa-dev
mailing list