summaryrefslogtreecommitdiffstats
path: root/src/gallium
diff options
context:
space:
mode:
authorChia-I Wu <[email protected]>2015-06-11 07:36:28 +0800
committerChia-I Wu <[email protected]>2015-06-15 01:23:23 +0800
commit117926debb72e5027faae885f9aa7f1ca61f6a9c (patch)
treef7ae8f50d1d8448807735f94657e73c294621b45 /src/gallium
parent54e0a8ed5dcaaa0ef483d5960ae86f88e0bf8990 (diff)
ilo: merge ilo_state_3d*.[ch] to ilo_state.[ch]
With most code replaced to ilo_state_*, what was left did not belong there anymore.
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/drivers/ilo/Makefile.sources2
-rw-r--r--src/gallium/drivers/ilo/core/ilo_builder_3d_top.h2
-rw-r--r--src/gallium/drivers/ilo/core/ilo_state_3d.h122
-rw-r--r--src/gallium/drivers/ilo/core/ilo_state_3d_bottom.c147
-rw-r--r--src/gallium/drivers/ilo/ilo_blitter_rectlist.c1
-rw-r--r--src/gallium/drivers/ilo/ilo_state.c107
-rw-r--r--src/gallium/drivers/ilo/ilo_state.h74
7 files changed, 179 insertions, 276 deletions
diff --git a/src/gallium/drivers/ilo/Makefile.sources b/src/gallium/drivers/ilo/Makefile.sources
index e5a8ed4a97b..68870f44337 100644
--- a/src/gallium/drivers/ilo/Makefile.sources
+++ b/src/gallium/drivers/ilo/Makefile.sources
@@ -20,8 +20,6 @@ C_SOURCES := \
core/ilo_fence.h \
core/ilo_image.c \
core/ilo_image.h \
- core/ilo_state_3d.h \
- core/ilo_state_3d_bottom.c \
core/ilo_state_cc.c \
core/ilo_state_cc.h \
core/ilo_state_raster.c \
diff --git a/src/gallium/drivers/ilo/core/ilo_builder_3d_top.h b/src/gallium/drivers/ilo/core/ilo_builder_3d_top.h
index 85b0da7406d..bfd94344103 100644
--- a/src/gallium/drivers/ilo/core/ilo_builder_3d_top.h
+++ b/src/gallium/drivers/ilo/core/ilo_builder_3d_top.h
@@ -30,11 +30,11 @@
#include "genhw/genhw.h"
#include "../ilo_resource.h"
+#include "../ilo_state.h"
#include "intel_winsys.h"
#include "ilo_core.h"
#include "ilo_dev.h"
-#include "ilo_state_3d.h"
#include "ilo_state_sampler.h"
#include "ilo_state_shader.h"
#include "ilo_state_sol.h"
diff --git a/src/gallium/drivers/ilo/core/ilo_state_3d.h b/src/gallium/drivers/ilo/core/ilo_state_3d.h
deleted file mode 100644
index dcc94bfc88c..00000000000
--- a/src/gallium/drivers/ilo/core/ilo_state_3d.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Mesa 3-D graphics library
- *
- * Copyright (C) 2012-2014 LunarG, Inc.
- *
- * 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 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.
- *
- * Authors:
- * Chia-I Wu <[email protected]>
- */
-
-#ifndef ILO_STATE_3D_H
-#define ILO_STATE_3D_H
-
-#include "genhw/genhw.h"
-#include "pipe/p_state.h"
-
-#include "ilo_core.h"
-#include "ilo_dev.h"
-#include "ilo_state_shader.h"
-#include "ilo_state_surface.h"
-#include "ilo_state_zs.h"
-
-/**
- * \see brw_context.h
- */
-#define ILO_MAX_DRAW_BUFFERS 8
-#define ILO_MAX_CONST_BUFFERS (1 + 12)
-#define ILO_MAX_SAMPLER_VIEWS 16
-#define ILO_MAX_SAMPLERS 16
-#define ILO_MAX_SO_BINDINGS 64
-#define ILO_MAX_SO_BUFFERS 4
-#define ILO_MAX_VIEWPORTS 1
-
-#define ILO_MAX_SURFACES 256
-
-struct intel_bo;
-struct ilo_buffer;
-struct ilo_image;
-struct ilo_shader_state;
-
-struct ilo_vb_state {
- struct pipe_vertex_buffer states[PIPE_MAX_ATTRIBS];
- uint32_t enabled_mask;
-};
-
-struct ilo_ib_state {
- struct pipe_resource *buffer;
- const void *user_buffer;
- unsigned offset;
- unsigned index_size;
-
- /* these are not valid until the state is finalized */
- struct pipe_resource *hw_resource;
- unsigned hw_index_size;
- /* an offset to be added to pipe_draw_info::start */
- int64_t draw_start_offset;
-};
-
-struct ilo_so_state {
- struct pipe_stream_output_target *states[ILO_MAX_SO_BUFFERS];
- unsigned count;
- unsigned append_bitmask;
-
- bool enabled;
-};
-
-struct ilo_surface_cso {
- struct pipe_surface base;
-
- bool is_rt;
- union {
- struct ilo_state_surface rt;
- struct ilo_state_zs zs;
- } u;
-};
-
-struct ilo_fb_state {
- struct pipe_framebuffer_state state;
-
- struct ilo_state_surface null_rt;
- struct ilo_state_zs null_zs;
-
- struct ilo_fb_blend_caps {
- bool is_unorm;
- bool is_integer;
- bool force_dst_alpha_one;
-
- bool can_logicop;
- bool can_blend;
- bool can_alpha_test;
- } blend_caps[PIPE_MAX_COLOR_BUFS];
-
- unsigned num_samples;
-
- bool has_integer_rt;
- bool has_hiz;
- enum gen_depth_format depth_offset_format;
-};
-
-void
-ilo_gpe_set_fb(const struct ilo_dev *dev,
- const struct pipe_framebuffer_state *state,
- struct ilo_fb_state *fb);
-
-#endif /* ILO_STATE_3D_H */
diff --git a/src/gallium/drivers/ilo/core/ilo_state_3d_bottom.c b/src/gallium/drivers/ilo/core/ilo_state_3d_bottom.c
deleted file mode 100644
index 8734aff44da..00000000000
--- a/src/gallium/drivers/ilo/core/ilo_state_3d_bottom.c
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * Mesa 3-D graphics library
- *
- * Copyright (C) 2012-2014 LunarG, Inc.
- *
- * 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 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.
- *
- * Authors:
- * Chia-I Wu <[email protected]>
- */
-
-#include "genhw/genhw.h"
-#include "util/u_framebuffer.h"
-#include "util/u_half.h"
-
-#include "ilo_format.h"
-#include "ilo_image.h"
-#include "ilo_state_3d.h"
-
-static void
-fb_set_blend_caps(const struct ilo_dev *dev,
- enum pipe_format format,
- struct ilo_fb_blend_caps *caps)
-{
- const struct util_format_description *desc =
- util_format_description(format);
- const int ch = util_format_get_first_non_void_channel(format);
-
- memset(caps, 0, sizeof(*caps));
-
- if (format == PIPE_FORMAT_NONE || desc->is_mixed)
- return;
-
- caps->is_unorm = (ch >= 0 && desc->channel[ch].normalized &&
- desc->channel[ch].type == UTIL_FORMAT_TYPE_UNSIGNED &&
- desc->colorspace == UTIL_FORMAT_COLORSPACE_RGB);
- caps->is_integer = util_format_is_pure_integer(format);
-
- /*
- * From the Sandy Bridge PRM, volume 2 part 1, page 365:
- *
- * "Logic Ops are only supported on *_UNORM surfaces (excluding _SRGB
- * variants), otherwise Logic Ops must be DISABLED."
- *
- * According to the classic driver, this is lifted on Gen8+.
- */
- caps->can_logicop = (ilo_dev_gen(dev) >= ILO_GEN(8) || caps->is_unorm);
-
- /* no blending for pure integer formats */
- caps->can_blend = !caps->is_integer;
-
- /*
- * From the Sandy Bridge PRM, volume 2 part 1, page 382:
- *
- * "Alpha Test can only be enabled if Pixel Shader outputs a float
- * alpha value."
- */
- caps->can_alpha_test = !caps->is_integer;
-
- caps->force_dst_alpha_one =
- (ilo_format_translate_render(dev, format) !=
- ilo_format_translate_color(dev, format));
-
- /* sanity check */
- if (caps->force_dst_alpha_one) {
- enum pipe_format render_format;
-
- switch (format) {
- case PIPE_FORMAT_B8G8R8X8_UNORM:
- render_format = PIPE_FORMAT_B8G8R8A8_UNORM;
- break;
- default:
- render_format = PIPE_FORMAT_NONE;
- break;
- }
-
- assert(ilo_format_translate_render(dev, format) ==
- ilo_format_translate_color(dev, render_format));
- }
-}
-
-void
-ilo_gpe_set_fb(const struct ilo_dev *dev,
- const struct pipe_framebuffer_state *state,
- struct ilo_fb_state *fb)
-{
- const struct pipe_surface *first_surf = NULL;
- int i;
-
- ILO_DEV_ASSERT(dev, 6, 8);
-
- util_copy_framebuffer_state(&fb->state, state);
-
- fb->has_integer_rt = false;
- for (i = 0; i < state->nr_cbufs; i++) {
- if (state->cbufs[i]) {
- fb_set_blend_caps(dev, state->cbufs[i]->format, &fb->blend_caps[i]);
-
- fb->has_integer_rt |= fb->blend_caps[i].is_integer;
-
- if (!first_surf)
- first_surf = state->cbufs[i];
- } else {
- fb_set_blend_caps(dev, PIPE_FORMAT_NONE, &fb->blend_caps[i]);
- }
- }
-
- if (!first_surf && state->zsbuf)
- first_surf = state->zsbuf;
-
- fb->num_samples = (first_surf) ? first_surf->texture->nr_samples : 1;
- if (!fb->num_samples)
- fb->num_samples = 1;
-
- if (state->zsbuf) {
- const struct ilo_surface_cso *cso =
- (const struct ilo_surface_cso *) state->zsbuf;
-
- fb->has_hiz = cso->u.zs.hiz_bo;
- fb->depth_offset_format =
- ilo_state_zs_get_depth_format(&cso->u.zs, dev);
- } else {
- fb->has_hiz = false;
- fb->depth_offset_format = GEN6_ZFORMAT_D32_FLOAT;
- }
-
- /*
- * The PRMs list several restrictions when the framebuffer has more than
- * one surface. It seems they are actually lifted on GEN6+.
- */
-}
diff --git a/src/gallium/drivers/ilo/ilo_blitter_rectlist.c b/src/gallium/drivers/ilo/ilo_blitter_rectlist.c
index a4c8dead4a5..afdb0377824 100644
--- a/src/gallium/drivers/ilo/ilo_blitter_rectlist.c
+++ b/src/gallium/drivers/ilo/ilo_blitter_rectlist.c
@@ -25,7 +25,6 @@
* Chia-I Wu <[email protected]>
*/
-#include "core/ilo_state_3d.h"
#include "util/u_draw.h"
#include "util/u_pack_color.h"
diff --git a/src/gallium/drivers/ilo/ilo_state.c b/src/gallium/drivers/ilo/ilo_state.c
index 917839fa23e..0145fcbb8d5 100644
--- a/src/gallium/drivers/ilo/ilo_state.c
+++ b/src/gallium/drivers/ilo/ilo_state.c
@@ -27,9 +27,9 @@
#include "core/ilo_builder_3d.h" /* for gen6_3d_translate_pipe_prim() */
#include "core/ilo_format.h"
-#include "core/ilo_state_3d.h"
#include "util/u_dual_blend.h"
#include "util/u_dynarray.h"
+#include "util/u_framebuffer.h"
#include "util/u_helpers.h"
#include "util/u_resource.h"
#include "util/u_upload_mgr.h"
@@ -1492,13 +1492,116 @@ ilo_set_constant_buffer(struct pipe_context *pipe,
}
static void
+fb_set_blend_caps(const struct ilo_dev *dev,
+ enum pipe_format format,
+ struct ilo_fb_blend_caps *caps)
+{
+ const struct util_format_description *desc =
+ util_format_description(format);
+ const int ch = util_format_get_first_non_void_channel(format);
+
+ memset(caps, 0, sizeof(*caps));
+
+ if (format == PIPE_FORMAT_NONE || desc->is_mixed)
+ return;
+
+ caps->is_unorm = (ch >= 0 && desc->channel[ch].normalized &&
+ desc->channel[ch].type == UTIL_FORMAT_TYPE_UNSIGNED &&
+ desc->colorspace == UTIL_FORMAT_COLORSPACE_RGB);
+ caps->is_integer = util_format_is_pure_integer(format);
+
+ /*
+ * From the Sandy Bridge PRM, volume 2 part 1, page 365:
+ *
+ * "Logic Ops are only supported on *_UNORM surfaces (excluding _SRGB
+ * variants), otherwise Logic Ops must be DISABLED."
+ *
+ * According to the classic driver, this is lifted on Gen8+.
+ */
+ caps->can_logicop = (ilo_dev_gen(dev) >= ILO_GEN(8) || caps->is_unorm);
+
+ /* no blending for pure integer formats */
+ caps->can_blend = !caps->is_integer;
+
+ /*
+ * From the Sandy Bridge PRM, volume 2 part 1, page 382:
+ *
+ * "Alpha Test can only be enabled if Pixel Shader outputs a float
+ * alpha value."
+ */
+ caps->can_alpha_test = !caps->is_integer;
+
+ caps->force_dst_alpha_one =
+ (ilo_format_translate_render(dev, format) !=
+ ilo_format_translate_color(dev, format));
+
+ /* sanity check */
+ if (caps->force_dst_alpha_one) {
+ enum pipe_format render_format;
+
+ switch (format) {
+ case PIPE_FORMAT_B8G8R8X8_UNORM:
+ render_format = PIPE_FORMAT_B8G8R8A8_UNORM;
+ break;
+ default:
+ render_format = PIPE_FORMAT_NONE;
+ break;
+ }
+
+ assert(ilo_format_translate_render(dev, format) ==
+ ilo_format_translate_color(dev, render_format));
+ }
+}
+
+static void
ilo_set_framebuffer_state(struct pipe_context *pipe,
const struct pipe_framebuffer_state *state)
{
const struct ilo_dev *dev = ilo_context(pipe)->dev;
struct ilo_state_vector *vec = &ilo_context(pipe)->state_vector;
+ struct ilo_fb_state *fb = &vec->fb;
+ const struct pipe_surface *first_surf = NULL;
+ int i;
- ilo_gpe_set_fb(dev, state, &vec->fb);
+ util_copy_framebuffer_state(&fb->state, state);
+
+ fb->has_integer_rt = false;
+ for (i = 0; i < state->nr_cbufs; i++) {
+ if (state->cbufs[i]) {
+ fb_set_blend_caps(dev, state->cbufs[i]->format, &fb->blend_caps[i]);
+
+ fb->has_integer_rt |= fb->blend_caps[i].is_integer;
+
+ if (!first_surf)
+ first_surf = state->cbufs[i];
+ } else {
+ fb_set_blend_caps(dev, PIPE_FORMAT_NONE, &fb->blend_caps[i]);
+ }
+ }
+
+ if (!first_surf && state->zsbuf)
+ first_surf = state->zsbuf;
+
+ fb->num_samples = (first_surf) ? first_surf->texture->nr_samples : 1;
+ if (!fb->num_samples)
+ fb->num_samples = 1;
+
+ if (state->zsbuf) {
+ const struct ilo_surface_cso *cso =
+ (const struct ilo_surface_cso *) state->zsbuf;
+
+ fb->has_hiz = cso->u.zs.hiz_bo;
+ fb->depth_offset_format =
+ ilo_state_zs_get_depth_format(&cso->u.zs, dev);
+ } else {
+ fb->has_hiz = false;
+ fb->depth_offset_format = GEN6_ZFORMAT_D32_FLOAT;
+ }
+
+ /*
+ * The PRMs list several restrictions when the framebuffer has more than
+ * one surface. It seems they are actually lifted on GEN6+.
+ */
vec->dirty |= ILO_DIRTY_FB;
}
diff --git a/src/gallium/drivers/ilo/ilo_state.h b/src/gallium/drivers/ilo/ilo_state.h
index e4c6f281a5c..90514d52224 100644
--- a/src/gallium/drivers/ilo/ilo_state.h
+++ b/src/gallium/drivers/ilo/ilo_state.h
@@ -28,7 +28,6 @@
#ifndef ILO_STATE_H
#define ILO_STATE_H
-#include "core/ilo_state_3d.h"
#include "core/ilo_state_cc.h"
#include "core/ilo_state_raster.h"
#include "core/ilo_state_sampler.h"
@@ -46,6 +45,19 @@
#include "ilo_common.h"
/**
+ * \see brw_context.h
+ */
+#define ILO_MAX_DRAW_BUFFERS 8
+#define ILO_MAX_CONST_BUFFERS (1 + 12)
+#define ILO_MAX_SAMPLER_VIEWS 16
+#define ILO_MAX_SAMPLERS 16
+#define ILO_MAX_SO_BINDINGS 64
+#define ILO_MAX_SO_BUFFERS 4
+#define ILO_MAX_VIEWPORTS 1
+
+#define ILO_MAX_SURFACES 256
+
+/**
* States that we track.
*
* XXX Do we want to count each sampler or vertex buffer as a state? If that
@@ -131,6 +143,7 @@ enum ilo_dirty_flags {
};
struct ilo_context;
+struct ilo_shader_state;
struct ilo_ve_state {
unsigned vb_mapping[PIPE_MAX_ATTRIBS];
@@ -143,6 +156,24 @@ struct ilo_ve_state {
struct ilo_state_vf vf;
};
+struct ilo_vb_state {
+ struct pipe_vertex_buffer states[PIPE_MAX_ATTRIBS];
+ uint32_t enabled_mask;
+};
+
+struct ilo_ib_state {
+ struct pipe_resource *buffer;
+ const void *user_buffer;
+ unsigned offset;
+ unsigned index_size;
+
+ /* these are not valid until the state is finalized */
+ struct pipe_resource *hw_resource;
+ unsigned hw_index_size;
+ /* an offset to be added to pipe_draw_info::start */
+ int64_t draw_start_offset;
+};
+
struct ilo_cbuf_cso {
struct pipe_resource *resource;
struct ilo_state_surface_buffer_info info;
@@ -188,6 +219,14 @@ struct ilo_view_state {
unsigned count;
};
+struct ilo_so_state {
+ struct pipe_stream_output_target *states[ILO_MAX_SO_BUFFERS];
+ unsigned count;
+ unsigned append_bitmask;
+
+ bool enabled;
+};
+
struct ilo_rasterizer_state {
struct pipe_rasterizer_state state;
@@ -208,6 +247,39 @@ struct ilo_viewport_state {
uint32_t vp_data[20 * ILO_MAX_VIEWPORTS];
};
+struct ilo_surface_cso {
+ struct pipe_surface base;
+
+ bool is_rt;
+ union {
+ struct ilo_state_surface rt;
+ struct ilo_state_zs zs;
+ } u;
+};
+
+struct ilo_fb_state {
+ struct pipe_framebuffer_state state;
+
+ struct ilo_state_surface null_rt;
+ struct ilo_state_zs null_zs;
+
+ struct ilo_fb_blend_caps {
+ bool is_unorm;
+ bool is_integer;
+ bool force_dst_alpha_one;
+
+ bool can_logicop;
+ bool can_blend;
+ bool can_alpha_test;
+ } blend_caps[PIPE_MAX_COLOR_BUFS];
+
+ unsigned num_samples;
+
+ bool has_integer_rt;
+ bool has_hiz;
+ enum gen_depth_format depth_offset_format;
+};
+
struct ilo_dsa_state {
struct ilo_state_cc_depth_info depth;