i965: Add a new brw_device_info structure.
authorKenneth Graunke <kenneth@whitecape.org>
Thu, 4 Jul 2013 19:11:36 +0000 (12:11 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Sun, 13 Oct 2013 07:10:43 +0000 (00:10 -0700)
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@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
src/mesa/drivers/dri/i965/Makefile.sources
src/mesa/drivers/dri/i965/brw_device_info.c [new file with mode: 0644]
src/mesa/drivers/dri/i965/brw_device_info.h [new file with mode: 0644]
src/mesa/drivers/dri/i965/intel_chipset.h
src/mesa/drivers/dri/i965/intel_screen.c
src/mesa/drivers/dri/i965/intel_screen.h

index 23d937d39d98d100a5ef41aee2d5584df4035e6a..4e06ee2a55e5d0d4a91ffbf82c8e49587b4209d9 100644 (file)
@@ -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 (file)
index 0000000..3345d9c
--- /dev/null
@@ -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 (file)
index 0000000..9c2fecb
--- /dev/null
@@ -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);
index 65cb50ed2e6acfe2cfeabb354dbb1e4c4a9041fc..a760dee441c3e14df108adab979c03e67c196d80 100644 (file)
@@ -25,6 +25,9 @@
  *
  */
 
+#pragma once
+#include <stdbool.h>
+
 #define PCI_CHIP_IGD_GM                        0xA011
 #define PCI_CHIP_IGD_G                 0xA001
 
index 0d2c2edaa1d2ac5445815c5eddd10304679a3c89..7176c8a65bef419112fcecf593300129cbfde899 100644 (file)
@@ -1257,6 +1257,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;
index fef17bcfb3c67bdfacbfe1af737dedeb4b830b86..ef69e95efe60166b764a4e471dd18a3a38dfcf01 100644 (file)
 #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;