[Mesa-dev] [v2 01/23] i965/blorp: introduce separate eu-emitter for blit compiler
Topi Pohjolainen
topi.pohjolainen at intel.com
Wed Jan 22 09:16:53 PST 2014
Prepares for presenting blorp blit programs using FS IR that
allows EU-assembly generation using i965 glsl-compiler
backend (fs_generator).
v2: rebased on top of endif-jump counter fix (moving the
added brw_set_uip_jip() into the emitter)
Signed-off-by: Topi Pohjolainen <topi.pohjolainen at intel.com>
Reviewed-by: Paul Berry <stereotype441 at gmail.com> (v1)
---
src/mesa/drivers/dri/i965/Makefile.sources | 1 +
src/mesa/drivers/dri/i965/brw_blorp_blit.cpp | 43 ++--------------
src/mesa/drivers/dri/i965/brw_blorp_blit_eu.cpp | 65 +++++++++++++++++++++++++
src/mesa/drivers/dri/i965/brw_blorp_blit_eu.h | 42 ++++++++++++++++
4 files changed, 113 insertions(+), 38 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 d0c85cf..a3fb417 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 3b92c56..f9c355b 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);
@@ -668,10 +665,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;
@@ -745,16 +740,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 *
@@ -806,21 +795,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 exceptions
- * 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();
@@ -928,14 +902,7 @@ brw_blorp_blit_program::compile(struct brw_context *brw,
*/
render_target_write();
- brw_set_uip_jip(&func);
-
- 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
@@ -2385,7 +2352,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..8d723d6
--- /dev/null
+++ b/src/mesa/drivers/dri/i965/brw_blorp_blit_eu.cpp
@@ -0,0 +1,65 @@
+/*
+ * 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)
+{
+ brw_set_uip_jip(&func);
+
+ 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