~mmach/netext73/mesa-ryzen

« back to all changes in this revision

Viewing changes to src/intel/blorp/blorp_genX_exec.h

  • Committer: mmach
  • Date: 2023-11-02 21:31:35 UTC
  • Revision ID: netbit73@gmail.com-20231102213135-18d4tzh7tj0uz752
2023-11-02 22:11:57

Show diffs side-by-side

added added

removed removed

Lines of Context:
267
267
         urb.VSNumberofURBEntries      = entries[i];
268
268
      }
269
269
   }
 
270
 
 
271
   if (batch->blorp->config.use_mesh_shading) {
 
272
#if GFX_VERx10 >= 125
 
273
      blorp_emit(batch, GENX(3DSTATE_URB_ALLOC_MESH), zero);
 
274
      blorp_emit(batch, GENX(3DSTATE_URB_ALLOC_TASK), zero);
 
275
#endif
 
276
   }
 
277
 
270
278
#else /* GFX_VER < 7 */
271
279
   blorp_emit_urb_config(batch, vs_entry_size, sf_entry_size);
272
280
#endif
896
904
         unreachable("Invalid fast clear op");
897
905
      }
898
906
 
 
907
      /* The RENDER_SURFACE_STATE page for TGL says:
 
908
       *
 
909
       *   For an 8 bpp surface with NUM_MULTISAMPLES = 1, Surface Width not
 
910
       *   multiple of 64 pixels and more than 1 mip level in the view, Fast
 
911
       *   Clear is not supported when AUX_CCS_E is set in this field.
 
912
       *
 
913
       * The granularity of a fast-clear or ambiguate operation is likely one
 
914
       * CCS element. For an 8 bpp primary surface, this maps to 32px x 4rows.
 
915
       * Due to the surface layout parameters, if LOD0's width isn't a
 
916
       * multiple of 64px, LOD1 and LOD2+ will share CCS elements. Assert that
 
917
       * these operations aren't occurring on these LODs.
 
918
       *
 
919
       * We don't explicitly check for TGL+ because the restriction is
 
920
       * technically applicable to all hardware. Platforms prior to TGL don't
 
921
       * support CCS on 8 bpp surfaces. So, these unaligned fast clear
 
922
       * operations shouldn't be occurring prior to TGL as well.
 
923
       */
 
924
      if (isl_format_get_layout(params->dst.surf.format)->bpb == 8 &&
 
925
          params->dst.surf.logical_level0_px.width % 64 != 0 &&
 
926
          params->dst.surf.levels >= 3 &&
 
927
          params->dst.view.base_level >= 1) {
 
928
         assert(params->num_samples == 1);
 
929
         assert(!ps.RenderTargetFastClearEnable);
 
930
      }
 
931
 
899
932
      if (prog_data) {
900
933
         intel_set_ps_dispatch_state(&ps, devinfo, prog_data,
901
934
                                     params->num_samples,
1397
1430
 
1398
1431
   if (batch->blorp->config.use_mesh_shading) {
1399
1432
#if GFX_VERx10 >= 125
1400
 
      blorp_emit(batch, GENX(3DSTATE_URB_ALLOC_MESH), zero);
1401
 
      blorp_emit(batch, GENX(3DSTATE_URB_ALLOC_TASK), zero);
1402
 
 
1403
 
      blorp_emit(batch, GENX(3DSTATE_MESH_SHADER), zero);
1404
 
      blorp_emit(batch, GENX(3DSTATE_TASK_SHADER), zero);
1405
 
 
1406
1433
      blorp_emit(batch, GENX(3DSTATE_MESH_CONTROL), zero);
1407
1434
      blorp_emit(batch, GENX(3DSTATE_TASK_CONTROL), zero);
1408
1435
#endif
1629
1656
      }
1630
1657
   }
1631
1658
 
1632
 
#if GFX_VER >= 7 && GFX_VER < 12
1633
 
   if (has_indirect_clear_color) {
1634
 
      /* Updating a surface state object may require that the state cache be
1635
 
       * invalidated. From the SKL PRM, Shared Functions -> State -> State
1636
 
       * Caching:
1637
 
       *
1638
 
       *    Whenever the RENDER_SURFACE_STATE object in memory pointed to by
1639
 
       *    the Binding Table Pointer (BTP) and Binding Table Index (BTI) is
1640
 
       *    modified [...], the L1 state cache must be invalidated to ensure
1641
 
       *    the new surface or sampler state is fetched from system memory.
1642
 
       *
1643
 
       * XXX - Investigate why exactly this invalidation is necessary to
1644
 
       *       avoid Vulkan regressions on ICL.  It's possible that the
1645
 
       *       MI_ATOMIC used to update the clear color isn't correctly
1646
 
       *       ordered with the pre-existing invalidation in
1647
 
       *       blorp_update_clear_color().
1648
 
       */
1649
 
      blorp_emit(batch, GENX(PIPE_CONTROL), pipe) {
1650
 
         pipe.StateCacheInvalidationEnable = true;
1651
 
      }
1652
 
   }
1653
 
#endif
1654
 
 
1655
1659
   return bind_offset;
1656
1660
}
1657
1661
 
