[Mesa-dev] [PATCH 08/29] i965: Add a new brw_device_info structure.

Kenneth Graunke kenneth at whitecape.org
Fri Sep 27 16:45:47 PDT 2013


The idea is that struct brw_device_info should store statically-known
information about hardware features.  Using the new family name in the
PCI ID table, we can easily grab the right structure.

This is basically the equivalent of intel_device_info in the kernel.

This patch also makes the new structure available from intel_screen, but
nothing uses it.  Right now, it looks very redundant with existing
fields, but that will change.

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
---
 src/mesa/drivers/dri/i965/Makefile.sources  |  1 +
 src/mesa/drivers/dri/i965/brw_device_info.c | 97 +++++++++++++++++++++++++++++
 src/mesa/drivers/dri/i965/brw_device_info.h | 44 +++++++++++++
 src/mesa/drivers/dri/i965/intel_chipset.h   |  3 +
 src/mesa/drivers/dri/i965/intel_screen.c    |  1 +
 src/mesa/drivers/dri/i965/intel_screen.h    |  4 ++
 6 files changed, 150 insertions(+)
 create mode 100644 src/mesa/drivers/dri/i965/brw_device_info.c
 create mode 100644 src/mesa/drivers/dri/i965/brw_device_info.h

diff --git a/src/mesa/drivers/dri/i965/Makefile.sources b/src/mesa/drivers/dri/i965/Makefile.sources
index 8da5643..292425d 100644
--- a/src/mesa/drivers/dri/i965/Makefile.sources
+++ b/src/mesa/drivers/dri/i965/Makefile.sources
@@ -45,6 +45,7 @@ i965_FILES = \
 	brw_context.c \
 	brw_cubemap_normalize.cpp \
 	brw_curbe.c \
+	brw_device_info.c \
 	brw_disasm.c \
 	brw_draw.c \
 	brw_draw_upload.c \
diff --git a/src/mesa/drivers/dri/i965/brw_device_info.c b/src/mesa/drivers/dri/i965/brw_device_info.c
new file mode 100644
index 0000000..3345d9c
--- /dev/null
+++ b/src/mesa/drivers/dri/i965/brw_device_info.c
@@ -0,0 +1,97 @@
+/*
+ * 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 <stdio.h>
+#include <stdlib.h>
+#include "brw_device_info.h"
+
+static const struct brw_device_info brw_device_info_i965 = {
+   .gen = 4,
+};
+
+static const struct brw_device_info brw_device_info_g4x = {
+   .gen = 4,
+   .is_g4x = true,
+};
+
+static const struct brw_device_info brw_device_info_ilk = {
+   .gen = 5,
+};
+
+static const struct brw_device_info brw_device_info_snb_gt1 = {
+   .gen = 6,
+   .gt = 2,
+   .has_hiz_and_separate_stencil = true,
+   .has_llc = true,
+};
+
+static const struct brw_device_info brw_device_info_snb_gt2 = {
+   .gen = 6,
+   .gt = 2,
+   .has_hiz_and_separate_stencil = true,
+   .has_llc = true,
+};
+
+#define GEN7_FEATURES                               \
+   .gen = 7,                                        \
+   .has_hiz_and_separate_stencil = true,            \
+   .must_use_separate_stencil = true,               \
+   .has_llc = true
+
+static const struct brw_device_info brw_device_info_ivb_gt1 = {
+   GEN7_FEATURES, .is_ivybridge = true, .gt = 1,
+};
+
+static const struct brw_device_info brw_device_info_ivb_gt2 = {
+   GEN7_FEATURES, .is_ivybridge = true, .gt = 2,
+};
+
+static const struct brw_device_info brw_device_info_byt = {
+   GEN7_FEATURES, .is_baytrail = true, .gt = 1,
+   .has_llc = false,
+};
+
+static const struct brw_device_info brw_device_info_hsw_gt1 = {
+   GEN7_FEATURES, .is_haswell = true, .gt = 1,
+};
+
+static const struct brw_device_info brw_device_info_hsw_gt2 = {
+   GEN7_FEATURES, .is_haswell = true, .gt = 2,
+};
+
+static const struct brw_device_info brw_device_info_hsw_gt3 = {
+   GEN7_FEATURES, .is_haswell = true, .gt = 3,
+};
+
+const struct brw_device_info *
+brw_get_device_info(int devid)
+{
+   switch (devid) {
+#undef CHIPSET
+#define CHIPSET(id, family, name) case id: return &brw_device_info_##family;
+#include "pci_ids/i965_pci_ids.h"
+   default:
+      fprintf(stderr, "Unknown Intel device.");
+      abort();
+   }
+}
diff --git a/src/mesa/drivers/dri/i965/brw_device_info.h b/src/mesa/drivers/dri/i965/brw_device_info.h
new file mode 100644
index 0000000..9c2fecb
--- /dev/null
+++ b/src/mesa/drivers/dri/i965/brw_device_info.h
@@ -0,0 +1,44 @@
+ /*
+  * 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.
+  *
+  */
+
+#pragma once
+#include <stdbool.h>
+
+struct brw_device_info
+{
+   int gen; /**< Generation number: 4, 5, 6, 7, ... */
+   int gt;
+
+   bool is_g4x;
+   bool is_ivybridge;
+   bool is_baytrail;
+   bool is_haswell;
+
+   bool has_hiz_and_separate_stencil;
+   bool must_use_separate_stencil;
+
+   bool has_llc;
+};
+
+const struct brw_device_info *brw_get_device_info(int devid);
diff --git a/src/mesa/drivers/dri/i965/intel_chipset.h b/src/mesa/drivers/dri/i965/intel_chipset.h
index 65cb50e..a760dee 100644
--- a/src/mesa/drivers/dri/i965/intel_chipset.h
+++ b/src/mesa/drivers/dri/i965/intel_chipset.h
@@ -25,6 +25,9 @@
  *
  */
 
+#pragma once
+#include <stdbool.h>
+
 #define PCI_CHIP_IGD_GM			0xA011
 #define PCI_CHIP_IGD_G			0xA001
 
diff --git a/src/mesa/drivers/dri/i965/intel_screen.c b/src/mesa/drivers/dri/i965/intel_screen.c
index df9edb7..741b554 100644
--- a/src/mesa/drivers/dri/i965/intel_screen.c
+++ b/src/mesa/drivers/dri/i965/intel_screen.c
@@ -1253,6 +1253,7 @@ __DRIconfig **intelInitScreen2(__DRIscreen *psp)
        return false;
 
    intelScreen->deviceID = drm_intel_bufmgr_gem_get_devid(intelScreen->bufmgr);
+   intelScreen->devinfo = brw_get_device_info(intelScreen->deviceID);
 
    if (IS_GEN7(intelScreen->deviceID)) {
       intelScreen->gen = 7;
diff --git a/src/mesa/drivers/dri/i965/intel_screen.h b/src/mesa/drivers/dri/i965/intel_screen.h
index fef17bc..ef69e95 100644
--- a/src/mesa/drivers/dri/i965/intel_screen.h
+++ b/src/mesa/drivers/dri/i965/intel_screen.h
@@ -32,12 +32,16 @@
 #include <sys/time.h>
 #include "dri_util.h"
 #include "intel_bufmgr.h"
+#include "intel_chipset.h"
+#include "brw_device_info.h"
 #include "i915_drm.h"
 #include "xmlconfig.h"
 
 struct intel_screen
 {
    int deviceID;
+   const struct brw_device_info *devinfo;
+
    int gen;
 
    __DRIscreen *driScrnPriv;
-- 
1.8.3.4



More information about the mesa-dev mailing list