i965: Add genxml related plumbing in a new genX_state_upload.c file.
authorKenneth Graunke <kenneth@whitecape.org>
Wed, 8 Mar 2017 05:42:30 +0000 (21:42 -0800)
committerKenneth Graunke <kenneth@whitecape.org>
Thu, 4 May 2017 01:57:51 +0000 (18:57 -0700)
v3 (Rafael): Drop aub parameter
v4 (Ken): Squash in gen4/g45 automake fixes

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Signed-off-by: Rafael Antognolli <rafael.antognolli@intel.com>
src/mesa/drivers/dri/i965/Makefile.am
src/mesa/drivers/dri/i965/Makefile.sources
src/mesa/drivers/dri/i965/genX_state_upload.c [new file with mode: 0644]

index 4e9b062b28fcde7a3da5fea1d2f3d1e2601dc7ad..762aefc5542c2e7ce96333e5667ccbbd2f05d4bb 100644 (file)
@@ -46,12 +46,24 @@ AM_CFLAGS = \
 AM_CXXFLAGS = $(AM_CFLAGS)
 
 I965_PERGEN_LIBS = \
+       libi965_gen4.la \
+       libi965_gen45.la \
+       libi965_gen5.la \
        libi965_gen6.la \
        libi965_gen7.la \
        libi965_gen75.la \
        libi965_gen8.la \
        libi965_gen9.la
 
+libi965_gen4_la_SOURCES = $(i965_gen4_FILES)
+libi965_gen4_la_CFLAGS = $(AM_CFLAGS) -DGEN_VERSIONx10=40
+
+libi965_gen45_la_SOURCES = $(i965_gen45_FILES)
+libi965_gen45_la_CFLAGS = $(AM_CFLAGS) -DGEN_VERSIONx10=45
+
+libi965_gen5_la_SOURCES = $(i965_gen5_FILES)
+libi965_gen5_la_CFLAGS = $(AM_CFLAGS) -DGEN_VERSIONx10=50
+
 libi965_gen6_la_SOURCES = $(i965_gen6_FILES)
 libi965_gen6_la_CFLAGS = $(AM_CFLAGS) -DGEN_VERSIONx10=60
 
index aef1a7af3573b95ed2e827e5639a96adf535a804..41f4d839823528372c1b3c4e83cd8d248cd026c3 100644 (file)
@@ -160,20 +160,34 @@ i965_FILES = \
        intel_upload.c \
        libdrm_macros.h
 
+i965_gen4_FILES = \
+       genX_state_upload.c
+
+i965_gen45_FILES = \
+       genX_state_upload.c
+
+i965_gen5_FILES = \
+       genX_state_upload.c
+
 i965_gen6_FILES = \
-       genX_blorp_exec.c
+       genX_blorp_exec.c \
+       genX_state_upload.c
 
 i965_gen7_FILES = \
-       genX_blorp_exec.c
+       genX_blorp_exec.c \
+       genX_state_upload.c
 
 i965_gen75_FILES = \
-       genX_blorp_exec.c
+       genX_blorp_exec.c \
+       genX_state_upload.c
 
 i965_gen8_FILES = \
-       genX_blorp_exec.c
+       genX_blorp_exec.c \
+       genX_state_upload.c
 
 i965_gen9_FILES = \
-       genX_blorp_exec.c
+       genX_blorp_exec.c \
+       genX_state_upload.c
 
 i965_oa_GENERATED_FILES = \
        brw_oa_hsw.h \
diff --git a/src/mesa/drivers/dri/i965/genX_state_upload.c b/src/mesa/drivers/dri/i965/genX_state_upload.c
new file mode 100644 (file)
index 0000000..ec571d5
--- /dev/null
@@ -0,0 +1,109 @@
+/*
+ * Copyright © 2017 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 <assert.h>
+
+#include "common/gen_device_info.h"
+#include "genxml/gen_macros.h"
+
+#include "brw_context.h"
+#include "brw_state.h"
+
+#include "intel_batchbuffer.h"
+
+UNUSED static void *
+emit_dwords(struct brw_context *brw, unsigned n)
+{
+   intel_batchbuffer_begin(brw, n, RENDER_RING);
+   uint32_t *map = brw->batch.map_next;
+   brw->batch.map_next += n;
+   intel_batchbuffer_advance(brw);
+   return map;
+}
+
+struct brw_address {
+   struct brw_bo *bo;
+   uint32_t read_domains;
+   uint32_t write_domain;
+   uint32_t offset;
+};
+
+static uint64_t
+emit_reloc(struct brw_context *brw,
+           void *location, struct brw_address address, uint32_t delta)
+{
+   uint32_t offset = (char *) location - (char *) brw->batch.map;
+
+   return brw_emit_reloc(&brw->batch, offset, address.bo,
+                         address.offset + delta,
+                         address.read_domains,
+                         address.write_domain);
+}
+
+#define __gen_address_type struct brw_address
+#define __gen_user_data struct brw_context
+
+static uint64_t
+__gen_combine_address(struct brw_context *brw, void *location,
+                      struct brw_address address, uint32_t delta)
+{
+   if (address.bo == NULL) {
+      return address.offset + delta;
+   } else {
+      return emit_reloc(brw, location, address, delta);
+   }
+}
+
+#include "genxml/genX_pack.h"
+
+#define _brw_cmd_length(cmd) cmd ## _length
+#define _brw_cmd_length_bias(cmd) cmd ## _length_bias
+#define _brw_cmd_header(cmd) cmd ## _header
+#define _brw_cmd_pack(cmd) cmd ## _pack
+
+#define brw_batch_emit(brw, cmd, name)                  \
+   for (struct cmd name = { _brw_cmd_header(cmd) },     \
+        *_dst = emit_dwords(brw, _brw_cmd_length(cmd)); \
+        __builtin_expect(_dst != NULL, 1);              \
+        _brw_cmd_pack(cmd)(brw, (void *)_dst, &name),   \
+        _dst = NULL)
+
+#define brw_batch_emitn(brw, cmd, n) ({                \
+      uint32_t *_dw = emit_dwords(brw, n);             \
+      struct cmd template = {                          \
+         _brw_cmd_header(cmd),                         \
+         .DWordLength = n - _brw_cmd_length_bias(cmd), \
+      };                                               \
+      _brw_cmd_pack(cmd)(brw, _dw, &template);         \
+      _dw + 1; /* Array starts at dw[1] */             \
+   })
+
+#define brw_state_emit(brw, cmd, align, offset, name)              \
+   for (struct cmd name = { 0, },                                  \
+        *_dst = brw_state_batch(brw, _brw_cmd_length(cmd) * 4,     \
+                                align, offset);                    \
+        __builtin_expect(_dst != NULL, 1);                         \
+        _brw_cmd_pack(cmd)(brw, (void *)_dst, &name),              \
+        _dst = NULL)
+
+/* ---------------------------------------------------------------------- */