radv: expose integrated device type for APUs.
[mesa.git] / src / amd / vulkan / radv_device.c
index 59ce2d02a55c374f5168f3198ce9751f5849eb5a..887916f558f27a11e6c68af153717874b02e2073 100644 (file)
@@ -304,6 +304,12 @@ radv_physical_device_init(struct radv_physical_device *device,
 
        radv_get_device_uuid(drm_device, device->device_uuid);
 
+       if (device->rad_info.family == CHIP_STONEY ||
+           device->rad_info.chip_class >= GFX9) {
+               device->has_rbplus = true;
+               device->rbplus_allowed = device->rad_info.family == CHIP_STONEY;
+       }
+
        return VK_SUCCESS;
 
 fail:
@@ -508,8 +514,8 @@ void radv_GetPhysicalDeviceFeatures(
        VkPhysicalDevice                            physicalDevice,
        VkPhysicalDeviceFeatures*                   pFeatures)
 {
-       //   RADV_FROM_HANDLE(radv_physical_device, pdevice, physicalDevice);
-
+       RADV_FROM_HANDLE(radv_physical_device, pdevice, physicalDevice);
+       bool is_gfx9 = pdevice->rad_info.chip_class >= GFX9;
        memset(pFeatures, 0, sizeof(*pFeatures));
 
        *pFeatures = (VkPhysicalDeviceFeatures) {
@@ -517,8 +523,8 @@ void radv_GetPhysicalDeviceFeatures(
                .fullDrawIndexUint32                      = true,
                .imageCubeArray                           = true,
                .independentBlend                         = true,
-               .geometryShader                           = true,
-               .tessellationShader                       = true,
+               .geometryShader                           = !is_gfx9,
+               .tessellationShader                       = !is_gfx9,
                .sampleRateShading                        = false,
                .dualSrcBlend                             = true,
                .logicOp                                  = true,
@@ -728,7 +734,7 @@ void radv_GetPhysicalDeviceProperties(
                .driverVersion = radv_get_driver_version(),
                .vendorID = 0x1002,
                .deviceID = pdevice->rad_info.pci_id,
-               .deviceType = VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU,
+               .deviceType = pdevice->rad_info.has_dedicated_vram ? VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU : VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU,
                .limits = limits,
                .sparseProperties = {0},
        };
@@ -1103,6 +1109,7 @@ VkResult radv_CreateDevice(
                case RADV_QUEUE_COMPUTE:
                        si_cs_emit_cache_flush(device->flush_cs[family],
                                               device->physical_device->rad_info.chip_class,
+                                              NULL, 0,
                                               family == RADV_QUEUE_COMPUTE && device->physical_device->rad_info.chip_class >= CIK,
                                               RADV_CMD_FLAG_INV_ICACHE |
                                               RADV_CMD_FLAG_INV_SMEM_L1 |
@@ -1118,6 +1125,7 @@ VkResult radv_CreateDevice(
                case RADV_QUEUE_COMPUTE:
                        si_cs_emit_cache_flush(device->flush_shader_cs[family],
                                               device->physical_device->rad_info.chip_class,
+                                              NULL, 0,
                                               family == RADV_QUEUE_COMPUTE && device->physical_device->rad_info.chip_class >= CIK,
                                               family == RADV_QUEUE_COMPUTE ? RADV_CMD_FLAG_CS_PARTIAL_FLUSH : (RADV_CMD_FLAG_CS_PARTIAL_FLUSH | RADV_CMD_FLAG_PS_PARTIAL_FLUSH) |
                                               RADV_CMD_FLAG_INV_ICACHE |
@@ -1720,6 +1728,10 @@ radv_get_preamble_cs(struct radv_queue *queue,
                                                       S_030938_SIZE(tess_factor_ring_size / 4));
                                radeon_set_uconfig_reg(cs, R_030940_VGT_TF_MEMORY_BASE,
                                                       tf_va >> 8);
+                               if (queue->device->physical_device->rad_info.chip_class >= GFX9) {
+                                       radeon_set_uconfig_reg(cs, R_030944_VGT_TF_MEMORY_BASE_HI,
+                                                              tf_va >> 40);
+                               }
                                radeon_set_uconfig_reg(cs, R_03093C_VGT_HS_OFFCHIP_PARAM, hs_offchip_param);
                        } else {
                                radeon_set_config_reg(cs, R_008988_VGT_TF_RING_SIZE,
@@ -1763,6 +1775,7 @@ radv_get_preamble_cs(struct radv_queue *queue,
                if (!i) {
                        si_cs_emit_cache_flush(cs,
                                               queue->device->physical_device->rad_info.chip_class,
+                                              NULL, 0,
                                               queue->queue_family_index == RING_COMPUTE &&
                                                 queue->device->physical_device->rad_info.chip_class >= CIK,
                                               RADV_CMD_FLAG_INV_ICACHE |
@@ -2703,7 +2716,20 @@ radv_initialise_color_surface(struct radv_device *device,
 
        va = device->ws->buffer_get_va(iview->bo) + iview->image->offset;
 
-       {
+       if (device->physical_device->rad_info.chip_class >= GFX9) {
+               struct gfx9_surf_meta_flags meta;
+               if (iview->image->dcc_offset)
+                       meta = iview->image->surface.u.gfx9.dcc;
+               else
+                       meta = iview->image->surface.u.gfx9.cmask;
+
+               cb->cb_color_attrib |= S_028C74_COLOR_SW_MODE(iview->image->surface.u.gfx9.surf.swizzle_mode) |
+                       S_028C74_FMASK_SW_MODE(iview->image->surface.u.gfx9.fmask.swizzle_mode) |
+                       S_028C74_RB_ALIGNED(meta.rb_aligned) |
+                       S_028C74_PIPE_ALIGNED(meta.pipe_aligned);
+
+               va += iview->image->surface.u.gfx9.surf_offset >> 8;
+       } else {
                const struct legacy_surf_level *level_info = &surf->u.legacy.level[iview->base_mip];
                unsigned pitch_tile_max, slice_tile_max, tile_mode_index;
 
@@ -2835,6 +2861,21 @@ radv_initialise_color_surface(struct radv_device *device,
                unsigned bankh = util_logbase2(iview->image->surface.u.legacy.bankh);
                cb->cb_color_attrib |= S_028C74_FMASK_BANK_HEIGHT(bankh);
        }
+
+       if (device->physical_device->rad_info.chip_class >= GFX9) {
+               uint32_t max_slice = radv_surface_layer_count(iview);
+               unsigned mip0_depth = iview->base_layer + max_slice - 1;
+
+               cb->cb_color_view |= S_028C6C_MIP_LEVEL(iview->base_mip);
+               cb->cb_color_attrib |= S_028C74_MIP0_DEPTH(mip0_depth) |
+                       S_028C74_RESOURCE_TYPE(iview->image->surface.u.gfx9.resource_type);
+               cb->cb_color_attrib2 = S_028C68_MIP0_WIDTH(iview->image->info.width - 1) |
+                       S_028C68_MIP0_HEIGHT(iview->image->info.height - 1) |
+                       S_028C68_MAX_MIP(iview->image->info.levels);
+
+               cb->gfx9_epitch = S_0287A0_EPITCH(iview->image->surface.u.gfx9.surf.epitch);
+
+       }
 }
 
 static void
@@ -2885,7 +2926,39 @@ radv_initialise_ds_surface(struct radv_device *device,
        va = device->ws->buffer_get_va(iview->bo) + iview->image->offset;
        s_offs = z_offs = va;
 
-       {
+       if (device->physical_device->rad_info.chip_class >= GFX9) {
+               assert(iview->image->surface.u.gfx9.surf_offset == 0);
+               s_offs += iview->image->surface.u.gfx9.stencil_offset;
+
+               ds->db_z_info = S_028038_FORMAT(format) |
+                       S_028038_NUM_SAMPLES(util_logbase2(iview->image->info.samples)) |
+                       S_028038_SW_MODE(iview->image->surface.u.gfx9.surf.swizzle_mode) |
+                       S_028038_MAXMIP(iview->image->info.levels - 1);
+               ds->db_stencil_info = S_02803C_FORMAT(stencil_format) |
+                       S_02803C_SW_MODE(iview->image->surface.u.gfx9.stencil.swizzle_mode);
+
+               ds->db_z_info2 = S_028068_EPITCH(iview->image->surface.u.gfx9.surf.epitch);
+               ds->db_stencil_info2 = S_02806C_EPITCH(iview->image->surface.u.gfx9.stencil.epitch);
+               ds->db_depth_view |= S_028008_MIPID(level);
+
+               ds->db_depth_size = S_02801C_X_MAX(iview->image->info.width - 1) |
+                       S_02801C_Y_MAX(iview->image->info.height - 1);
+
+               /* Only use HTILE for the first level. */
+               if (iview->image->surface.htile_size && !level) {
+                       ds->db_z_info |= S_028038_TILE_SURFACE_ENABLE(1);
+
+                       if (!(iview->image->surface.flags & RADEON_SURF_SBUFFER))
+                               /* Use all of the htile_buffer for depth if there's no stencil. */
+                               ds->db_stencil_info |= S_02803C_TILE_STENCIL_DISABLE(1);
+                       va = device->ws->buffer_get_va(iview->bo) + iview->image->offset +
+                               iview->image->htile_offset;
+                       ds->db_htile_data_base = va >> 8;
+                       ds->db_htile_surface = S_028ABC_FULL_CACHE(1) |
+                               S_028ABC_PIPE_ALIGNED(iview->image->surface.u.gfx9.htile.pipe_aligned) |
+                               S_028ABC_RB_ALIGNED(iview->image->surface.u.gfx9.htile.rb_aligned);
+               }
+       } else {
                const struct legacy_surf_level *level_info = &iview->image->surface.u.legacy.level[level];
 
                if (stencil_only)