2016-04-01 15:57:54 +03:00
|
|
|
/*
|
|
|
|
|
* 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 "main/teximage.h"
|
|
|
|
|
#include "main/blend.h"
|
|
|
|
|
#include "main/fbobject.h"
|
|
|
|
|
#include "main/renderbuffer.h"
|
2016-04-22 09:44:13 +03:00
|
|
|
#include "main/glformats.h"
|
2016-04-01 15:57:54 +03:00
|
|
|
|
|
|
|
|
#include "util/ralloc.h"
|
|
|
|
|
|
|
|
|
|
#include "intel_fbo.h"
|
|
|
|
|
|
2016-08-08 15:25:17 -07:00
|
|
|
#include "blorp_priv.h"
|
2016-04-01 15:57:54 +03:00
|
|
|
#include "brw_meta_util.h"
|
|
|
|
|
#include "brw_context.h"
|
|
|
|
|
#include "brw_eu.h"
|
|
|
|
|
|
2016-04-27 17:17:11 -07:00
|
|
|
#include "nir_builder.h"
|
|
|
|
|
|
2016-04-01 15:57:54 +03:00
|
|
|
#define FILE_DEBUG_FLAG DEBUG_BLORP
|
|
|
|
|
|
|
|
|
|
struct brw_blorp_const_color_prog_key
|
|
|
|
|
{
|
|
|
|
|
bool use_simd16_replicated_data;
|
|
|
|
|
bool pad[3];
|
|
|
|
|
};
|
|
|
|
|
|
2016-04-27 17:17:11 -07:00
|
|
|
static void
|
2016-08-19 00:54:56 -07:00
|
|
|
brw_blorp_params_get_clear_kernel(struct blorp_context *blorp,
|
2016-04-27 17:17:11 -07:00
|
|
|
struct brw_blorp_params *params,
|
|
|
|
|
bool use_replicated_data)
|
2016-04-01 15:57:54 +03:00
|
|
|
{
|
2016-04-27 17:17:11 -07:00
|
|
|
struct brw_blorp_const_color_prog_key blorp_key;
|
|
|
|
|
memset(&blorp_key, 0, sizeof(blorp_key));
|
|
|
|
|
blorp_key.use_simd16_replicated_data = use_replicated_data;
|
2016-04-01 15:57:54 +03:00
|
|
|
|
2016-08-19 00:54:56 -07:00
|
|
|
if (blorp->lookup_shader(blorp, &blorp_key, sizeof(blorp_key),
|
|
|
|
|
¶ms->wm_prog_kernel, ¶ms->wm_prog_data))
|
2016-04-27 17:17:11 -07:00
|
|
|
return;
|
2016-04-01 15:57:54 +03:00
|
|
|
|
2016-04-27 17:17:11 -07:00
|
|
|
void *mem_ctx = ralloc_context(NULL);
|
2016-04-01 15:57:54 +03:00
|
|
|
|
2016-04-27 17:17:11 -07:00
|
|
|
nir_builder b;
|
|
|
|
|
nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_FRAGMENT, NULL);
|
|
|
|
|
b.shader->info.name = ralloc_strdup(b.shader, "BLORP-clear");
|
2016-04-01 15:57:54 +03:00
|
|
|
|
2016-05-15 07:43:39 +03:00
|
|
|
nir_variable *v_color = nir_variable_create(b.shader, nir_var_shader_in,
|
|
|
|
|
glsl_vec4_type(), "v_color");
|
|
|
|
|
v_color->data.location = VARYING_SLOT_VAR0;
|
2016-07-07 02:02:38 -07:00
|
|
|
v_color->data.interpolation = INTERP_MODE_FLAT;
|
2016-04-01 15:57:54 +03:00
|
|
|
|
2016-04-27 17:17:11 -07:00
|
|
|
nir_variable *frag_color = nir_variable_create(b.shader, nir_var_shader_out,
|
|
|
|
|
glsl_vec4_type(),
|
|
|
|
|
"gl_FragColor");
|
|
|
|
|
frag_color->data.location = FRAG_RESULT_COLOR;
|
2016-04-01 15:57:54 +03:00
|
|
|
|
2016-05-15 07:43:39 +03:00
|
|
|
nir_copy_var(&b, frag_color, v_color);
|
2016-04-01 15:57:54 +03:00
|
|
|
|
2016-04-27 17:17:11 -07:00
|
|
|
struct brw_wm_prog_key wm_key;
|
|
|
|
|
brw_blorp_init_wm_prog_key(&wm_key);
|
2016-04-01 15:57:54 +03:00
|
|
|
|
2016-04-27 17:17:11 -07:00
|
|
|
struct brw_blorp_prog_data prog_data;
|
|
|
|
|
unsigned program_size;
|
|
|
|
|
const unsigned *program =
|
2016-08-19 00:54:56 -07:00
|
|
|
brw_blorp_compile_nir_shader(blorp, b.shader, &wm_key, use_replicated_data,
|
2016-04-27 17:17:11 -07:00
|
|
|
&prog_data, &program_size);
|
2016-04-01 15:57:54 +03:00
|
|
|
|
2016-08-19 00:54:56 -07:00
|
|
|
blorp->upload_shader(blorp, &blorp_key, sizeof(blorp_key),
|
|
|
|
|
program, program_size,
|
|
|
|
|
&prog_data, sizeof(prog_data),
|
|
|
|
|
¶ms->wm_prog_kernel, ¶ms->wm_prog_data);
|
2016-04-01 15:57:54 +03:00
|
|
|
|
2016-04-27 17:17:11 -07:00
|
|
|
ralloc_free(mem_ctx);
|
2016-04-22 11:38:23 -07:00
|
|
|
}
|
|
|
|
|
|
2016-08-08 15:25:17 -07:00
|
|
|
void
|
2016-08-19 00:54:56 -07:00
|
|
|
blorp_fast_clear(struct blorp_batch *batch,
|
|
|
|
|
const struct brw_blorp_surf *surf,
|
2016-07-25 14:03:49 -07:00
|
|
|
uint32_t level, uint32_t layer,
|
|
|
|
|
uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1)
|
|
|
|
|
{
|
2016-04-22 14:32:48 -07:00
|
|
|
struct brw_blorp_params params;
|
|
|
|
|
brw_blorp_params_init(¶ms);
|
2016-04-22 12:55:49 -07:00
|
|
|
|
2016-07-25 14:03:49 -07:00
|
|
|
params.x0 = x0;
|
|
|
|
|
params.y0 = y0;
|
|
|
|
|
params.x1 = x1;
|
|
|
|
|
params.y1 = y1;
|
2016-04-22 12:55:49 -07:00
|
|
|
|
2016-07-25 14:03:49 -07:00
|
|
|
memset(¶ms.wm_inputs, 0xff, 4*sizeof(float));
|
|
|
|
|
params.fast_clear_op = GEN7_PS_RENDER_TARGET_FAST_CLEAR_ENABLE;
|
|
|
|
|
|
2016-08-19 00:54:56 -07:00
|
|
|
brw_get_fast_clear_rect(batch->blorp->isl_dev, surf->aux_surf,
|
2016-08-19 00:37:38 -07:00
|
|
|
¶ms.x0, ¶ms.y0, ¶ms.x1, ¶ms.y1);
|
2016-07-25 14:03:49 -07:00
|
|
|
|
2016-08-19 00:54:56 -07:00
|
|
|
brw_blorp_params_get_clear_kernel(batch->blorp, ¶ms, true);
|
2016-04-22 12:55:49 -07:00
|
|
|
|
2016-08-19 00:54:56 -07:00
|
|
|
brw_blorp_surface_info_init(batch->blorp, ¶ms.dst, surf, level, layer,
|
2016-07-25 14:03:49 -07:00
|
|
|
surf->surf->format, true);
|
|
|
|
|
|
2016-08-19 00:54:56 -07:00
|
|
|
batch->blorp->exec(batch, ¶ms);
|
2016-07-25 14:03:49 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2016-08-08 15:25:17 -07:00
|
|
|
void
|
2016-08-19 00:54:56 -07:00
|
|
|
blorp_clear(struct blorp_batch *batch,
|
|
|
|
|
const struct brw_blorp_surf *surf,
|
2016-07-25 14:03:49 -07:00
|
|
|
uint32_t level, uint32_t layer,
|
|
|
|
|
uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1,
|
|
|
|
|
enum isl_format format, union isl_color_value clear_color,
|
|
|
|
|
bool color_write_disable[4])
|
|
|
|
|
{
|
|
|
|
|
struct brw_blorp_params params;
|
|
|
|
|
brw_blorp_params_init(¶ms);
|
|
|
|
|
|
|
|
|
|
params.x0 = x0;
|
|
|
|
|
params.y0 = y0;
|
|
|
|
|
params.x1 = x1;
|
|
|
|
|
params.y1 = y1;
|
|
|
|
|
|
|
|
|
|
memcpy(¶ms.wm_inputs, clear_color.f32, sizeof(float) * 4);
|
2016-04-22 12:55:49 -07:00
|
|
|
|
2016-04-27 17:18:02 -07:00
|
|
|
bool use_simd16_replicated_data = true;
|
2016-04-22 12:55:49 -07:00
|
|
|
|
|
|
|
|
/* From the SNB PRM (Vol4_Part1):
|
|
|
|
|
*
|
|
|
|
|
* "Replicated data (Message Type = 111) is only supported when
|
|
|
|
|
* accessing tiled memory. Using this Message Type to access linear
|
|
|
|
|
* (untiled) memory is UNDEFINED."
|
|
|
|
|
*/
|
2016-07-25 14:03:49 -07:00
|
|
|
if (surf->surf->tiling == ISL_TILING_LINEAR)
|
2016-04-27 17:18:02 -07:00
|
|
|
use_simd16_replicated_data = false;
|
2016-04-22 12:55:49 -07:00
|
|
|
|
|
|
|
|
/* Constant color writes ignore everyting in blend and color calculator
|
|
|
|
|
* state. This is not documented.
|
|
|
|
|
*/
|
2016-07-25 14:03:49 -07:00
|
|
|
for (unsigned i = 0; i < 4; i++) {
|
|
|
|
|
params.color_write_disable[i] = color_write_disable[i];
|
|
|
|
|
if (color_write_disable[i])
|
|
|
|
|
use_simd16_replicated_data = false;
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-19 00:54:56 -07:00
|
|
|
brw_blorp_params_get_clear_kernel(batch->blorp, ¶ms,
|
|
|
|
|
use_simd16_replicated_data);
|
2016-07-25 14:03:49 -07:00
|
|
|
|
2016-08-19 00:54:56 -07:00
|
|
|
brw_blorp_surface_info_init(batch->blorp, ¶ms.dst, surf, level, layer,
|
2016-07-25 14:03:49 -07:00
|
|
|
format, true);
|
2016-04-22 12:55:49 -07:00
|
|
|
|
2016-08-19 00:54:56 -07:00
|
|
|
batch->blorp->exec(batch, ¶ms);
|
2016-07-25 14:03:49 -07:00
|
|
|
}
|
|
|
|
|
|
2016-08-08 15:25:17 -07:00
|
|
|
void
|
2016-08-19 00:54:56 -07:00
|
|
|
brw_blorp_ccs_resolve(struct blorp_batch *batch,
|
|
|
|
|
struct brw_blorp_surf *surf, enum isl_format format)
|
2016-04-01 15:57:54 +03:00
|
|
|
{
|
2016-04-22 14:32:48 -07:00
|
|
|
struct brw_blorp_params params;
|
|
|
|
|
brw_blorp_params_init(¶ms);
|
2016-04-22 12:55:49 -07:00
|
|
|
|
2016-08-19 00:54:56 -07:00
|
|
|
brw_blorp_surface_info_init(batch->blorp, ¶ms.dst, surf,
|
2016-07-23 12:46:10 -07:00
|
|
|
0 /* level */, 0 /* layer */, format, true);
|
2016-04-22 12:55:49 -07:00
|
|
|
|
2016-08-19 00:54:56 -07:00
|
|
|
brw_get_ccs_resolve_rect(batch->blorp->isl_dev, ¶ms.dst.aux_surf,
|
2016-07-23 12:13:07 -07:00
|
|
|
¶ms.x0, ¶ms.y0,
|
|
|
|
|
¶ms.x1, ¶ms.y1);
|
2016-04-22 12:55:49 -07:00
|
|
|
|
2016-07-23 12:46:10 -07:00
|
|
|
if (params.dst.aux_usage == ISL_AUX_USAGE_CCS_E)
|
2016-04-17 18:33:55 +03:00
|
|
|
params.resolve_type = GEN9_PS_RENDER_TARGET_RESOLVE_FULL;
|
|
|
|
|
else
|
|
|
|
|
params.resolve_type = GEN7_PS_RENDER_TARGET_RESOLVE_ENABLE;
|
2016-04-22 12:55:49 -07:00
|
|
|
|
|
|
|
|
/* Note: there is no need to initialize push constants because it doesn't
|
|
|
|
|
* matter what data gets dispatched to the render target. However, we must
|
|
|
|
|
* ensure that the fragment shader delivers the data using the "replicated
|
|
|
|
|
* color" message.
|
|
|
|
|
*/
|
|
|
|
|
|
2016-08-19 00:54:56 -07:00
|
|
|
brw_blorp_params_get_clear_kernel(batch->blorp, ¶ms, true);
|
2016-04-22 12:55:49 -07:00
|
|
|
|
2016-08-19 00:54:56 -07:00
|
|
|
batch->blorp->exec(batch, ¶ms);
|
2016-07-23 12:46:10 -07:00
|
|
|
}
|