diff --git a/dlls/winevulkan/vulkan.c b/dlls/winevulkan/vulkan.c index 03f0ad9d89b..9fb10431a75 100644 --- a/dlls/winevulkan/vulkan.c +++ b/dlls/winevulkan/vulkan.c @@ -963,6 +963,8 @@ VkResult WINAPI __wine_create_vk_device_with_callback(VkPhysicalDevice phys_dev, VkResult (WINAPI *native_vkCreateDevice)(VkPhysicalDevice, const VkDeviceCreateInfo *, const VkAllocationCallbacks *, VkDevice *, void * (*)(VkInstance, const char *), void *), void *native_vkCreateDevice_context) { + VkPhysicalDeviceFeatures features = {0}; + VkPhysicalDeviceFeatures2 *features2; VkDeviceCreateInfo create_info_host; struct VkQueue_T *next_queue; struct VkDevice_T *object; @@ -996,6 +998,25 @@ VkResult WINAPI __wine_create_vk_device_with_callback(VkPhysicalDevice phys_dev, if (res != VK_SUCCESS) goto fail; + /* Enable shaderStorageImageWriteWithoutFormat for fshack + * This is available on all hardware and driver combinations we care about. + */ + if (create_info_host.pEnabledFeatures) + { + features = *create_info_host.pEnabledFeatures; + features.shaderStorageImageWriteWithoutFormat = VK_TRUE; + create_info_host.pEnabledFeatures = &features; + } + if ((features2 = wine_vk_find_struct(&create_info_host, PHYSICAL_DEVICE_FEATURES_2))) + { + features2->features.shaderStorageImageWriteWithoutFormat = VK_TRUE; + } + else if (!create_info_host.pEnabledFeatures) + { + features.shaderStorageImageWriteWithoutFormat = VK_TRUE; + create_info_host.pEnabledFeatures = &features; + } + if (native_vkCreateDevice) res = native_vkCreateDevice(phys_dev->phys_dev, &create_info_host, NULL /* allocator */, &object->device, @@ -2035,60 +2056,79 @@ void WINAPI wine_vkGetPrivateDataEXT(VkDevice device, VkObjectType object_type, } /* -#version 450 +#version 460 + +layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in; layout(binding = 0) uniform sampler2D texSampler; -layout(binding = 1, rgba8) uniform writeonly image2D outImage; +layout(binding = 1) uniform writeonly image2D outImage; layout(push_constant) uniform pushConstants { //both in real image coords vec2 offset; vec2 extents; } constants; -layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in; - void main() { vec2 texcoord = (vec2(gl_GlobalInvocationID.xy) - constants.offset) / constants.extents; vec4 c = texture(texSampler, texcoord); - imageStore(outImage, ivec2(gl_GlobalInvocationID.xy), c.bgra); + + // Convert linear -> srgb + bvec3 isLo = lessThanEqual(c.rgb, vec3(0.0031308f)); + vec3 loPart = c.rgb * 12.92f; + vec3 hiPart = pow(c.rgb, vec3(5.0f / 12.0f)) * 1.055f - 0.055f; + c.rgb = mix(hiPart, loPart, isLo); + + imageStore(outImage, ivec2(gl_GlobalInvocationID.xy), c); } + */ const uint32_t blit_comp_spv[] = { - 0x07230203,0x00010000,0x00080006,0x00000037,0x00000000,0x00020011,0x00000001,0x0006000b, - 0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001, - 0x0006000f,0x00000005,0x00000004,0x6e69616d,0x00000000,0x0000000d,0x00060010,0x00000004, - 0x00000011,0x00000008,0x00000008,0x00000001,0x00030003,0x00000002,0x000001c2,0x00040005, - 0x00000004,0x6e69616d,0x00000000,0x00050005,0x00000009,0x63786574,0x64726f6f,0x00000000, - 0x00080005,0x0000000d,0x475f6c67,0x61626f6c,0x766e496c,0x7461636f,0x496e6f69,0x00000044, - 0x00060005,0x00000012,0x68737570,0x736e6f43,0x746e6174,0x00000073,0x00050006,0x00000012, - 0x00000000,0x7366666f,0x00007465,0x00050006,0x00000012,0x00000001,0x65747865,0x0073746e, - 0x00050005,0x00000014,0x736e6f63,0x746e6174,0x00000073,0x00030005,0x00000021,0x00000063, - 0x00050005,0x00000025,0x53786574,0x6c706d61,0x00007265,0x00050005,0x0000002c,0x4974756f, - 0x6567616d,0x00000000,0x00040047,0x0000000d,0x0000000b,0x0000001c,0x00050048,0x00000012, - 0x00000000,0x00000023,0x00000000,0x00050048,0x00000012,0x00000001,0x00000023,0x00000008, - 0x00030047,0x00000012,0x00000002,0x00040047,0x00000025,0x00000022,0x00000000,0x00040047, - 0x00000025,0x00000021,0x00000000,0x00040047,0x0000002c,0x00000022,0x00000000,0x00040047, - 0x0000002c,0x00000021,0x00000001,0x00030047,0x0000002c,0x00000019,0x00040047,0x00000036, - 0x0000000b,0x00000019,0x00020013,0x00000002,0x00030021,0x00000003,0x00000002,0x00030016, - 0x00000006,0x00000020,0x00040017,0x00000007,0x00000006,0x00000002,0x00040020,0x00000008, - 0x00000007,0x00000007,0x00040015,0x0000000a,0x00000020,0x00000000,0x00040017,0x0000000b, - 0x0000000a,0x00000003,0x00040020,0x0000000c,0x00000001,0x0000000b,0x0004003b,0x0000000c, - 0x0000000d,0x00000001,0x00040017,0x0000000e,0x0000000a,0x00000002,0x0004001e,0x00000012, - 0x00000007,0x00000007,0x00040020,0x00000013,0x00000009,0x00000012,0x0004003b,0x00000013, - 0x00000014,0x00000009,0x00040015,0x00000015,0x00000020,0x00000001,0x0004002b,0x00000015, - 0x00000016,0x00000000,0x00040020,0x00000017,0x00000009,0x00000007,0x0004002b,0x00000015, - 0x0000001b,0x00000001,0x00040017,0x0000001f,0x00000006,0x00000004,0x00040020,0x00000020, - 0x00000007,0x0000001f,0x00090019,0x00000022,0x00000006,0x00000001,0x00000000,0x00000000, - 0x00000000,0x00000001,0x00000000,0x0003001b,0x00000023,0x00000022,0x00040020,0x00000024, - 0x00000000,0x00000023,0x0004003b,0x00000024,0x00000025,0x00000000,0x0004002b,0x00000006, - 0x00000028,0x00000000,0x00090019,0x0000002a,0x00000006,0x00000001,0x00000000,0x00000000, - 0x00000000,0x00000002,0x00000004,0x00040020,0x0000002b,0x00000000,0x0000002a,0x0004003b, - 0x0000002b,0x0000002c,0x00000000,0x00040017,0x00000030,0x00000015,0x00000002,0x0004002b, - 0x0000000a,0x00000034,0x00000008,0x0004002b,0x0000000a,0x00000035,0x00000001,0x0006002c, - 0x0000000b,0x00000036,0x00000034,0x00000034,0x00000035,0x00050036,0x00000002,0x00000004, - 0x00000000,0x00000003,0x000200f8,0x00000005,0x0004003b,0x00000008,0x00000009,0x00000007, - 0x0004003b,0x00000020,0x00000021,0x00000007,0x0004003d,0x0000000b,0x0000000f,0x0000000d, + 0x07230203,0x00010000,0x0008000a,0x0000005e,0x00000000,0x00020011,0x00000001,0x00020011, + 0x00000038,0x0006000b,0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e, + 0x00000000,0x00000001,0x0006000f,0x00000005,0x00000004,0x6e69616d,0x00000000,0x0000000d, + 0x00060010,0x00000004,0x00000011,0x00000008,0x00000008,0x00000001,0x00030003,0x00000002, + 0x000001cc,0x00040005,0x00000004,0x6e69616d,0x00000000,0x00050005,0x00000009,0x63786574, + 0x64726f6f,0x00000000,0x00080005,0x0000000d,0x475f6c67,0x61626f6c,0x766e496c,0x7461636f, + 0x496e6f69,0x00000044,0x00060005,0x00000012,0x68737570,0x736e6f43,0x746e6174,0x00000073, + 0x00050006,0x00000012,0x00000000,0x7366666f,0x00007465,0x00050006,0x00000012,0x00000001, + 0x65747865,0x0073746e,0x00050005,0x00000014,0x736e6f63,0x746e6174,0x00000073,0x00030005, + 0x00000021,0x00000063,0x00050005,0x00000025,0x53786574,0x6c706d61,0x00007265,0x00040005, + 0x0000002d,0x6f4c7369,0x00000000,0x00040005,0x00000035,0x61506f6c,0x00007472,0x00040005, + 0x0000003a,0x61506968,0x00007472,0x00050005,0x00000055,0x4974756f,0x6567616d,0x00000000, + 0x00040047,0x0000000d,0x0000000b,0x0000001c,0x00050048,0x00000012,0x00000000,0x00000023, + 0x00000000,0x00050048,0x00000012,0x00000001,0x00000023,0x00000008,0x00030047,0x00000012, + 0x00000002,0x00040047,0x00000025,0x00000022,0x00000000,0x00040047,0x00000025,0x00000021, + 0x00000000,0x00040047,0x00000055,0x00000022,0x00000000,0x00040047,0x00000055,0x00000021, + 0x00000001,0x00030047,0x00000055,0x00000019,0x00040047,0x0000005d,0x0000000b,0x00000019, + 0x00020013,0x00000002,0x00030021,0x00000003,0x00000002,0x00030016,0x00000006,0x00000020, + 0x00040017,0x00000007,0x00000006,0x00000002,0x00040020,0x00000008,0x00000007,0x00000007, + 0x00040015,0x0000000a,0x00000020,0x00000000,0x00040017,0x0000000b,0x0000000a,0x00000003, + 0x00040020,0x0000000c,0x00000001,0x0000000b,0x0004003b,0x0000000c,0x0000000d,0x00000001, + 0x00040017,0x0000000e,0x0000000a,0x00000002,0x0004001e,0x00000012,0x00000007,0x00000007, + 0x00040020,0x00000013,0x00000009,0x00000012,0x0004003b,0x00000013,0x00000014,0x00000009, + 0x00040015,0x00000015,0x00000020,0x00000001,0x0004002b,0x00000015,0x00000016,0x00000000, + 0x00040020,0x00000017,0x00000009,0x00000007,0x0004002b,0x00000015,0x0000001b,0x00000001, + 0x00040017,0x0000001f,0x00000006,0x00000004,0x00040020,0x00000020,0x00000007,0x0000001f, + 0x00090019,0x00000022,0x00000006,0x00000001,0x00000000,0x00000000,0x00000000,0x00000001, + 0x00000000,0x0003001b,0x00000023,0x00000022,0x00040020,0x00000024,0x00000000,0x00000023, + 0x0004003b,0x00000024,0x00000025,0x00000000,0x0004002b,0x00000006,0x00000028,0x00000000, + 0x00020014,0x0000002a,0x00040017,0x0000002b,0x0000002a,0x00000003,0x00040020,0x0000002c, + 0x00000007,0x0000002b,0x00040017,0x0000002e,0x00000006,0x00000003,0x0004002b,0x00000006, + 0x00000031,0x3b4d2e1c,0x0006002c,0x0000002e,0x00000032,0x00000031,0x00000031,0x00000031, + 0x00040020,0x00000034,0x00000007,0x0000002e,0x0004002b,0x00000006,0x00000038,0x414eb852, + 0x0004002b,0x00000006,0x0000003d,0x3ed55555,0x0006002c,0x0000002e,0x0000003e,0x0000003d, + 0x0000003d,0x0000003d,0x0004002b,0x00000006,0x00000040,0x3f870a3d,0x0004002b,0x00000006, + 0x00000042,0x3d6147ae,0x0004002b,0x0000000a,0x00000049,0x00000000,0x00040020,0x0000004a, + 0x00000007,0x00000006,0x0004002b,0x0000000a,0x0000004d,0x00000001,0x0004002b,0x0000000a, + 0x00000050,0x00000002,0x00090019,0x00000053,0x00000006,0x00000001,0x00000000,0x00000000, + 0x00000000,0x00000002,0x00000000,0x00040020,0x00000054,0x00000000,0x00000053,0x0004003b, + 0x00000054,0x00000055,0x00000000,0x00040017,0x00000059,0x00000015,0x00000002,0x0004002b, + 0x0000000a,0x0000005c,0x00000008,0x0006002c,0x0000000b,0x0000005d,0x0000005c,0x0000005c, + 0x0000004d,0x00050036,0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8,0x00000005, + 0x0004003b,0x00000008,0x00000009,0x00000007,0x0004003b,0x00000020,0x00000021,0x00000007, + 0x0004003b,0x0000002c,0x0000002d,0x00000007,0x0004003b,0x00000034,0x00000035,0x00000007, + 0x0004003b,0x00000034,0x0000003a,0x00000007,0x0004003d,0x0000000b,0x0000000f,0x0000000d, 0x0007004f,0x0000000e,0x00000010,0x0000000f,0x0000000f,0x00000000,0x00000001,0x00040070, 0x00000007,0x00000011,0x00000010,0x00050041,0x00000017,0x00000018,0x00000014,0x00000016, 0x0004003d,0x00000007,0x00000019,0x00000018,0x00050083,0x00000007,0x0000001a,0x00000011, @@ -2096,12 +2136,27 @@ const uint32_t blit_comp_spv[] = { 0x0000001d,0x0000001c,0x00050088,0x00000007,0x0000001e,0x0000001a,0x0000001d,0x0003003e, 0x00000009,0x0000001e,0x0004003d,0x00000023,0x00000026,0x00000025,0x0004003d,0x00000007, 0x00000027,0x00000009,0x00070058,0x0000001f,0x00000029,0x00000026,0x00000027,0x00000002, - 0x00000028,0x0003003e,0x00000021,0x00000029,0x0004003d,0x0000002a,0x0000002d,0x0000002c, - 0x0004003d,0x0000000b,0x0000002e,0x0000000d,0x0007004f,0x0000000e,0x0000002f,0x0000002e, - 0x0000002e,0x00000000,0x00000001,0x0004007c,0x00000030,0x00000031,0x0000002f,0x0004003d, - 0x0000001f,0x00000032,0x00000021,0x0009004f,0x0000001f,0x00000033,0x00000032,0x00000032, - 0x00000002,0x00000001,0x00000000,0x00000003,0x00040063,0x0000002d,0x00000031,0x00000033, - 0x000100fd,0x00010038 + 0x00000028,0x0003003e,0x00000021,0x00000029,0x0004003d,0x0000001f,0x0000002f,0x00000021, + 0x0008004f,0x0000002e,0x00000030,0x0000002f,0x0000002f,0x00000000,0x00000001,0x00000002, + 0x000500bc,0x0000002b,0x00000033,0x00000030,0x00000032,0x0003003e,0x0000002d,0x00000033, + 0x0004003d,0x0000001f,0x00000036,0x00000021,0x0008004f,0x0000002e,0x00000037,0x00000036, + 0x00000036,0x00000000,0x00000001,0x00000002,0x0005008e,0x0000002e,0x00000039,0x00000037, + 0x00000038,0x0003003e,0x00000035,0x00000039,0x0004003d,0x0000001f,0x0000003b,0x00000021, + 0x0008004f,0x0000002e,0x0000003c,0x0000003b,0x0000003b,0x00000000,0x00000001,0x00000002, + 0x0007000c,0x0000002e,0x0000003f,0x00000001,0x0000001a,0x0000003c,0x0000003e,0x0005008e, + 0x0000002e,0x00000041,0x0000003f,0x00000040,0x00060050,0x0000002e,0x00000043,0x00000042, + 0x00000042,0x00000042,0x00050083,0x0000002e,0x00000044,0x00000041,0x00000043,0x0003003e, + 0x0000003a,0x00000044,0x0004003d,0x0000002e,0x00000045,0x0000003a,0x0004003d,0x0000002e, + 0x00000046,0x00000035,0x0004003d,0x0000002b,0x00000047,0x0000002d,0x000600a9,0x0000002e, + 0x00000048,0x00000047,0x00000046,0x00000045,0x00050041,0x0000004a,0x0000004b,0x00000021, + 0x00000049,0x00050051,0x00000006,0x0000004c,0x00000048,0x00000000,0x0003003e,0x0000004b, + 0x0000004c,0x00050041,0x0000004a,0x0000004e,0x00000021,0x0000004d,0x00050051,0x00000006, + 0x0000004f,0x00000048,0x00000001,0x0003003e,0x0000004e,0x0000004f,0x00050041,0x0000004a, + 0x00000051,0x00000021,0x00000050,0x00050051,0x00000006,0x00000052,0x00000048,0x00000002, + 0x0003003e,0x00000051,0x00000052,0x0004003d,0x00000053,0x00000056,0x00000055,0x0004003d, + 0x0000000b,0x00000057,0x0000000d,0x0007004f,0x0000000e,0x00000058,0x00000057,0x00000057, + 0x00000000,0x00000001,0x0004007c,0x00000059,0x0000005a,0x00000058,0x0004003d,0x0000001f, + 0x0000005b,0x00000021,0x00040063,0x00000056,0x0000005a,0x0000005b,0x000100fd,0x00010038 }; static VkResult create_pipeline(VkDevice device, struct VkSwapchainKHR_T *swapchain, VkShaderModule shaderModule) @@ -2195,20 +2250,12 @@ static VkResult init_blit_images(VkDevice device, struct VkSwapchainKHR_T *swapc VkPushConstantRange pushConstants; VkShaderModuleCreateInfo shaderInfo = {0}; VkShaderModule shaderModule = 0; - VkDeviceSize blitMemTotal = 0, offs; - VkImageCreateInfo imageInfo = {0}; #if defined(USE_STRUCT_CONVERSION) - VkMemoryRequirements_host blitMemReq; - VkMemoryAllocateInfo_host allocInfo = {0}; - VkPhysicalDeviceMemoryProperties_host memProperties; VkImageViewCreateInfo_host viewInfo = {0}; #else - VkMemoryRequirements blitMemReq; - VkMemoryAllocateInfo allocInfo = {0}; - VkPhysicalDeviceMemoryProperties memProperties; VkImageViewCreateInfo viewInfo = {0}; #endif - uint32_t blit_memory_type = -1, i; + uint32_t i; samplerInfo.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; samplerInfo.magFilter = swapchain->fs_hack_filter; @@ -2218,7 +2265,7 @@ static VkResult init_blit_images(VkDevice device, struct VkSwapchainKHR_T *swapc samplerInfo.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER; samplerInfo.anisotropyEnable = VK_FALSE; samplerInfo.maxAnisotropy = 1; - samplerInfo.borderColor = VK_BORDER_COLOR_INT_OPAQUE_BLACK; + samplerInfo.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_BLACK; samplerInfo.unnormalizedCoordinates = VK_FALSE; samplerInfo.compareEnable = VK_FALSE; samplerInfo.compareOp = VK_COMPARE_OP_ALWAYS; @@ -2304,98 +2351,14 @@ static VkResult init_blit_images(VkDevice device, struct VkSwapchainKHR_T *swapc device->funcs.p_vkDestroyShaderModule(device->device, shaderModule, NULL); - if(!(swapchain->surface_usage & VK_IMAGE_USAGE_STORAGE_BIT)){ - TRACE("using intermediate blit images\n"); - /* create intermediate blit images */ - for(i = 0; i < swapchain->n_images; ++i){ - struct fs_hack_image *hack = &swapchain->fs_hack_images[i]; - - imageInfo.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; - imageInfo.imageType = VK_IMAGE_TYPE_2D; - imageInfo.extent.width = swapchain->real_extent.width; - imageInfo.extent.height = swapchain->real_extent.height; - imageInfo.extent.depth = 1; - imageInfo.mipLevels = 1; - imageInfo.arrayLayers = 1; - imageInfo.format = VK_FORMAT_R8G8B8A8_UNORM; - imageInfo.tiling = VK_IMAGE_TILING_OPTIMAL; - imageInfo.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; - imageInfo.usage = VK_IMAGE_USAGE_STORAGE_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT; - imageInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE; - imageInfo.samples = VK_SAMPLE_COUNT_1_BIT; - res = device->funcs.p_vkCreateImage(device->device, &imageInfo, NULL, &hack->blit_image); - if(res != VK_SUCCESS){ - ERR("vkCreateImage failed: %d\n", res); - goto fail; - } - - device->funcs.p_vkGetImageMemoryRequirements(device->device, hack->blit_image, &blitMemReq); - - offs = blitMemTotal % blitMemReq.alignment; - if(offs) - blitMemTotal += blitMemReq.alignment - offs; - - blitMemTotal += blitMemReq.size; - } - - /* allocate backing memory */ - device->phys_dev->instance->funcs.p_vkGetPhysicalDeviceMemoryProperties(device->phys_dev->phys_dev, &memProperties); - - for(i = 0; i < memProperties.memoryTypeCount; i++){ - if((memProperties.memoryTypes[i].propertyFlags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT) == VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT){ - if(blitMemReq.memoryTypeBits & (1 << i)){ - blit_memory_type = i; - break; - } - } - } - - if(blit_memory_type == -1){ - ERR("unable to find suitable memory type\n"); - res = VK_ERROR_OUT_OF_HOST_MEMORY; - goto fail; - } - - allocInfo.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; - allocInfo.allocationSize = blitMemTotal; - allocInfo.memoryTypeIndex = blit_memory_type; - - res = device->funcs.p_vkAllocateMemory(device->device, &allocInfo, NULL, &swapchain->blit_image_memory); - if(res != VK_SUCCESS){ - ERR("vkAllocateMemory: %d\n", res); - goto fail; - } - - /* bind backing memory and create imageviews */ - blitMemTotal = 0; - for(i = 0; i < swapchain->n_images; ++i){ - struct fs_hack_image *hack = &swapchain->fs_hack_images[i]; - - device->funcs.p_vkGetImageMemoryRequirements(device->device, hack->blit_image, &blitMemReq); - - offs = blitMemTotal % blitMemReq.alignment; - if(offs) - blitMemTotal += blitMemReq.alignment - offs; - - res = device->funcs.p_vkBindImageMemory(device->device, hack->blit_image, swapchain->blit_image_memory, blitMemTotal); - if(res != VK_SUCCESS){ - ERR("vkBindImageMemory: %d\n", res); - goto fail; - } - - blitMemTotal += blitMemReq.size; - } - }else - TRACE("blitting directly to swapchain images\n"); - /* create imageviews */ for(i = 0; i < swapchain->n_images; ++i){ struct fs_hack_image *hack = &swapchain->fs_hack_images[i]; viewInfo.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; - viewInfo.image = hack->blit_image ? hack->blit_image : hack->swapchain_image; + viewInfo.image = hack->swapchain_image; viewInfo.viewType = VK_IMAGE_VIEW_TYPE_2D; - viewInfo.format = VK_FORMAT_R8G8B8A8_UNORM; + viewInfo.format = VK_FORMAT_B8G8R8A8_UNORM; viewInfo.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; viewInfo.subresourceRange.baseMipLevel = 0; viewInfo.subresourceRange.levelCount = 1; @@ -2421,9 +2384,6 @@ static VkResult init_blit_images(VkDevice device, struct VkSwapchainKHR_T *swapc device->funcs.p_vkDestroyImageView(device->device, hack->blit_view, NULL); hack->blit_view = VK_NULL_HANDLE; - - device->funcs.p_vkDestroyImage(device->device, hack->blit_image, NULL); - hack->blit_image = VK_NULL_HANDLE; } device->funcs.p_vkDestroyShaderModule(device->device, shaderModule, NULL); @@ -2440,9 +2400,6 @@ static VkResult init_blit_images(VkDevice device, struct VkSwapchainKHR_T *swapc device->funcs.p_vkDestroyDescriptorPool(device->device, swapchain->descriptor_pool, NULL); swapchain->descriptor_pool = VK_NULL_HANDLE; - device->funcs.p_vkFreeMemory(device->device, swapchain->blit_image_memory, NULL); - swapchain->blit_image_memory = VK_NULL_HANDLE; - device->funcs.p_vkDestroySampler(device->device, swapchain->sampler, NULL); swapchain->sampler = VK_NULL_HANDLE; @@ -2454,7 +2411,6 @@ static void destroy_fs_hack_image(VkDevice device, struct VkSwapchainKHR_T *swap device->funcs.p_vkDestroyImageView(device->device, hack->user_view, NULL); device->funcs.p_vkDestroyImageView(device->device, hack->blit_view, NULL); device->funcs.p_vkDestroyImage(device->device, hack->user_image, NULL); - device->funcs.p_vkDestroyImage(device->device, hack->blit_image, NULL); if(hack->cmd) device->funcs.p_vkFreeCommandBuffers(device->device, swapchain->cmd_pools[hack->cmd_queue_idx], @@ -2462,11 +2418,8 @@ static void destroy_fs_hack_image(VkDevice device, struct VkSwapchainKHR_T *swap device->funcs.p_vkDestroySemaphore(device->device, hack->blit_finished, NULL); } -#if defined(USE_STRUCT_CONVERSION) -static VkResult init_fs_hack_images(VkDevice device, struct VkSwapchainKHR_T *swapchain, VkSwapchainCreateInfoKHR_host *createinfo) -#else -static VkResult init_fs_hack_images(VkDevice device, struct VkSwapchainKHR_T *swapchain, VkSwapchainCreateInfoKHR *createinfo) -#endif + +static VkResult init_fs_hack_images(VkDevice device, struct VkSwapchainKHR_T *swapchain, const VkSwapchainCreateInfoKHR *createinfo) { VkResult res; VkImage *real_images = NULL; @@ -2530,11 +2483,17 @@ static VkResult init_fs_hack_images(VkDevice device, struct VkSwapchainKHR_T *sw imageInfo.format = createinfo->imageFormat; imageInfo.tiling = VK_IMAGE_TILING_OPTIMAL; imageInfo.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; - imageInfo.usage = createinfo->imageUsage | VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT; + imageInfo.usage = createinfo->imageUsage | VK_IMAGE_USAGE_SAMPLED_BIT; imageInfo.sharingMode = createinfo->imageSharingMode; imageInfo.samples = VK_SAMPLE_COUNT_1_BIT; imageInfo.queueFamilyIndexCount = createinfo->queueFamilyIndexCount; imageInfo.pQueueFamilyIndices = createinfo->pQueueFamilyIndices; + + if (createinfo-> flags & VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR) + imageInfo.flags |= VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT | VK_IMAGE_CREATE_EXTENDED_USAGE_BIT; + else if (createinfo->imageFormat != VK_FORMAT_B8G8R8A8_SRGB) + imageInfo.flags |= VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT; + res = device->funcs.p_vkCreateImage(device->device, &imageInfo, NULL, &hack->user_image); if(res != VK_SUCCESS){ ERR("vkCreateImage failed: %d\n", res); @@ -2600,7 +2559,7 @@ static VkResult init_fs_hack_images(VkDevice device, struct VkSwapchainKHR_T *sw viewInfo.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; viewInfo.image = swapchain->fs_hack_images[i].user_image; viewInfo.viewType = VK_IMAGE_VIEW_TYPE_2D; - viewInfo.format = createinfo->imageFormat; + viewInfo.format = VK_FORMAT_B8G8R8A8_SRGB; viewInfo.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; viewInfo.subresourceRange.baseMipLevel = 0; viewInfo.subresourceRange.levelCount = 1; @@ -2706,14 +2665,15 @@ NTSTATUS wine_vkCreateSwapchainKHR(void *args) return result; } - object->surface_usage = caps.supportedUsageFlags; - TRACE("surface usage flags: 0x%x\n", object->surface_usage); + if (!(caps.supportedUsageFlags & VK_IMAGE_USAGE_STORAGE_BIT)) + FIXME("Swapchain does not support required VK_IMAGE_USAGE_STORAGE_BIT\n"); native_info.imageExtent = object->real_extent; - native_info.imageUsage |= VK_IMAGE_USAGE_TRANSFER_DST_BIT; /* XXX: check if supported by surface */ + native_info.imageFormat = VK_FORMAT_B8G8R8A8_UNORM; + native_info.imageUsage = VK_IMAGE_USAGE_STORAGE_BIT; - if(native_info.imageFormat != VK_FORMAT_B8G8R8A8_UNORM && - native_info.imageFormat != VK_FORMAT_B8G8R8A8_SRGB){ + if(create_info->imageFormat != VK_FORMAT_B8G8R8A8_UNORM && + create_info->imageFormat != VK_FORMAT_B8G8R8A8_SRGB){ FIXME("swapchain image format is not BGRA8 UNORM/SRGB. Things may go badly. %d\n", native_info.imageFormat); } @@ -2733,7 +2693,7 @@ NTSTATUS wine_vkCreateSwapchainKHR(void *args) if(object->fs_hack_enabled){ object->user_extent = create_info->imageExtent; - result = init_fs_hack_images(device, object, &native_info); + result = init_fs_hack_images(device, object, create_info); if(result != VK_SUCCESS){ ERR("creating fs hack images failed: %d\n", result); device->funcs.p_vkDestroySwapchainKHR(device->device, object->swapchain, NULL); @@ -2742,8 +2702,6 @@ NTSTATUS wine_vkCreateSwapchainKHR(void *args) return result; } - /* FIXME: would be nice to do this on-demand, but games can use up all - * memory so we fail to allocate later */ result = init_blit_images(device, object); if(result != VK_SUCCESS){ ERR("creating blit images failed: %d\n", result); @@ -3065,7 +3023,6 @@ NTSTATUS wine_vkDestroySwapchainKHR(void *args) device->funcs.p_vkDestroyDescriptorPool(device->device, object->descriptor_pool, NULL); device->funcs.p_vkDestroySampler(device->device, object->sampler, NULL); device->funcs.p_vkFreeMemory(device->device, object->user_image_memory, NULL); - device->funcs.p_vkFreeMemory(device->device, object->blit_image_memory, NULL); free(object->cmd_pools); free(object->fs_hack_images); } @@ -3140,7 +3097,6 @@ static VkCommandBuffer create_hack_cmd(VkQueue queue, struct VkSwapchainKHR_T *s static VkResult record_compute_cmd(VkDevice device, struct VkSwapchainKHR_T *swapchain, struct fs_hack_image *hack) { VkResult result; - VkImageCopy region = {0}; #if defined(USE_STRUCT_CONVERSION) VkImageMemoryBarrier_host barriers[3] = {{0}}; VkCommandBufferBeginInfo_host beginInfo = {0}; @@ -3152,15 +3108,6 @@ static VkResult record_compute_cmd(VkDevice device, struct VkSwapchainKHR_T *swa TRACE("recording compute command\n"); -#if 0 - /* DOOM runs out of memory when allocating blit images after loading. */ - if(!swapchain->blit_image_memory){ - result = init_blit_images(device, swapchain); - if(result != VK_SUCCESS) - return result; - } -#endif - beginInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; beginInfo.flags = VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT; @@ -3183,13 +3130,13 @@ static VkResult record_compute_cmd(VkDevice device, struct VkSwapchainKHR_T *swa barriers[0].dstAccessMask = VK_ACCESS_SHADER_READ_BIT; /* storage image... */ - /* transition blit image from whatever to GENERAL */ + /* transition swapchain image from whatever to GENERAL */ barriers[1].sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; barriers[1].oldLayout = VK_IMAGE_LAYOUT_UNDEFINED; barriers[1].newLayout = VK_IMAGE_LAYOUT_GENERAL; barriers[1].srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; barriers[1].dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; - barriers[1].image = hack->blit_image ? hack->blit_image : hack->swapchain_image; + barriers[1].image = hack->swapchain_image; barriers[1].subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; barriers[1].subresourceRange.baseMipLevel = 0; barriers[1].subresourceRange.levelCount = 1; @@ -3219,6 +3166,11 @@ static VkResult record_compute_cmd(VkDevice device, struct VkSwapchainKHR_T *swa /* vec2: blit dst offset in real coords */ constants[0] = swapchain->blit_dst.offset.x; constants[1] = swapchain->blit_dst.offset.y; + + /* offset by 0.5f because sampling is relative to pixel center */ + constants[0] -= 0.5f * swapchain->blit_dst.extent.width / swapchain->user_extent.width ; + constants[1] -= 0.5f * swapchain->blit_dst.extent.height / swapchain->user_extent.height; + /* vec2: blit dst extents in real coords */ constants[2] = swapchain->blit_dst.extent.width; constants[3] = swapchain->blit_dst.extent.height; @@ -3245,269 +3197,24 @@ static VkResult record_compute_cmd(VkDevice device, struct VkSwapchainKHR_T *swa barriers[0].srcAccessMask = VK_ACCESS_SHADER_READ_BIT; barriers[0].dstAccessMask = 0; - device->funcs.p_vkCmdPipelineBarrier( - hack->cmd, - VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, - VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, - 0, - 0, NULL, - 0, NULL, - 1, barriers - ); - - if(hack->blit_image){ - /* for the copy... */ - /* no transition, just a barrier for our access masks (w -> r) */ - barriers[0].sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; - barriers[0].oldLayout = VK_IMAGE_LAYOUT_GENERAL; - barriers[0].newLayout = VK_IMAGE_LAYOUT_GENERAL; - barriers[0].srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; - barriers[0].dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; - barriers[0].image = hack->blit_image; - barriers[0].subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; - barriers[0].subresourceRange.baseMipLevel = 0; - barriers[0].subresourceRange.levelCount = 1; - barriers[0].subresourceRange.baseArrayLayer = 0; - barriers[0].subresourceRange.layerCount = 1; - barriers[0].srcAccessMask = VK_ACCESS_SHADER_WRITE_BIT; - barriers[0].dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT; - - /* for the copy... */ - /* transition swapchain image from whatever to TRANSFER_DST - * we don't care about the contents... */ - barriers[1].sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; - barriers[1].oldLayout = VK_IMAGE_LAYOUT_UNDEFINED; - barriers[1].newLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; - barriers[1].srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; - barriers[1].dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; - barriers[1].image = hack->swapchain_image; - barriers[1].subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; - barriers[1].subresourceRange.baseMipLevel = 0; - barriers[1].subresourceRange.levelCount = 1; - barriers[1].subresourceRange.baseArrayLayer = 0; - barriers[1].subresourceRange.layerCount = 1; - barriers[1].srcAccessMask = 0; - barriers[1].dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT; - - device->funcs.p_vkCmdPipelineBarrier( - hack->cmd, - VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, - VK_PIPELINE_STAGE_TRANSFER_BIT, - 0, - 0, NULL, - 0, NULL, - 2, barriers - ); - - /* copy from blit image to swapchain image */ - region.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; - region.srcSubresource.layerCount = 1; - region.srcOffset.x = 0; - region.srcOffset.y = 0; - region.srcOffset.z = 0; - region.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; - region.dstSubresource.layerCount = 1; - region.dstOffset.x = 0; - region.dstOffset.y = 0; - region.dstOffset.z = 0; - region.extent.width = swapchain->real_extent.width; - region.extent.height = swapchain->real_extent.height; - region.extent.depth = 1; - - device->funcs.p_vkCmdCopyImage(hack->cmd, - hack->blit_image, VK_IMAGE_LAYOUT_GENERAL, - hack->swapchain_image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, - 1, ®ion); - - /* transition swapchain image from TRANSFER_DST_OPTIMAL to PRESENT_SRC */ - barriers[0].sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; - barriers[0].oldLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; - barriers[0].newLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR; - barriers[0].srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; - barriers[0].dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; - barriers[0].image = hack->swapchain_image; - barriers[0].subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; - barriers[0].subresourceRange.baseMipLevel = 0; - barriers[0].subresourceRange.levelCount = 1; - barriers[0].subresourceRange.baseArrayLayer = 0; - barriers[0].subresourceRange.layerCount = 1; - barriers[0].srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT; - barriers[0].dstAccessMask = 0; - - device->funcs.p_vkCmdPipelineBarrier( - hack->cmd, - VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, - VK_PIPELINE_STAGE_TRANSFER_BIT, - 0, - 0, NULL, - 0, NULL, - 1, barriers - ); - }else{ - /* transition swapchain image from GENERAL to PRESENT_SRC */ - barriers[0].sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; - barriers[0].oldLayout = VK_IMAGE_LAYOUT_GENERAL; - barriers[0].newLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR; - barriers[0].srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; - barriers[0].dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; - barriers[0].image = hack->swapchain_image; - barriers[0].subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; - barriers[0].subresourceRange.baseMipLevel = 0; - barriers[0].subresourceRange.levelCount = 1; - barriers[0].subresourceRange.baseArrayLayer = 0; - barriers[0].subresourceRange.layerCount = 1; - barriers[0].srcAccessMask = VK_ACCESS_SHADER_WRITE_BIT; - barriers[0].dstAccessMask = 0; - - device->funcs.p_vkCmdPipelineBarrier( - hack->cmd, - VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, - VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, - 0, - 0, NULL, - 0, NULL, - 1, barriers - ); - } - - result = device->funcs.p_vkEndCommandBuffer(hack->cmd); - if(result != VK_SUCCESS){ - ERR("vkEndCommandBuffer: %d\n", result); - return result; - } - - return VK_SUCCESS; -} - -static VkResult record_graphics_cmd(VkDevice device, struct VkSwapchainKHR_T *swapchain, struct fs_hack_image *hack) -{ - VkResult result; - VkImageBlit blitregion = {0}; - VkImageSubresourceRange range = {0}; - VkClearColorValue black = {{0.f, 0.f, 0.f}}; -#if defined(USE_STRUCT_CONVERSION) - VkImageMemoryBarrier_host barriers[2] = {{0}}; - VkCommandBufferBeginInfo_host beginInfo = {0}; -#else - VkImageMemoryBarrier barriers[2] = {{0}}; - VkCommandBufferBeginInfo beginInfo = {0}; -#endif - - TRACE("recording graphics command\n"); - - beginInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; - beginInfo.flags = VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT; - - device->funcs.p_vkBeginCommandBuffer(hack->cmd, &beginInfo); - - /* transition real image from whatever to TRANSFER_DST_OPTIMAL */ - barriers[0].sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; - barriers[0].oldLayout = VK_IMAGE_LAYOUT_UNDEFINED; - barriers[0].newLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; - barriers[0].srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; - barriers[0].dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; - barriers[0].image = hack->swapchain_image; - barriers[0].subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; - barriers[0].subresourceRange.baseMipLevel = 0; - barriers[0].subresourceRange.levelCount = 1; - barriers[0].subresourceRange.baseArrayLayer = 0; - barriers[0].subresourceRange.layerCount = 1; - barriers[0].srcAccessMask = 0; - barriers[0].dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT; - - /* transition user image from PRESENT_SRC to TRANSFER_SRC_OPTIMAL */ - barriers[1].sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; - barriers[1].oldLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR; - barriers[1].newLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; - barriers[1].srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; - barriers[1].dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; - barriers[1].image = hack->user_image; - barriers[1].subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; - barriers[1].subresourceRange.baseMipLevel = 0; - barriers[1].subresourceRange.levelCount = 1; - barriers[1].subresourceRange.baseArrayLayer = 0; - barriers[1].subresourceRange.layerCount = 1; - barriers[1].srcAccessMask = 0; - barriers[1].dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT; - - device->funcs.p_vkCmdPipelineBarrier( - hack->cmd, - VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, - VK_PIPELINE_STAGE_TRANSFER_BIT, - 0, - 0, NULL, - 0, NULL, - 2, barriers - ); - - /* clear the image */ - range.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; - range.baseMipLevel = 0; - range.levelCount = 1; - range.baseArrayLayer = 0; - range.layerCount = 1; - - device->funcs.p_vkCmdClearColorImage( - hack->cmd, hack->swapchain_image, - VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, - &black, 1, &range); - - /* perform blit */ - blitregion.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; - blitregion.srcSubresource.layerCount = 1; - blitregion.srcOffsets[0].x = 0; - blitregion.srcOffsets[0].y = 0; - blitregion.srcOffsets[0].z = 0; - blitregion.srcOffsets[1].x = swapchain->user_extent.width; - blitregion.srcOffsets[1].y = swapchain->user_extent.height; - blitregion.srcOffsets[1].z = 1; - blitregion.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; - blitregion.dstSubresource.layerCount = 1; - blitregion.dstOffsets[0].x = swapchain->blit_dst.offset.x; - blitregion.dstOffsets[0].y = swapchain->blit_dst.offset.y; - blitregion.dstOffsets[0].z = 0; - blitregion.dstOffsets[1].x = swapchain->blit_dst.offset.x + swapchain->blit_dst.extent.width; - blitregion.dstOffsets[1].y = swapchain->blit_dst.offset.y + swapchain->blit_dst.extent.height; - blitregion.dstOffsets[1].z = 1; - - device->funcs.p_vkCmdBlitImage(hack->cmd, - hack->user_image, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, - hack->swapchain_image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, - 1, &blitregion, swapchain->fs_hack_filter); - - /* transition real image from TRANSFER_DST to PRESENT_SRC */ - barriers[0].sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; - barriers[0].oldLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; - barriers[0].newLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR; - barriers[0].srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; - barriers[0].dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; - barriers[0].image = hack->swapchain_image; - barriers[0].subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; - barriers[0].subresourceRange.baseMipLevel = 0; - barriers[0].subresourceRange.levelCount = 1; - barriers[0].subresourceRange.baseArrayLayer = 0; - barriers[0].subresourceRange.layerCount = 1; - barriers[0].srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT; - barriers[0].dstAccessMask = 0; - - /* transition user image from TRANSFER_SRC_OPTIMAL to back to PRESENT_SRC */ + /* transition swapchain image from GENERAL to PRESENT_SRC */ barriers[1].sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; - barriers[1].oldLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; + barriers[1].oldLayout = VK_IMAGE_LAYOUT_GENERAL; barriers[1].newLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR; barriers[1].srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; barriers[1].dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED; - barriers[1].image = hack->user_image; + barriers[1].image = hack->swapchain_image; barriers[1].subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; barriers[1].subresourceRange.baseMipLevel = 0; barriers[1].subresourceRange.levelCount = 1; barriers[1].subresourceRange.baseArrayLayer = 0; barriers[1].subresourceRange.layerCount = 1; - barriers[1].srcAccessMask = VK_ACCESS_TRANSFER_READ_BIT; + barriers[1].srcAccessMask = VK_ACCESS_SHADER_WRITE_BIT; barriers[1].dstAccessMask = 0; device->funcs.p_vkCmdPipelineBarrier( hack->cmd, - VK_PIPELINE_STAGE_TRANSFER_BIT, + VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, 0, 0, NULL, @@ -3566,12 +3273,10 @@ static VkResult fshack_vk_queue_present(VkQueue queue, const VkPresentInfoKHR *p return VK_ERROR_DEVICE_LOST; } - if(queue->device->queue_props[queue_idx].queueFlags & VK_QUEUE_GRAPHICS_BIT) - res = record_graphics_cmd(queue->device, swapchain, hack); - else if(queue->device->queue_props[queue_idx].queueFlags & VK_QUEUE_COMPUTE_BIT) + if(queue->device->queue_props[queue_idx].queueFlags & VK_QUEUE_COMPUTE_BIT) /* TODO */ res = record_compute_cmd(queue->device, swapchain, hack); else{ - ERR("Present queue is neither graphics nor compute queue!\n"); + ERR("Present queue does not support compute!\n"); res = VK_ERROR_DEVICE_LOST; } diff --git a/dlls/winevulkan/vulkan_private.h b/dlls/winevulkan/vulkan_private.h index 4585a24bdcd..ce69f6f073e 100644 --- a/dlls/winevulkan/vulkan_private.h +++ b/dlls/winevulkan/vulkan_private.h @@ -74,7 +74,6 @@ struct fs_hack_image uint32_t cmd_queue_idx; VkCommandBuffer cmd; VkImage swapchain_image; - VkImage blit_image; VkImage user_image; VkSemaphore blit_finished; VkImageView user_view, blit_view; @@ -89,10 +88,9 @@ struct VkSwapchainKHR_T BOOL fs_hack_enabled; VkExtent2D user_extent; VkExtent2D real_extent; - VkImageUsageFlags surface_usage; VkRect2D blit_dst; VkCommandPool *cmd_pools; /* VkCommandPool[device->queue_count] */ - VkDeviceMemory user_image_memory, blit_image_memory; + VkDeviceMemory user_image_memory; uint32_t n_images; struct fs_hack_image *fs_hack_images; /* struct fs_hack_image[n_images] */ VkFilter fs_hack_filter;