1896
1900
 
1897
1901
static void
1898
1902
blorp_update_clear_color(UNUSED struct blorp_batch *batch,
1899
 
                         const struct brw_blorp_surface_info *info,
1900
 
                         enum isl_aux_op op)
 
1903
                         const struct brw_blorp_surface_info *info)
1901
1904
{
1902
 
   if (info->clear_color_addr.buffer && op == ISL_AUX_OP_FAST_CLEAR) {
 
1905
   assert(info->clear_color_addr.buffer != NULL);
1903
1906
#if GFX_VER == 11
1904
 
      blorp_emit(batch, GENX(PIPE_CONTROL), pipe) {
1905
 
         pipe.CommandStreamerStallEnable = true;
1906
 
      }
1907
 
 
1908
 
      /* 2 QWORDS */
1909
 
      const unsigned inlinedata_dw = 2 * 2;
1910
 
      const unsigned num_dwords = GENX(MI_ATOMIC_length) + inlinedata_dw;
1911
 
 
1912
 
      struct blorp_address clear_addr = info->clear_color_addr;
1913
 
      uint32_t *dw = blorp_emitn(batch, GENX(MI_ATOMIC), num_dwords,
1914
 
                                 .DataSize = MI_ATOMIC_QWORD,
1915
 
                                 .ATOMICOPCODE = MI_ATOMIC_OP_MOVE8B,
1916
 
                                 .InlineData = true,
1917
 
                                 .MemoryAddress = clear_addr);
1918
 
      /* dw starts at dword 1, but we need to fill dwords 3 and 5 */
1919
 
      dw[2] = info->clear_color.u32[0];
1920
 
      dw[3] = 0;
1921
 
      dw[4] = info->clear_color.u32[1];
1922
 
      dw[5] = 0;
1923
 
 
1924
 
      clear_addr.offset += 8;
1925
 
      dw = blorp_emitn(batch, GENX(MI_ATOMIC), num_dwords,
1926
 
                                 .DataSize = MI_ATOMIC_QWORD,
1927
 
                                 .ATOMICOPCODE = MI_ATOMIC_OP_MOVE8B,
1928
 
                                 .CSSTALL = true,
1929
 
                                 .ReturnDataControl = true,
1930
 
                                 .InlineData = true,
1931
 
                                 .MemoryAddress = clear_addr);
1932
 
      /* dw starts at dword 1, but we need to fill dwords 3 and 5 */
1933
 
      dw[2] = info->clear_color.u32[2];
1934
 
      dw[3] = 0;
1935
 
      dw[4] = info->clear_color.u32[3];
1936
 
      dw[5] = 0;
1937
 
 
1938
 
      blorp_emit(batch, GENX(PIPE_CONTROL), pipe) {
1939
 
         pipe.StateCacheInvalidationEnable = true;
1940
 
         pipe.TextureCacheInvalidationEnable = true;
1941
 
      }
 
1907
   /* 2 QWORDS */
 
1908
   const unsigned inlinedata_dw = 2 * 2;
 
1909
   const unsigned num_dwords = GENX(MI_ATOMIC_length) + inlinedata_dw;
 
1910
 
 
1911
   struct blorp_address clear_addr = info->clear_color_addr;
 
1912
   uint32_t *dw = blorp_emitn(batch, GENX(MI_ATOMIC), num_dwords,
 
1913
                              .DataSize = MI_ATOMIC_QWORD,
 
1914
                              .ATOMICOPCODE = MI_ATOMIC_OP_MOVE8B,
 
1915
                              .InlineData = true,
 
1916
                              .MemoryAddress = clear_addr);
 
1917
   /* dw starts at dword 1, but we need to fill dwords 3 and 5 */
 
1918
   dw[2] = info->clear_color.u32[0];
 
1919
   dw[3] = 0;
 
1920
   dw[4] = info->clear_color.u32[1];
 
1921
   dw[5] = 0;
 
1922
 
 
1923
   clear_addr.offset += 8;
 
1924
   dw = blorp_emitn(batch, GENX(MI_ATOMIC), num_dwords,
 
1925
                    .DataSize = MI_ATOMIC_QWORD,
 
1926
                    .ATOMICOPCODE = MI_ATOMIC_OP_MOVE8B,
 
1927
                    .CSSTALL = true,
 
1928
                    .ReturnDataControl = true,
 
1929
                    .InlineData = true,
 
1930
                    .MemoryAddress = clear_addr);
 
1931
   /* dw starts at dword 1, but we need to fill dwords 3 and 5 */
 
1932
   dw[2] = info->clear_color.u32[2];
 
1933
   dw[3] = 0;
 
1934
   dw[4] = info->clear_color.u32[3];
 
1935
   dw[5] = 0;
 
1936
 
1942
1937
#elif GFX_VER >= 9
1943
1938
 
1944
 
      /* According to Wa_2201730850, in the Clear Color Programming Note
1945
 
       * under the Red channel, "Software shall write the converted Depth
1946
 
       * Clear to this dword." The only depth formats listed under the red
1947
 
       * channel are IEEE_FP and UNORM24_X8. These two requirements are
1948
 
       * incompatible with the UNORM16 depth format, so just ignore that case
1949
 
       * and simply perform the conversion for all depth formats.
1950
 
       */
1951
 
      union isl_color_value fixed_color = info->clear_color;
1952
 
      if (GFX_VER == 12 && isl_surf_usage_is_depth(info->surf.usage)) {
1953
 
         isl_color_value_pack(&info->clear_color, info->surf.format,
1954
 
                              fixed_color.u32);
1955
 
      }
1956
 
 
1957
 
      for (int i = 0; i < 4; i++) {
1958
 
         blorp_emit(batch, GENX(MI_STORE_DATA_IMM), sdi) {
1959
 
            sdi.Address = info->clear_color_addr;
1960
 
            sdi.Address.offset += i * 4;
1961
 
            sdi.ImmediateData = fixed_color.u32[i];
1962
 
#if GFX_VER >= 12
1963
 
            if (i == 3)
1964
 
               sdi.ForceWriteCompletionCheck = true;
1965
 
#endif
1966
 
         }
1967
 
      }
1968
 
 
1969
 
/* The RENDER_SURFACE_STATE::ClearColor field states that software should
1970
 
 * write the converted depth value 16B after the clear address:
1971
 
 *
1972
 
 *    3D Sampler will always fetch clear depth from the location 16-bytes
1973
 
 *    above this address, where the clear depth, converted to native
1974
 
 *    surface format by software, will be stored.
1975
 
 *
1976
 
 */
1977
 
#if GFX_VER >= 12
1978
 
      if (isl_surf_usage_is_depth(info->surf.usage)) {
1979
 
         blorp_emit(batch, GENX(MI_STORE_DATA_IMM), sdi) {
1980
 
            sdi.Address = info->clear_color_addr;
1981
 
            sdi.Address.offset += 4 * 4;
1982
 
            sdi.ImmediateData = fixed_color.u32[0];
 
1939
   /* According to Wa_2201730850, in the Clear Color Programming Note under
 
1940
    * the Red channel, "Software shall write the converted Depth Clear to this
 
1941
    * dword." The only depth formats listed under the red channel are IEEE_FP
 
1942
    * and UNORM24_X8. These two requirements are incompatible with the UNORM16
 
1943
    * depth format, so just ignore that case and simply perform the conversion
 
1944
    * for all depth formats.
 
1945
    */
 
1946
   union isl_color_value fixed_color = info->clear_color;
 
1947
   if (GFX_VER == 12 && isl_surf_usage_is_depth(info->surf.usage)) {
 
1948
      isl_color_value_pack(&info->clear_color, info->surf.format,
 
1949
                           fixed_color.u32);
 
1950
   }
 
1951
 
 
1952
   for (int i = 0; i < 4; i++) {
 
1953
      blorp_emit(batch, GENX(MI_STORE_DATA_IMM), sdi) {
 
1954
         sdi.Address = info->clear_color_addr;
 
1955
         sdi.Address.offset += i * 4;
 
1956
         sdi.ImmediateData = fixed_color.u32[i];
 
1957
#if GFX_VER >= 12
 
1958
         if (i == 3)
1983
1959
            sdi.ForceWriteCompletionCheck = true;
1984
 
         }
 
1960
#endif
1985
1961
      }
1986
 
#endif
 
1962
   }
1987
1963
 
1988
 
#elif GFX_VER >= 7
 
1964
   /* The RENDER_SURFACE_STATE::ClearColor field states that software should
 
1965
    * write the converted depth value 16B after the clear address:
 
1966
    *
 
1967
    *    3D Sampler will always fetch clear depth from the location 16-bytes
 
1968
    *    above this address, where the clear depth, converted to native
 
1969
    *    surface format by software, will be stored.
 
1970
    *
 
1971
    */
 
1972
#if GFX_VER >= 12
 
1973
   if (isl_surf_usage_is_depth(info->surf.usage)) {
1989
1974
      blorp_emit(batch, GENX(MI_STORE_DATA_IMM), sdi) {
1990
1975
         sdi.Address = info->clear_color_addr;
1991
 
         sdi.ImmediateData = ISL_CHANNEL_SELECT_RED   << 25 |
1992
 
                             ISL_CHANNEL_SELECT_GREEN << 22 |
1993
 
                             ISL_CHANNEL_SELECT_BLUE  << 19 |
1994
 
                             ISL_CHANNEL_SELECT_ALPHA << 16;
1995
 
         if (isl_format_has_int_channel(info->view.format)) {
1996
 
            for (unsigned i = 0; i < 4; i++) {
1997
 
               assert(info->clear_color.u32[i] == 0 ||
1998
 
                      info->clear_color.u32[i] == 1);
1999
 
            }
2000
 
            sdi.ImmediateData |= (info->clear_color.u32[0] != 0) << 31;
2001
 
            sdi.ImmediateData |= (info->clear_color.u32[1] != 0) << 30;
2002
 
            sdi.ImmediateData |= (info->clear_color.u32[2] != 0) << 29;
2003
 
            sdi.ImmediateData |= (info->clear_color.u32[3] != 0) << 28;
2004
 
         } else {
2005
 
            for (unsigned i = 0; i < 4; i++) {
2006
 
               assert(info->clear_color.f32[i] == 0.0f ||
2007
 
                      info->clear_color.f32[i] == 1.0f);
2008
 
            }
2009
 
            sdi.ImmediateData |= (info->clear_color.f32[0] != 0.0f) << 31;
2010
 
            sdi.ImmediateData |= (info->clear_color.f32[1] != 0.0f) << 30;
2011
 
            sdi.ImmediateData |= (info->clear_color.f32[2] != 0.0f) << 29;
2012
 
            sdi.ImmediateData |= (info->clear_color.f32[3] != 0.0f) << 28;
2013
 
         }
2014
 
      }
2015
 
#endif
2016
 
   }
 
1976
         sdi.Address.offset += 4 * 4;
 
1977
         sdi.ImmediateData = fixed_color.u32[0];
 
1978
         sdi.ForceWriteCompletionCheck = true;
 
1979
      }
 
1980
   }
 
1981
#endif
 
1982
 
 
1983
#elif GFX_VER >= 7
 
1984
   blorp_emit(batch, GENX(MI_STORE_DATA_IMM), sdi) {
 
1985
      sdi.Address = info->clear_color_addr;
 
1986
      sdi.ImmediateData = ISL_CHANNEL_SELECT_RED   << 25 |
 
1987
                          ISL_CHANNEL_SELECT_GREEN << 22 |
 
1988
                          ISL_CHANNEL_SELECT_BLUE  << 19 |
 
1989
                          ISL_CHANNEL_SELECT_ALPHA << 16;
 
1990
      if (isl_format_has_int_channel(info->view.format)) {
 
1991
         for (unsigned i = 0; i < 4; i++) {
 
1992
            assert(info->clear_color.u32[i] == 0 ||
 
1993
                   info->clear_color.u32[i] == 1);
 
1994
         }
 
1995
         sdi.ImmediateData |= (info->clear_color.u32[0] != 0) << 31;
 
1996
         sdi.ImmediateData |= (info->clear_color.u32[1] != 0) << 30;
 
1997
         sdi.ImmediateData |= (info->clear_color.u32[2] != 0) << 29;
 
1998
         sdi.ImmediateData |= (info->clear_color.u32[3] != 0) << 28;
 
1999
      } else {
 
2000
         for (unsigned i = 0; i < 4; i++) {
 
2001
            assert(info->clear_color.f32[i] == 0.0f ||
 
2002
                   info->clear_color.f32[i] == 1.0f);
 
2003
         }
 
2004
         sdi.ImmediateData |= (info->clear_color.f32[0] != 0.0f) << 31;
 
2005
         sdi.ImmediateData |= (info->clear_color.f32[1] != 0.0f) << 30;
 
2006
         sdi.ImmediateData |= (info->clear_color.f32[2] != 0.0f) << 29;
 
2007
         sdi.ImmediateData |= (info->clear_color.f32[3] != 0.0f) << 28;
 
2008
      }
 
2009
   }
 
2010
#endif
2017
2011
}
2018
2012
 
