From 3d1a4d1f5b26400878fa99c723759a2c54721de2 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Sat, 26 Jul 2014 20:49:32 -0700 Subject: [PATCH] i965: Make BLORP use brw_emit_sampler_state(). This simplifies the code, removes use of the old structures, and also allows us to combine the Gen6 and Gen7+ code. Signed-off-by: Kenneth Graunke Reviewed-by: Topi Pohjolainen --- src/mesa/drivers/dri/i965/brw_blorp.h | 4 ++ src/mesa/drivers/dri/i965/gen6_blorp.cpp | 65 ++++++++++-------------- src/mesa/drivers/dri/i965/gen7_blorp.cpp | 59 +-------------------- 3 files changed, 33 insertions(+), 95 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_blorp.h b/src/mesa/drivers/dri/i965/brw_blorp.h index 683f09e681f..419744f0730 100644 --- a/src/mesa/drivers/dri/i965/brw_blorp.h +++ b/src/mesa/drivers/dri/i965/brw_blorp.h @@ -420,6 +420,10 @@ gen6_blorp_emit_clip_disable(struct brw_context *brw, void gen6_blorp_emit_drawing_rectangle(struct brw_context *brw, const brw_blorp_params *params); + +uint32_t +gen6_blorp_emit_sampler_state(struct brw_context *brw, + const brw_blorp_params *params); /** \} */ #endif /* __cplusplus */ diff --git a/src/mesa/drivers/dri/i965/gen6_blorp.cpp b/src/mesa/drivers/dri/i965/gen6_blorp.cpp index d4198860c46..1cab8b71ff0 100644 --- a/src/mesa/drivers/dri/i965/gen6_blorp.cpp +++ b/src/mesa/drivers/dri/i965/gen6_blorp.cpp @@ -445,53 +445,44 @@ gen6_blorp_emit_binding_table(struct brw_context *brw, /** * SAMPLER_STATE. See brw_update_sampler_state(). */ -static uint32_t +uint32_t gen6_blorp_emit_sampler_state(struct brw_context *brw, const brw_blorp_params *params) { uint32_t sampler_offset; + uint32_t *sampler_state = (uint32_t *) + brw_state_batch(brw, AUB_TRACE_SAMPLER_STATE, 16, 32, &sampler_offset); - struct brw_sampler_state *sampler = (struct brw_sampler_state *) - brw_state_batch(brw, AUB_TRACE_SAMPLER_STATE, - sizeof(struct brw_sampler_state), - 32, &sampler_offset); - memset(sampler, 0, sizeof(*sampler)); - - sampler->ss0.min_filter = BRW_MAPFILTER_LINEAR; - sampler->ss0.mip_filter = BRW_MIPFILTER_NONE; - sampler->ss0.mag_filter = BRW_MAPFILTER_LINEAR; - - sampler->ss1.r_wrap_mode = BRW_TEXCOORDMODE_CLAMP; - sampler->ss1.s_wrap_mode = BRW_TEXCOORDMODE_CLAMP; - sampler->ss1.t_wrap_mode = BRW_TEXCOORDMODE_CLAMP; - - /* Set LOD bias: - */ - sampler->ss0.lod_bias = 0; + unsigned address_rounding = BRW_ADDRESS_ROUNDING_ENABLE_U_MIN | + BRW_ADDRESS_ROUNDING_ENABLE_V_MIN | + BRW_ADDRESS_ROUNDING_ENABLE_R_MIN | + BRW_ADDRESS_ROUNDING_ENABLE_U_MAG | + BRW_ADDRESS_ROUNDING_ENABLE_V_MAG | + BRW_ADDRESS_ROUNDING_ENABLE_R_MAG; - sampler->ss0.lod_preclamp = 1; /* OpenGL mode */ - sampler->ss0.default_color_mode = 0; /* OpenGL/DX10 mode */ - - /* Set BaseMipLevel, MaxLOD, MinLOD: - * - * XXX: I don't think that using firstLevel, lastLevel works, + /* XXX: I don't think that using firstLevel, lastLevel works, * because we always setup the surface state as if firstLevel == * level zero. Probably have to subtract firstLevel from each of * these: */ - sampler->ss0.base_level = U_FIXED(0, 1); - - sampler->ss1.max_lod = U_FIXED(0, 6); - sampler->ss1.min_lod = U_FIXED(0, 6); - - sampler->ss3.non_normalized_coord = 1; - - sampler->ss3.address_round |= BRW_ADDRESS_ROUNDING_ENABLE_U_MIN | - BRW_ADDRESS_ROUNDING_ENABLE_V_MIN | - BRW_ADDRESS_ROUNDING_ENABLE_R_MIN; - sampler->ss3.address_round |= BRW_ADDRESS_ROUNDING_ENABLE_U_MAG | - BRW_ADDRESS_ROUNDING_ENABLE_V_MAG | - BRW_ADDRESS_ROUNDING_ENABLE_R_MAG; + brw_emit_sampler_state(brw, + sampler_state, + sampler_offset, + BRW_MAPFILTER_LINEAR, /* min filter */ + BRW_MAPFILTER_LINEAR, /* mag filter */ + BRW_MIPFILTER_NONE, + BRW_ANISORATIO_2, + address_rounding, + BRW_TEXCOORDMODE_CLAMP, + BRW_TEXCOORDMODE_CLAMP, + BRW_TEXCOORDMODE_CLAMP, + 0, /* min LOD */ + 0, /* max LOD */ + 0, /* LOD bias */ + 0, /* base miplevel */ + 0, /* shadow function */ + true, /* non-normalized coordinates */ + 0); /* border color offset - unused */ return sampler_offset; } diff --git a/src/mesa/drivers/dri/i965/gen7_blorp.cpp b/src/mesa/drivers/dri/i965/gen7_blorp.cpp index 0ad570b44f4..1cf55fd4cf5 100644 --- a/src/mesa/drivers/dri/i965/gen7_blorp.cpp +++ b/src/mesa/drivers/dri/i965/gen7_blorp.cpp @@ -223,63 +223,6 @@ gen7_blorp_emit_surface_state(struct brw_context *brw, } -/** - * SAMPLER_STATE. See gen7_update_sampler_state(). - */ -static uint32_t -gen7_blorp_emit_sampler_state(struct brw_context *brw, - const brw_blorp_params *params) -{ - uint32_t sampler_offset; - - struct gen7_sampler_state *sampler = (struct gen7_sampler_state *) - brw_state_batch(brw, AUB_TRACE_SAMPLER_STATE, - sizeof(struct gen7_sampler_state), - 32, &sampler_offset); - memset(sampler, 0, sizeof(*sampler)); - - sampler->ss0.min_filter = BRW_MAPFILTER_LINEAR; - sampler->ss0.mip_filter = BRW_MIPFILTER_NONE; - sampler->ss0.mag_filter = BRW_MAPFILTER_LINEAR; - - sampler->ss3.r_wrap_mode = BRW_TEXCOORDMODE_CLAMP; - sampler->ss3.s_wrap_mode = BRW_TEXCOORDMODE_CLAMP; - sampler->ss3.t_wrap_mode = BRW_TEXCOORDMODE_CLAMP; - - // sampler->ss0.min_mag_neq = 1; - - /* Set LOD bias: - */ - sampler->ss0.lod_bias = 0; - - sampler->ss0.lod_preclamp = 1; /* OpenGL mode */ - sampler->ss0.default_color_mode = 0; /* OpenGL/DX10 mode */ - - /* Set BaseMipLevel, MaxLOD, MinLOD: - * - * XXX: I don't think that using firstLevel, lastLevel works, - * because we always setup the surface state as if firstLevel == - * level zero. Probably have to subtract firstLevel from each of - * these: - */ - sampler->ss0.base_level = U_FIXED(0, 1); - - sampler->ss1.max_lod = U_FIXED(0, 8); - sampler->ss1.min_lod = U_FIXED(0, 8); - - sampler->ss3.non_normalized_coord = 1; - - sampler->ss3.address_round |= BRW_ADDRESS_ROUNDING_ENABLE_U_MIN | - BRW_ADDRESS_ROUNDING_ENABLE_V_MIN | - BRW_ADDRESS_ROUNDING_ENABLE_R_MIN; - sampler->ss3.address_round |= BRW_ADDRESS_ROUNDING_ENABLE_U_MAG | - BRW_ADDRESS_ROUNDING_ENABLE_V_MAG | - BRW_ADDRESS_ROUNDING_ENABLE_R_MAG; - - return sampler_offset; -} - - /* 3DSTATE_VS * * Disable vertex shader. @@ -898,7 +841,7 @@ gen7_blorp_exec(struct brw_context *brw, gen6_blorp_emit_binding_table(brw, params, wm_surf_offset_renderbuffer, wm_surf_offset_texture); - sampler_offset = gen7_blorp_emit_sampler_state(brw, params); + sampler_offset = gen6_blorp_emit_sampler_state(brw, params); } gen7_blorp_emit_vs_disable(brw, params); gen7_blorp_emit_hs_disable(brw, params); -- 2.30.2