nil: Rename rendering to color_target
authorFaith Ekstrand <faith.ekstrand@collabora.com>
Tue, 31 Jan 2023 02:11:54 +0000 (20:11 -0600)
committerMarge Bot <emma+marge@anholt.net>
Fri, 4 Aug 2023 21:31:57 +0000 (21:31 +0000)
Also, add a helper for depth/stencil formats and use
nil_format_supports_color_targets() helper to compute Vulkan format
features rather than checking for a non-zero color format.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24326>

src/nouveau/nil/nil_format.c
src/nouveau/nil/nil_format.h
src/nouveau/vulkan/nvk_cmd_draw.c

index c8b9c0c..0c9efd7 100644 (file)
@@ -330,16 +330,24 @@ static const struct nil_format_info nil_format_infos[PIPE_FORMAT_COUNT] =
 };
 
 bool
-nil_format_supports_render(struct nouveau_ws_device *dev,
-                           enum pipe_format format)
+nil_format_supports_color_targets(struct nouveau_ws_device *dev,
+                                  enum pipe_format format)
 {
    assert(format < PIPE_FORMAT_COUNT);
    const struct nil_format_info *fmt = &nil_format_infos[format];
    return fmt->czt != 0;
 }
 
-uint32_t
-nil_format_to_render(enum pipe_format format)
+uint8_t
+nil_format_to_color_target(enum pipe_format format)
+{
+   assert(format < PIPE_FORMAT_COUNT);
+   const struct nil_format_info *fmt = &nil_format_infos[format];
+   return fmt->czt;
+}
+
+uint8_t
+nil_format_to_depth_stencil(enum pipe_format format)
 {
    assert(format < PIPE_FORMAT_COUNT);
    const struct nil_format_info *fmt = &nil_format_infos[format];
index 12825c5..acd6ee0 100644 (file)
@@ -11,10 +11,12 @@ struct nouveau_ws_device;
 
 /* We don't have our own format enum; we use PIPE_FORMAT for everything */
 
-bool nil_format_supports_render(struct nouveau_ws_device *dev,
-                                enum pipe_format format);
+bool nil_format_supports_color_targets(struct nouveau_ws_device *dev,
+                                       enum pipe_format format);
 
-uint32_t nil_format_to_render(enum pipe_format format);
+uint8_t nil_format_to_color_target(enum pipe_format format);
+
+uint8_t nil_format_to_depth_stencil(enum pipe_format format);
 
 struct nil_tic_format {
    unsigned comp_sizes:8;
index 3eafe2e..e994902 100644 (file)
@@ -434,7 +434,8 @@ nvk_CmdBeginRendering(VkCommandBuffer commandBuffer,
          P_NV9097_SET_COLOR_TARGET_HEIGHT(p, i, iview->vk.extent.height);
          const enum pipe_format p_format =
             vk_format_to_pipe_format(iview->vk.format);
-         P_NV9097_SET_COLOR_TARGET_FORMAT(p, i, nil_format_to_render(p_format));
+         const uint8_t ct_format = nil_format_to_color_target(p_format);
+         P_NV9097_SET_COLOR_TARGET_FORMAT(p, i, ct_format);
          P_NV9097_SET_COLOR_TARGET_MEMORY(p, i, {
             .block_width   = BLOCK_WIDTH_ONE_GOB,
             .block_height  = level->tiling.y_log2,
@@ -497,7 +498,8 @@ nvk_CmdBeginRendering(VkCommandBuffer commandBuffer,
       P_NV9097_SET_ZT_B(p, addr);
       const enum pipe_format p_format =
          vk_format_to_pipe_format(iview->vk.format);
-      P_NV9097_SET_ZT_FORMAT(p, nil_format_to_render(p_format));
+      const uint8_t zs_format = nil_format_to_depth_stencil(p_format);
+      P_NV9097_SET_ZT_FORMAT(p, zs_format);
       assert(image->nil.dim != NIL_IMAGE_DIM_3D);
       P_NV9097_SET_ZT_BLOCK_SIZE(p, {
          .width = WIDTH_ONE_GOB,