2019
2013
static void
2020
2014
blorp_exec_3d(struct blorp_batch *batch, const struct blorp_params *params)
2021
2015
{
2022
2016
   if (!(batch->flags & BLORP_BATCH_NO_UPDATE_CLEAR_COLOR)) {
2023
 
      blorp_update_clear_color(batch, &params->dst, params->fast_clear_op);
2024
 
      blorp_update_clear_color(batch, &params->depth, params->hiz_op);
 
2017
      if (params->fast_clear_op == ISL_AUX_OP_FAST_CLEAR &&
 
2018
          params->dst.clear_color_addr.buffer != NULL) {
 
2019
         blorp_update_clear_color(batch, &params->dst);
 
2020
      }
 
2021
 
 
2022
      if (params->hiz_op == ISL_AUX_OP_FAST_CLEAR &&
 
2023
          params->depth.clear_color_addr.buffer != NULL) {
 
2024
         blorp_update_clear_color(batch, &params->depth);
 
2025
      }
2025
2026
   }
2026
2027
 
2027
2028
#if GFX_VER >= 8
2145
2146
#endif /* GFX_VER >= 7 */
2146
2147
 
2147
2148
#if GFX_VERx10 >= 125
2148
 
 
2149
 
   blorp_emit(batch, GENX(CFE_STATE), cfe) {
2150
 
      cfe.MaximumNumberofThreads =
2151
 
         devinfo->max_cs_threads * devinfo->subslice_total;
2152
 
   }
2153
 
 
2154
2149
   assert(cs_prog_data->push.per_thread.regs == 0);
2155
2150
   blorp_emit(batch, GENX(COMPUTE_WALKER), cw) {
2156
2151
      cw.SIMDSize                       = dispatch.simd_size / 16;
2258
2253
      .SharedLocalMemorySize = encode_slm_size(GFX_VER,
2259
2254
                                               prog_data->total_shared),
2260
2255
      .BarrierEnable = cs_prog_data->uses_barrier,
2261
 
#if GFX_VER >= 8 || GEN_IS_HASWELL
 
2256
#if GFX_VER >= 8 || GFX_VERx10 == 75
2262
2257
      .CrossThreadConstantDataReadLength =
2263
2258
         cs_prog_data->push.cross_thread.regs,
2264
2259
#endif
2376
2371
{
2377
2372
   switch (info->aux_usage) {
2378
2373
   case ISL_AUX_USAGE_CCS_E:
2379
 
   case ISL_AUX_USAGE_GFX12_CCS_E:
 
2374
   case ISL_AUX_USAGE_FCV_CCS_E:
2380
2375
      return XY_CCS_E;
2381
2376
   case ISL_AUX_USAGE_NONE:
2382
2377
      return XY_NONE;