#include "util/ralloc.h"
+#include "main/macros.h" /* Needed for MAX3 and MAX2 for format_rgb9e5 */
+#include "util/format_rgb9e5.h"
+
#include "blorp_priv.h"
#include "brw_defines.h"
struct brw_blorp_const_color_prog_key
{
+ enum blorp_shader_type shader_type; /* Must be BLORP_SHADER_TYPE_CLEAR */
bool use_simd16_replicated_data;
bool pad[3];
};
struct blorp_params *params,
bool use_replicated_data)
{
- 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;
+ const struct brw_blorp_const_color_prog_key blorp_key = {
+ .shader_type = BLORP_SHADER_TYPE_CLEAR,
+ .use_simd16_replicated_data = use_replicated_data,
+ };
if (blorp->lookup_shader(blorp, &blorp_key, sizeof(blorp_key),
¶ms->wm_prog_kernel, ¶ms->wm_prog_data))
void *mem_ctx = ralloc_context(NULL);
nir_builder b;
- nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_FRAGMENT, NULL);
- b.shader->info.name = ralloc_strdup(b.shader, "BLORP-clear");
+ nir_builder_init_simple_shader(&b, mem_ctx, MESA_SHADER_FRAGMENT, NULL);
+ b.shader->info->name = ralloc_strdup(b.shader, "BLORP-clear");
nir_variable *v_color = nir_variable_create(b.shader, nir_var_shader_in,
glsl_vec4_type(), "v_color");
struct brw_wm_prog_key wm_key;
brw_blorp_init_wm_prog_key(&wm_key);
- struct brw_blorp_prog_data prog_data;
+ struct brw_wm_prog_data prog_data;
unsigned program_size;
const unsigned *program =
- brw_blorp_compile_nir_shader(blorp, b.shader, &wm_key, use_replicated_data,
- &prog_data, &program_size);
+ blorp_compile_fs(blorp, mem_ctx, b.shader, &wm_key, use_replicated_data,
+ &prog_data, &program_size);
blorp->upload_shader(blorp, &blorp_key, sizeof(blorp_key),
program, program_size,
- &prog_data, sizeof(prog_data),
+ &prog_data.base, sizeof(prog_data),
¶ms->wm_prog_kernel, ¶ms->wm_prog_data);
ralloc_free(mem_ctx);
void
blorp_fast_clear(struct blorp_batch *batch,
- const struct blorp_surf *surf,
- uint32_t level, uint32_t layer, enum isl_format format,
+ const struct blorp_surf *surf, enum isl_format format,
+ uint32_t level, uint32_t start_layer, uint32_t num_layers,
uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1)
{
struct blorp_params params;
blorp_params_init(¶ms);
+ params.num_layers = num_layers;
params.x0 = x0;
params.y0 = y0;
blorp_params_get_clear_kernel(batch->blorp, ¶ms, true);
- brw_blorp_surface_info_init(batch->blorp, ¶ms.dst, surf, level, layer,
- format, true);
+ brw_blorp_surface_info_init(batch->blorp, ¶ms.dst, surf, level,
+ start_layer, format, true);
+ params.num_samples = params.dst.surf.samples;
batch->blorp->exec(batch, ¶ms);
}
void
blorp_clear(struct blorp_batch *batch,
const struct blorp_surf *surf,
- uint32_t level, uint32_t layer,
+ enum isl_format format, struct isl_swizzle swizzle,
+ uint32_t level, uint32_t start_layer, uint32_t num_layers,
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])
+ union isl_color_value clear_color,
+ const bool color_write_disable[4])
{
struct blorp_params params;
blorp_params_init(¶ms);
params.x1 = x1;
params.y1 = y1;
+ if (format == ISL_FORMAT_R9G9B9E5_SHAREDEXP) {
+ clear_color.u32[0] = float3_to_rgb9e5(clear_color.f32);
+ format = ISL_FORMAT_R32_UINT;
+ }
+
memcpy(¶ms.wm_inputs, clear_color.f32, sizeof(float) * 4);
bool use_simd16_replicated_data = true;
/* Constant color writes ignore everyting in blend and color calculator
* state. This is not documented.
*/
- 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;
+ if (color_write_disable) {
+ 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;
+ }
}
blorp_params_get_clear_kernel(batch->blorp, ¶ms,
use_simd16_replicated_data);
- brw_blorp_surface_info_init(batch->blorp, ¶ms.dst, surf, level, layer,
- format, true);
+ while (num_layers > 0) {
+ brw_blorp_surface_info_init(batch->blorp, ¶ms.dst, surf, level,
+ start_layer, format, true);
+ params.dst.view.swizzle = swizzle;
- batch->blorp->exec(batch, ¶ms);
+ params.num_samples = params.dst.surf.samples;
+
+ /* We may be restricted on the number of layers we can bind at any one
+ * time. In particular, Sandy Bridge has a maximum number of layers of
+ * 512 but a maximum 3D texture size is much larger.
+ */
+ params.num_layers = MIN2(params.dst.view.array_len, num_layers);
+ batch->blorp->exec(batch, ¶ms);
+
+ start_layer += params.num_layers;
+ num_layers -= params.num_layers;
+ }
+}
+
+void
+blorp_clear_depth_stencil(struct blorp_batch *batch,
+ const struct blorp_surf *depth,
+ const struct blorp_surf *stencil,
+ uint32_t level, uint32_t start_layer,
+ uint32_t num_layers,
+ uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1,
+ bool clear_depth, float depth_value,
+ uint8_t stencil_mask, uint8_t stencil_value)
+{
+ struct blorp_params params;
+ blorp_params_init(¶ms);
+
+ params.x0 = x0;
+ params.y0 = y0;
+ params.x1 = x1;
+ params.y1 = y1;
+
+ while (num_layers > 0) {
+ params.num_layers = num_layers;
+
+ if (stencil_mask) {
+ brw_blorp_surface_info_init(batch->blorp, ¶ms.stencil, stencil,
+ level, start_layer,
+ ISL_FORMAT_UNSUPPORTED, true);
+ params.stencil_mask = stencil_mask;
+ params.stencil_ref = stencil_value;
+
+ params.dst.surf.samples = params.stencil.surf.samples;
+ params.dst.surf.logical_level0_px =
+ params.stencil.surf.logical_level0_px;
+ params.dst.view = params.depth.view;
+
+ params.num_samples = params.stencil.surf.samples;
+
+ /* We may be restricted on the number of layers we can bind at any
+ * one time. In particular, Sandy Bridge has a maximum number of
+ * layers of 512 but a maximum 3D texture size is much larger.
+ */
+ if (params.stencil.view.array_len < params.num_layers)
+ params.num_layers = params.stencil.view.array_len;
+ }
+
+ if (clear_depth) {
+ brw_blorp_surface_info_init(batch->blorp, ¶ms.depth, depth,
+ level, start_layer,
+ ISL_FORMAT_UNSUPPORTED, true);
+ params.z = depth_value;
+ params.depth_format =
+ isl_format_get_depth_format(depth->surf->format, false);
+
+ params.dst.surf.samples = params.depth.surf.samples;
+ params.dst.surf.logical_level0_px =
+ params.depth.surf.logical_level0_px;
+ params.dst.view = params.depth.view;
+
+ params.num_samples = params.depth.surf.samples;
+
+ /* We may be restricted on the number of layers we can bind at any
+ * one time. In particular, Sandy Bridge has a maximum number of
+ * layers of 512 but a maximum 3D texture size is much larger.
+ */
+ if (params.depth.view.array_len < params.num_layers)
+ params.num_layers = params.depth.view.array_len;
+ }
+
+ batch->blorp->exec(batch, ¶ms);
+
+ start_layer += params.num_layers;
+ num_layers -= params.num_layers;
+ }
}
void