From: Jason Ekstrand Date: Fri, 3 Jun 2016 02:02:23 +0000 (-0700) Subject: isl/state: Refactor the setup of clear colors X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=87f0ffa646e97def0f81ba2ad12eab2702dfd7b1;p=mesa.git isl/state: Refactor the setup of clear colors This commit switches clear colors to use #if's instead of a C if. This lets us properly handle SNB where the clear color field doesn't exist. Reviewed-by: Chad Versace Cc: "12.0" --- diff --git a/src/intel/isl/isl_surface_state.c b/src/intel/isl/isl_surface_state.c index 745fea89d00..f36c0199ada 100644 --- a/src/intel/isl/isl_surface_state.c +++ b/src/intel/isl/isl_surface_state.c @@ -373,31 +373,35 @@ isl_genX(surf_fill_state_s)(const struct isl_device *dev, void *state, } #endif - if (GEN_GEN <= 8) { - /* Prior to Sky Lake, we only have one bit for the clear color which - * gives us 0 or 1 in whatever the surface's format happens to be. - */ - if (isl_format_has_int_channel(info->view->format)) { - for (unsigned i = 0; i < 4; i++) { - assert(info->clear_color.u32[i] == 0 || - info->clear_color.u32[i] == 1); - } - } else { - for (unsigned i = 0; i < 4; i++) { - assert(info->clear_color.f32[i] == 0.0f || - info->clear_color.f32[i] == 1.0f); - } +#if GEN_GEN >= 9 + s.RedClearColor = info->clear_color.u32[0]; + s.GreenClearColor = info->clear_color.u32[1]; + s.BlueClearColor = info->clear_color.u32[2]; + s.AlphaClearColor = info->clear_color.u32[3]; +#elif GEN_GEN >= 7 + /* Prior to Sky Lake, we only have one bit for the clear color which + * gives us 0 or 1 in whatever the surface's format happens to be. + */ + if (isl_format_has_int_channel(info->view->format)) { + for (unsigned i = 0; i < 4; i++) { + assert(info->clear_color.u32[i] == 0 || + info->clear_color.u32[i] == 1); } s.RedClearColor = info->clear_color.u32[0] != 0; s.GreenClearColor = info->clear_color.u32[1] != 0; s.BlueClearColor = info->clear_color.u32[2] != 0; s.AlphaClearColor = info->clear_color.u32[3] != 0; } else { - s.RedClearColor = info->clear_color.u32[0]; - s.GreenClearColor = info->clear_color.u32[1]; - s.BlueClearColor = info->clear_color.u32[2]; - s.AlphaClearColor = info->clear_color.u32[3]; + for (unsigned i = 0; i < 4; i++) { + assert(info->clear_color.f32[i] == 0.0f || + info->clear_color.f32[i] == 1.0f); + } + s.RedClearColor = info->clear_color.f32[0] != 0.0f; + s.GreenClearColor = info->clear_color.f32[1] != 0.0f; + s.BlueClearColor = info->clear_color.f32[2] != 0.0f; + s.AlphaClearColor = info->clear_color.f32[3] != 0.0f; } +#endif GENX(RENDER_SURFACE_STATE_pack)(NULL, state, &s); }