anv: Remove default scissor and viewport concepts
authorNanley Chery <nanley.g.chery@intel.com>
Thu, 31 Mar 2016 00:13:01 +0000 (17:13 -0700)
committerNanley Chery <nanley.g.chery@intel.com>
Thu, 14 Apr 2016 01:02:38 +0000 (18:02 -0700)
Users should never provide a scissor or viewport count of 0 because
they are required to set such state in a graphics pipeline. This
behavior was previously only used in Meta, which actually just
disables those hardware operations at pipeline creation time.

Kristian noticed that the current assignment of viewport count
reduces the number of viewport uploads, so it is not removed.

Signed-off-by: Nanley Chery <nanley.g.chery@intel.com>
Reviewed-by: Kristian Høgsberg Kristensen <kristian.h.kristensen@intel.com>
src/intel/vulkan/anv_meta_clear.c
src/intel/vulkan/anv_meta_resolve.c
src/intel/vulkan/gen7_cmd_buffer.c
src/intel/vulkan/gen8_cmd_buffer.c

index c5c7d563e91b32579d6b293abaa69ff0d8d75226..eb4e56984c35659388fdb5d423f4c5870fdf63ad 100644 (file)
@@ -47,8 +47,8 @@ meta_clear_begin(struct anv_meta_saved_state *saved_state,
                  (1 << VK_DYNAMIC_STATE_STENCIL_REFERENCE) |
                  (1 << VK_DYNAMIC_STATE_STENCIL_WRITE_MASK));
 
+   /* Avoid uploading more viewport states than necessary */
    cmd_buffer->state.dynamic.viewport.count = 0;
-   cmd_buffer->state.dynamic.scissor.count = 0;
 }
 
 static void
index f83bb6bbfd38df567cd4e5d76590590544c64070..7d2a75bb7529476be72129b1542d1c7a0fecc03d 100644 (file)
@@ -42,9 +42,6 @@ meta_resolve_save(struct anv_meta_saved_state *saved_state,
                   struct anv_cmd_buffer *cmd_buffer)
 {
    anv_meta_save(saved_state, cmd_buffer, 0);
-
-   cmd_buffer->state.dynamic.viewport.count = 0;
-   cmd_buffer->state.dynamic.scissor.count = 0;
 }
 
 static void
index b5d21efb2034ea7191b626d5891900c223df8ea8..5130a40d2777491078267ad45fb7701a75f26f3f 100644 (file)
@@ -133,10 +133,11 @@ clamp_int64(int64_t x, int64_t min, int64_t max)
 }
 
 #if GEN_GEN == 7 && !GEN_IS_HASWELL
-static void
-emit_scissor_state(struct anv_cmd_buffer *cmd_buffer,
-                   uint32_t count, const VkRect2D *scissors)
+void
+gen7_cmd_buffer_emit_scissor(struct anv_cmd_buffer *cmd_buffer)
 {
+   uint32_t count = cmd_buffer->state.dynamic.scissor.count;
+   const VkRect2D *scissors =  cmd_buffer->state.dynamic.scissor.scissors;
    struct anv_state scissor_state =
       anv_cmd_buffer_alloc_dynamic_state(cmd_buffer, count * 8, 32);
 
@@ -178,25 +179,6 @@ emit_scissor_state(struct anv_cmd_buffer *cmd_buffer,
    if (!cmd_buffer->device->info.has_llc)
       anv_state_clflush(scissor_state);
 }
-
-void
-gen7_cmd_buffer_emit_scissor(struct anv_cmd_buffer *cmd_buffer)
-{
-   if (cmd_buffer->state.dynamic.scissor.count > 0) {
-      emit_scissor_state(cmd_buffer, cmd_buffer->state.dynamic.scissor.count,
-                         cmd_buffer->state.dynamic.scissor.scissors);
-   } else {
-      /* Emit a default scissor based on the currently bound framebuffer */
-      emit_scissor_state(cmd_buffer, 1,
-                         &(VkRect2D) {
-                            .offset = { .x = 0, .y = 0, },
-                            .extent = {
-                               .width = cmd_buffer->state.framebuffer->width,
-                               .height = cmd_buffer->state.framebuffer->height,
-                            },
-                         });
-   }
-}
 #endif
 
 static const uint32_t vk_to_gen_index_type[] = {
index 5b6afb3d70d5adf5283fbd99dacab08f00c7a54a..3956a58d2016ebc570b0e768a4479a468cc593cc 100644 (file)
 #include "genxml/genX_pack.h"
 
 #if GEN_GEN == 8
-static void
-emit_viewport_state(struct anv_cmd_buffer *cmd_buffer,
-                    uint32_t count, const VkViewport *viewports)
+void
+gen8_cmd_buffer_emit_viewport(struct anv_cmd_buffer *cmd_buffer)
 {
+   uint32_t count = cmd_buffer->state.dynamic.viewport.count;
+   const VkViewport *viewports = cmd_buffer->state.dynamic.viewport.viewports;
    struct anv_state sf_clip_state =
       anv_cmd_buffer_alloc_dynamic_state(cmd_buffer, count * 64, 64);
    struct anv_state cc_state =
@@ -86,26 +87,6 @@ emit_viewport_state(struct anv_cmd_buffer *cmd_buffer,
                   GENX(3DSTATE_VIEWPORT_STATE_POINTERS_SF_CLIP),
                   .SFClipViewportPointer = sf_clip_state.offset);
 }
-
-void
-gen8_cmd_buffer_emit_viewport(struct anv_cmd_buffer *cmd_buffer)
-{
-   if (cmd_buffer->state.dynamic.viewport.count > 0) {
-      emit_viewport_state(cmd_buffer, cmd_buffer->state.dynamic.viewport.count,
-                          cmd_buffer->state.dynamic.viewport.viewports);
-   } else {
-      /* If viewport count is 0, this is taken to mean "use the default" */
-      emit_viewport_state(cmd_buffer, 1,
-                          &(VkViewport) {
-                             .x = 0.0f,
-                             .y = 0.0f,
-                             .width = cmd_buffer->state.framebuffer->width,
-                             .height = cmd_buffer->state.framebuffer->height,
-                             .minDepth = 0.0f,
-                             .maxDepth = 1.0f,
-                          });
-   }
-}
 #endif
 
 #define emit_lri(batch, reg, imm)                       \