mirror of
https://github.com/libretro/RetroArch
synced 2025-01-30 12:32:52 +00:00
(D3D10/D3D11/Vulkan) Cleanups
This commit is contained in:
parent
bfa627737e
commit
3115338849
@ -105,7 +105,7 @@ void d3d10_init_texture(D3D10Device device, d3d10_texture_t* texture)
|
||||
D3D10CreateTexture2D(device, &texture->desc, NULL, &texture->handle);
|
||||
|
||||
{
|
||||
D3D10_SHADER_RESOURCE_VIEW_DESC view_desc = { DXGI_FORMAT_UNKNOWN };
|
||||
D3D10_SHADER_RESOURCE_VIEW_DESC view_desc;
|
||||
view_desc.Format = texture->desc.Format;
|
||||
view_desc.ViewDimension = D3D_SRV_DIMENSION_TEXTURE2D;
|
||||
view_desc.Texture2D.MostDetailedMip = 0;
|
||||
@ -142,11 +142,7 @@ void d3d10_update_texture(
|
||||
d3d10_texture_t* texture)
|
||||
{
|
||||
D3D10_MAPPED_TEXTURE2D mapped_texture;
|
||||
D3D10_BOX frame_box = { 0, 0, 0, (UINT)width,
|
||||
(UINT)height, 1 };
|
||||
|
||||
if (!texture || !texture->staging)
|
||||
return;
|
||||
D3D10_BOX frame_box;
|
||||
|
||||
D3D10MapTexture2D(texture->staging,
|
||||
0, D3D10_MAP_WRITE, 0,
|
||||
@ -163,7 +159,12 @@ void d3d10_update_texture(
|
||||
#endif
|
||||
|
||||
D3D10UnmapTexture2D(texture->staging, 0);
|
||||
|
||||
frame_box.left = 0;
|
||||
frame_box.top = 0;
|
||||
frame_box.front = 0;
|
||||
frame_box.right = (UINT)width;
|
||||
frame_box.bottom = (UINT)height;
|
||||
frame_box.back = 1;
|
||||
D3D10CopyTexture2DSubresourceRegion(
|
||||
ctx, texture->handle, 0, 0, 0, 0, texture->staging, 0, &frame_box);
|
||||
|
||||
|
@ -131,7 +131,7 @@ void d3d11_init_texture(D3D11Device device, d3d11_texture_t* texture)
|
||||
D3D11CreateTexture2D(device, &texture->desc, NULL, &texture->handle);
|
||||
|
||||
{
|
||||
D3D11_SHADER_RESOURCE_VIEW_DESC view_desc = { DXGI_FORMAT_UNKNOWN };
|
||||
D3D11_SHADER_RESOURCE_VIEW_DESC view_desc;
|
||||
view_desc.Format = texture->desc.Format;
|
||||
view_desc.ViewDimension = D3D_SRV_DIMENSION_TEXTURE2D;
|
||||
view_desc.Texture2D.MostDetailedMip = 0;
|
||||
@ -168,10 +168,7 @@ void d3d11_update_texture(
|
||||
d3d11_texture_t* texture)
|
||||
{
|
||||
D3D11_MAPPED_SUBRESOURCE mapped_texture;
|
||||
D3D11_BOX frame_box = { 0, 0, 0, width, height, 1 };
|
||||
|
||||
if (!texture || !texture->staging)
|
||||
return;
|
||||
D3D11_BOX frame_box;
|
||||
|
||||
ctx->lpVtbl->Map(
|
||||
ctx, (D3D11Resource)texture->staging, 0, D3D11_MAP_WRITE, 0, &mapped_texture);
|
||||
@ -186,10 +183,16 @@ void d3d11_update_texture(
|
||||
mapped_texture.pData);
|
||||
#endif
|
||||
|
||||
frame_box.left = 0;
|
||||
frame_box.top = 0;
|
||||
frame_box.front = 0;
|
||||
frame_box.right = width;
|
||||
frame_box.bottom = height;
|
||||
frame_box.back = 1;
|
||||
ctx->lpVtbl->Unmap(ctx, (D3D11Resource)texture->staging, 0);
|
||||
|
||||
ctx->lpVtbl->CopySubresourceRegion(
|
||||
ctx, (D3D11Resource)texture->handle, 0, 0, 0, 0, (D3D11Resource)texture->staging, 0, &frame_box);
|
||||
ctx, (D3D11Resource)texture->handle, 0, 0, 0, 0,
|
||||
(D3D11Resource)texture->staging, 0, &frame_box);
|
||||
|
||||
if (texture->desc.MiscFlags & D3D11_RESOURCE_MISC_GENERATE_MIPS)
|
||||
D3D11GenerateMips(ctx, texture->view);
|
||||
|
@ -361,7 +361,7 @@ static void vulkan_track_dealloc(VkImage image)
|
||||
|
||||
static unsigned vulkan_num_miplevels(unsigned width, unsigned height)
|
||||
{
|
||||
unsigned size = MAX(width, height);
|
||||
unsigned size = MAX(width, height);
|
||||
unsigned levels = 0;
|
||||
while (size)
|
||||
{
|
||||
@ -1588,17 +1588,17 @@ static bool vulkan_context_init_device(gfx_ctx_vulkan_data_t *vk)
|
||||
bool use_device_ext;
|
||||
uint32_t queue_count;
|
||||
unsigned i;
|
||||
static const float one = 1.0f;
|
||||
bool found_queue = false;
|
||||
static const float one = 1.0f;
|
||||
bool found_queue = false;
|
||||
|
||||
VkPhysicalDeviceFeatures features = { false };
|
||||
VkDeviceQueueCreateInfo queue_info = { VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO };
|
||||
VkDeviceCreateInfo device_info = { VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO };
|
||||
VkPhysicalDeviceFeatures features = { false };
|
||||
VkDeviceQueueCreateInfo queue_info = { VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO };
|
||||
VkDeviceCreateInfo device_info = { VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO };
|
||||
|
||||
const char *enabled_device_extensions[8];
|
||||
unsigned enabled_device_extension_count = 0;
|
||||
|
||||
static const char *device_extensions[] = {
|
||||
static const char *device_extensions[] = {
|
||||
"VK_KHR_swapchain",
|
||||
};
|
||||
|
||||
@ -1623,7 +1623,7 @@ static bool vulkan_context_init_device(gfx_ctx_vulkan_data_t *vk)
|
||||
|
||||
if (!cached_device_vk && iface && iface->create_device)
|
||||
{
|
||||
struct retro_vulkan_context context = { 0 };
|
||||
struct retro_vulkan_context context = { 0 };
|
||||
const VkPhysicalDeviceFeatures features = { 0 };
|
||||
|
||||
bool ret = iface->create_device(&context, vk->context.instance,
|
||||
@ -1642,11 +1642,11 @@ static bool vulkan_context_init_device(gfx_ctx_vulkan_data_t *vk)
|
||||
}
|
||||
else
|
||||
{
|
||||
vk->context.destroy_device = iface->destroy_device;
|
||||
vk->context.destroy_device = iface->destroy_device;
|
||||
|
||||
vk->context.device = context.device;
|
||||
vk->context.queue = context.queue;
|
||||
vk->context.gpu = context.gpu;
|
||||
vk->context.device = context.device;
|
||||
vk->context.queue = context.queue;
|
||||
vk->context.gpu = context.gpu;
|
||||
vk->context.graphics_queue_index = context.queue_family_index;
|
||||
|
||||
if (context.presentation_queue != context.queue)
|
||||
@ -1700,8 +1700,7 @@ static bool vulkan_context_init_device(gfx_ctx_vulkan_data_t *vk)
|
||||
char driver_version[64];
|
||||
char api_version[64];
|
||||
char version_str[128];
|
||||
int pos = 0;
|
||||
|
||||
int pos = 0;
|
||||
device_str[0] = driver_version[0] = api_version[0] = version_str[0] = '\0';
|
||||
|
||||
strlcpy(device_str, vk->context.gpu_properties.deviceName, sizeof(device_str));
|
||||
@ -1944,7 +1943,7 @@ bool vulkan_context_init(gfx_ctx_vulkan_data_t *vk,
|
||||
return false;
|
||||
}
|
||||
|
||||
use_instance_ext = vulkan_find_instance_extensions(instance_extensions, ext_count);
|
||||
use_instance_ext = vulkan_find_instance_extensions(instance_extensions, ext_count);
|
||||
|
||||
app.pApplicationName = msg_hash_to_str(MSG_PROGRAM);
|
||||
app.applicationVersion = 0;
|
||||
@ -2901,9 +2900,8 @@ bool vulkan_create_swapchain(gfx_ctx_vulkan_data_t *vk,
|
||||
VkSurfaceFormatKHR format;
|
||||
VkExtent2D swapchain_size;
|
||||
VkSwapchainKHR old_swapchain;
|
||||
VkSwapchainCreateInfoKHR info;
|
||||
VkSurfaceTransformFlagBitsKHR pre_transform;
|
||||
VkSwapchainCreateInfoKHR info = {
|
||||
VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR };
|
||||
VkPresentModeKHR swapchain_present_mode = VK_PRESENT_MODE_FIFO_KHR;
|
||||
settings_t *settings = config_get_ptr();
|
||||
VkCompositeAlphaFlagBitsKHR composite = VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR;
|
||||
@ -3172,6 +3170,9 @@ bool vulkan_create_swapchain(gfx_ctx_vulkan_data_t *vk,
|
||||
|
||||
old_swapchain = vk->swapchain;
|
||||
|
||||
info.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR;
|
||||
info.pNext = NULL;
|
||||
info.flags = 0;
|
||||
info.surface = vk->vk_surface;
|
||||
info.minImageCount = desired_swapchain_images;
|
||||
info.imageFormat = format.format;
|
||||
@ -3179,14 +3180,17 @@ bool vulkan_create_swapchain(gfx_ctx_vulkan_data_t *vk,
|
||||
info.imageExtent.width = swapchain_size.width;
|
||||
info.imageExtent.height = swapchain_size.height;
|
||||
info.imageArrayLayers = 1;
|
||||
info.imageUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT
|
||||
| VK_IMAGE_USAGE_TRANSFER_SRC_BIT
|
||||
| VK_IMAGE_USAGE_TRANSFER_DST_BIT;
|
||||
info.imageSharingMode = VK_SHARING_MODE_EXCLUSIVE;
|
||||
info.queueFamilyIndexCount = 0;
|
||||
info.pQueueFamilyIndices = NULL;
|
||||
info.preTransform = pre_transform;
|
||||
info.compositeAlpha = composite;
|
||||
info.presentMode = swapchain_present_mode;
|
||||
info.clipped = true;
|
||||
info.oldSwapchain = old_swapchain;
|
||||
info.imageUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT
|
||||
| VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT;
|
||||
|
||||
#ifdef _WIN32
|
||||
/* On Windows, do not try to reuse the swapchain.
|
||||
@ -3268,7 +3272,7 @@ void vulkan_initialize_render_pass(VkDevice device, VkFormat format,
|
||||
VkAttachmentReference color_ref;
|
||||
VkRenderPassCreateInfo rp_info;
|
||||
VkAttachmentDescription attachment;
|
||||
VkSubpassDescription subpass = {0};
|
||||
VkSubpassDescription subpass = {0};
|
||||
|
||||
rp_info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO;
|
||||
rp_info.pNext = NULL;
|
||||
@ -3342,10 +3346,7 @@ void vulkan_framebuffer_generate_mips(
|
||||
unsigned i;
|
||||
/* This is run every frame, so make sure
|
||||
* we aren't opting into the "lazy" way of doing this. :) */
|
||||
VkImageMemoryBarrier barriers[2] = {
|
||||
{ VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER },
|
||||
{ VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER },
|
||||
};
|
||||
VkImageMemoryBarrier barriers[2];
|
||||
|
||||
/* First, transfer the input mip level to TRANSFER_SRC_OPTIMAL.
|
||||
* This should allow the surface to stay compressed.
|
||||
@ -3354,30 +3355,36 @@ void vulkan_framebuffer_generate_mips(
|
||||
*/
|
||||
|
||||
/* Input */
|
||||
barriers[0].srcAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
|
||||
barriers[0].dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT;
|
||||
barriers[0].oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
|
||||
barriers[0].newLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL;
|
||||
barriers[0].srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
|
||||
barriers[0].dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
|
||||
barriers[0].image = image;
|
||||
barriers[0].subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
|
||||
barriers[0].subresourceRange.baseMipLevel = 0;
|
||||
barriers[0].subresourceRange.levelCount = 1;
|
||||
barriers[0].subresourceRange.layerCount = VK_REMAINING_ARRAY_LAYERS;
|
||||
barriers[0].sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
|
||||
barriers[0].pNext = NULL;
|
||||
barriers[0].srcAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
|
||||
barriers[0].dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT;
|
||||
barriers[0].oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
|
||||
barriers[0].newLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL;
|
||||
barriers[0].srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
|
||||
barriers[0].dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
|
||||
barriers[0].image = 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 = VK_REMAINING_ARRAY_LAYERS;
|
||||
|
||||
/* The rest of the mip chain */
|
||||
barriers[1].srcAccessMask = 0;
|
||||
barriers[1].dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
|
||||
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 = image;
|
||||
barriers[1].subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
|
||||
barriers[1].subresourceRange.baseMipLevel = 1;
|
||||
barriers[1].subresourceRange.levelCount = VK_REMAINING_MIP_LEVELS;
|
||||
barriers[1].subresourceRange.layerCount = VK_REMAINING_ARRAY_LAYERS;
|
||||
barriers[1].sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
|
||||
barriers[1].pNext = NULL;
|
||||
barriers[1].srcAccessMask = 0;
|
||||
barriers[1].dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
|
||||
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 = image;
|
||||
barriers[1].subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
|
||||
barriers[1].subresourceRange.baseMipLevel = 1;
|
||||
barriers[1].subresourceRange.levelCount = VK_REMAINING_MIP_LEVELS;
|
||||
barriers[0].subresourceRange.baseArrayLayer = 0;
|
||||
barriers[1].subresourceRange.layerCount = VK_REMAINING_ARRAY_LAYERS;
|
||||
|
||||
vkCmdPipelineBarrier(cmd,
|
||||
VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT,
|
||||
|
@ -185,11 +185,12 @@ static bool d3d10_overlay_load(void* data, const void* image_data, unsigned num_
|
||||
|
||||
d3d10_init_texture(d3d10->device, &d3d10->overlays.textures[i]);
|
||||
|
||||
d3d10_update_texture(
|
||||
d3d10->device,
|
||||
images[i].width,
|
||||
images[i].height, 0, DXGI_FORMAT_B8G8R8A8_UNORM,
|
||||
images[i].pixels, &d3d10->overlays.textures[i]);
|
||||
if (d3d10->overlays.textures[i].staging)
|
||||
d3d10_update_texture(
|
||||
d3d10->device,
|
||||
images[i].width,
|
||||
images[i].height, 0, DXGI_FORMAT_B8G8R8A8_UNORM,
|
||||
images[i].pixels, &d3d10->overlays.textures[i]);
|
||||
|
||||
sprites[i].pos.x = 0.0f;
|
||||
sprites[i].pos.y = 0.0f;
|
||||
@ -517,11 +518,12 @@ static bool d3d10_gfx_set_shader(void* data, enum rarch_shader_type type, const
|
||||
|
||||
d3d10_init_texture(d3d10->device, &d3d10->luts[i]);
|
||||
|
||||
d3d10_update_texture(
|
||||
d3d10->device,
|
||||
image.width, image.height, 0,
|
||||
DXGI_FORMAT_R8G8B8A8_UNORM, image.pixels,
|
||||
&d3d10->luts[i]);
|
||||
if (d3d10->luts[i].staging)
|
||||
d3d10_update_texture(
|
||||
d3d10->device,
|
||||
image.width, image.height, 0,
|
||||
DXGI_FORMAT_R8G8B8A8_UNORM, image.pixels,
|
||||
&d3d10->luts[i]);
|
||||
|
||||
image_texture_free(&image);
|
||||
}
|
||||
@ -1345,9 +1347,10 @@ static bool d3d10_gfx_frame(
|
||||
d3d10_init_render_targets(d3d10, width, height);
|
||||
|
||||
if (frame != RETRO_HW_FRAME_BUFFER_VALID)
|
||||
d3d10_update_texture(
|
||||
d3d10->device,
|
||||
width, height, pitch, d3d10->format, frame, &d3d10->frame.texture[0]);
|
||||
if (d3d10->frame.texture[0].staging)
|
||||
d3d10_update_texture(
|
||||
d3d10->device,
|
||||
width, height, pitch, d3d10->format, frame, &d3d10->frame.texture[0]);
|
||||
}
|
||||
|
||||
D3D10SetVertexBuffer(context, 0, d3d10->frame.vbo, sizeof(d3d10_vertex_t), 0);
|
||||
@ -1632,8 +1635,9 @@ static void d3d10_set_menu_texture_frame(
|
||||
d3d10_init_texture(d3d10->device, &d3d10->menu.texture);
|
||||
}
|
||||
|
||||
d3d10_update_texture(d3d10->device, width, height, 0,
|
||||
format, frame, &d3d10->menu.texture);
|
||||
if (d3d10->menu.texture.staging)
|
||||
d3d10_update_texture(d3d10->device, width, height, 0,
|
||||
format, frame, &d3d10->menu.texture);
|
||||
d3d10->menu.texture.sampler = d3d10->samplers
|
||||
[settings->bools.menu_linear_filter
|
||||
? RARCH_FILTER_LINEAR
|
||||
@ -1720,10 +1724,11 @@ static uintptr_t d3d10_gfx_load_texture(
|
||||
|
||||
d3d10_init_texture(d3d10->device, texture);
|
||||
|
||||
d3d10_update_texture(
|
||||
d3d10->device,
|
||||
image->width, image->height, 0, DXGI_FORMAT_B8G8R8A8_UNORM, image->pixels,
|
||||
texture);
|
||||
if (texture->staging)
|
||||
d3d10_update_texture(
|
||||
d3d10->device,
|
||||
image->width, image->height, 0, DXGI_FORMAT_B8G8R8A8_UNORM, image->pixels,
|
||||
texture);
|
||||
|
||||
return (uintptr_t)texture;
|
||||
}
|
||||
|
@ -207,10 +207,11 @@ static bool d3d11_overlay_load(void* data, const void* image_data, unsigned num_
|
||||
|
||||
d3d11_init_texture(d3d11->device, &d3d11->overlays.textures[i]);
|
||||
|
||||
d3d11_update_texture(
|
||||
d3d11->context, images[i].width,
|
||||
images[i].height, 0, DXGI_FORMAT_B8G8R8A8_UNORM,
|
||||
images[i].pixels, &d3d11->overlays.textures[i]);
|
||||
if (d3d11->overlays.textures[i].staging)
|
||||
d3d11_update_texture(
|
||||
d3d11->context, images[i].width,
|
||||
images[i].height, 0, DXGI_FORMAT_B8G8R8A8_UNORM,
|
||||
images[i].pixels, &d3d11->overlays.textures[i]);
|
||||
|
||||
sprites[i].pos.x = 0.0f;
|
||||
sprites[i].pos.y = 0.0f;
|
||||
@ -708,9 +709,10 @@ static bool d3d11_gfx_set_shader(void* data, enum rarch_shader_type type, const
|
||||
|
||||
d3d11_init_texture(d3d11->device, &d3d11->luts[i]);
|
||||
|
||||
d3d11_update_texture(
|
||||
d3d11->context, image.width, image.height, 0, DXGI_FORMAT_R8G8B8A8_UNORM, image.pixels,
|
||||
&d3d11->luts[i]);
|
||||
if (d3d11->luts[i].staging)
|
||||
d3d11_update_texture(
|
||||
d3d11->context, image.width, image.height, 0, DXGI_FORMAT_R8G8B8A8_UNORM, image.pixels,
|
||||
&d3d11->luts[i]);
|
||||
|
||||
image_texture_free(&image);
|
||||
}
|
||||
@ -1990,7 +1992,7 @@ uuidof(ID3D11Texture2D), (void**)&back_buffer);
|
||||
Release(hw_texture);
|
||||
hw_texture = NULL;
|
||||
}
|
||||
else
|
||||
else if (d3d11->frame.texture[0].staging)
|
||||
d3d11_update_texture(
|
||||
context, width, height, pitch, d3d11->format, frame, &d3d11->frame.texture[0]);
|
||||
}
|
||||
@ -2414,8 +2416,9 @@ static void d3d11_set_menu_texture_frame(
|
||||
d3d11_init_texture(d3d11->device, &d3d11->menu.texture);
|
||||
}
|
||||
|
||||
d3d11_update_texture(d3d11->context, width, height, 0,
|
||||
format, frame, &d3d11->menu.texture);
|
||||
if (d3d11->menu.texture.staging)
|
||||
d3d11_update_texture(d3d11->context, width, height, 0,
|
||||
format, frame, &d3d11->menu.texture);
|
||||
d3d11->menu.texture.sampler = d3d11->samplers
|
||||
[menu_linear_filter
|
||||
? RARCH_FILTER_LINEAR
|
||||
@ -2508,9 +2511,10 @@ static uintptr_t d3d11_gfx_load_texture(
|
||||
|
||||
d3d11_init_texture(d3d11->device, texture);
|
||||
|
||||
d3d11_update_texture(
|
||||
d3d11->context, image->width, image->height, 0, DXGI_FORMAT_B8G8R8A8_UNORM, image->pixels,
|
||||
texture);
|
||||
if (texture->staging)
|
||||
d3d11_update_texture(
|
||||
d3d11->context, image->width, image->height, 0, DXGI_FORMAT_B8G8R8A8_UNORM, image->pixels,
|
||||
texture);
|
||||
|
||||
return (uintptr_t)texture;
|
||||
}
|
||||
|
@ -182,15 +182,20 @@ static void gfx_display_d3d10_draw_pipeline(gfx_display_ctx_draw_t* draw,
|
||||
|
||||
if (!d3d10->menu_pipeline_vbo)
|
||||
{
|
||||
D3D10_BUFFER_DESC desc = { 0 };
|
||||
desc.Usage = D3D10_USAGE_IMMUTABLE;
|
||||
desc.ByteWidth = ca->coords.vertices * 2 * sizeof(float);
|
||||
desc.BindFlags = D3D10_BIND_VERTEX_BUFFER;
|
||||
D3D10_BUFFER_DESC desc;
|
||||
D3D10_SUBRESOURCE_DATA vertex_data;
|
||||
|
||||
{
|
||||
D3D10_SUBRESOURCE_DATA vertexData = { ca->coords.vertex };
|
||||
D3D10CreateBuffer(d3d10->device, &desc, &vertexData, &d3d10->menu_pipeline_vbo);
|
||||
}
|
||||
desc.ByteWidth = ca->coords.vertices * 2 * sizeof(float);
|
||||
desc.Usage = D3D10_USAGE_IMMUTABLE;
|
||||
desc.BindFlags = D3D10_BIND_VERTEX_BUFFER;
|
||||
desc.CPUAccessFlags = 0;
|
||||
desc.MiscFlags = 0;
|
||||
|
||||
vertex_data.pSysMem = ca->coords.vertex;
|
||||
vertex_data.SysMemPitch = 0;
|
||||
vertex_data.SysMemSlicePitch = 0;
|
||||
D3D10CreateBuffer(d3d10->device, &desc, &vertex_data,
|
||||
&d3d10->menu_pipeline_vbo);
|
||||
}
|
||||
D3D10SetVertexBuffer(d3d10->device, 0, d3d10->menu_pipeline_vbo, 2 * sizeof(float), 0);
|
||||
draw->coords->vertices = ca->coords.vertices;
|
||||
|
@ -79,7 +79,9 @@ static void gfx_display_d3d12_draw(gfx_display_ctx_draw_t *draw,
|
||||
|
||||
{
|
||||
d3d12_sprite_t* sprite;
|
||||
D3D12_RANGE range = { 0, 0 };
|
||||
D3D12_RANGE range;
|
||||
range.Begin = 0;
|
||||
range.End = 0;
|
||||
D3D12Map(d3d12->sprites.vbo, 0, &range, (void**)&sprite);
|
||||
sprite += d3d12->sprites.offset;
|
||||
|
||||
@ -196,8 +198,8 @@ static void gfx_display_d3d12_draw_pipeline(gfx_display_ctx_draw_t *draw,
|
||||
|
||||
if (!d3d12->menu_pipeline_vbo)
|
||||
{
|
||||
D3D12_RANGE read_range;
|
||||
void* vertex_data_begin;
|
||||
D3D12_RANGE read_range = { 0, 0 };
|
||||
|
||||
d3d12->menu_pipeline_vbo_view.StrideInBytes = 2 * sizeof(float);
|
||||
d3d12->menu_pipeline_vbo_view.SizeInBytes =
|
||||
@ -206,6 +208,8 @@ static void gfx_display_d3d12_draw_pipeline(gfx_display_ctx_draw_t *draw,
|
||||
d3d12->device, d3d12->menu_pipeline_vbo_view.SizeInBytes,
|
||||
&d3d12->menu_pipeline_vbo);
|
||||
|
||||
read_range.Begin = 0;
|
||||
read_range.End = 0;
|
||||
D3D12Map(d3d12->menu_pipeline_vbo, 0, &read_range, &vertex_data_begin);
|
||||
memcpy(vertex_data_begin, ca->coords.vertex, d3d12->menu_pipeline_vbo_view.SizeInBytes);
|
||||
D3D12Unmap(d3d12->menu_pipeline_vbo, 0, NULL);
|
||||
@ -230,8 +234,11 @@ static void gfx_display_d3d12_draw_pipeline(gfx_display_ctx_draw_t *draw,
|
||||
d3d12->ubo_values.time += 0.01f;
|
||||
|
||||
{
|
||||
D3D12_RANGE read_range = { 0, 0 };
|
||||
D3D12_RANGE read_range;
|
||||
d3d12_uniform_t* mapped_ubo;
|
||||
|
||||
read_range.Begin = 0;
|
||||
read_range.End = 0;
|
||||
D3D12Map(d3d12->ubo, 0, &read_range, (void**)&mapped_ubo);
|
||||
*mapped_ubo = d3d12->ubo_values;
|
||||
D3D12Unmap(d3d12->ubo, 0, NULL);
|
||||
|
@ -58,10 +58,11 @@ d3d10_font_init_font(void* data, const char* font_path, float font_size, bool is
|
||||
font->texture.desc.Height = font->atlas->height;
|
||||
font->texture.desc.Format = DXGI_FORMAT_A8_UNORM;
|
||||
d3d10_init_texture(d3d10->device, &font->texture);
|
||||
d3d10_update_texture(
|
||||
d3d10->device,
|
||||
font->atlas->width, font->atlas->height, font->atlas->width,
|
||||
DXGI_FORMAT_A8_UNORM, font->atlas->buffer, &font->texture);
|
||||
if (font->texture.staging)
|
||||
d3d10_update_texture(
|
||||
d3d10->device,
|
||||
font->atlas->width, font->atlas->height, font->atlas->width,
|
||||
DXGI_FORMAT_A8_UNORM, font->atlas->buffer, &font->texture);
|
||||
font->atlas->dirty = false;
|
||||
|
||||
return font;
|
||||
@ -209,10 +210,11 @@ static void d3d10_font_render_line(
|
||||
|
||||
if (font->atlas->dirty)
|
||||
{
|
||||
d3d10_update_texture(
|
||||
d3d10->device,
|
||||
font->atlas->width, font->atlas->height, font->atlas->width,
|
||||
DXGI_FORMAT_A8_UNORM, font->atlas->buffer, &font->texture);
|
||||
if (font->texture.staging)
|
||||
d3d10_update_texture(
|
||||
d3d10->device,
|
||||
font->atlas->width, font->atlas->height, font->atlas->width,
|
||||
DXGI_FORMAT_A8_UNORM, font->atlas->buffer, &font->texture);
|
||||
font->atlas->dirty = false;
|
||||
}
|
||||
|
||||
|
@ -57,9 +57,10 @@ d3d11_font_init_font(void* data, const char* font_path, float font_size, bool is
|
||||
font->texture.desc.Height = font->atlas->height;
|
||||
font->texture.desc.Format = DXGI_FORMAT_A8_UNORM;
|
||||
d3d11_init_texture(d3d11->device, &font->texture);
|
||||
d3d11_update_texture(
|
||||
d3d11->context, font->atlas->width, font->atlas->height, font->atlas->width,
|
||||
DXGI_FORMAT_A8_UNORM, font->atlas->buffer, &font->texture);
|
||||
if (font->texture.staging)
|
||||
d3d11_update_texture(
|
||||
d3d11->context, font->atlas->width, font->atlas->height, font->atlas->width,
|
||||
DXGI_FORMAT_A8_UNORM, font->atlas->buffer, &font->texture);
|
||||
font->atlas->dirty = false;
|
||||
|
||||
return font;
|
||||
@ -208,9 +209,11 @@ static void d3d11_font_render_line(
|
||||
|
||||
if (font->atlas->dirty)
|
||||
{
|
||||
d3d11_update_texture(
|
||||
d3d11->context, font->atlas->width, font->atlas->height, font->atlas->width,
|
||||
DXGI_FORMAT_A8_UNORM, font->atlas->buffer, &font->texture);
|
||||
if (font->texture.staging)
|
||||
d3d11_update_texture(
|
||||
d3d11->context,
|
||||
font->atlas->width, font->atlas->height, font->atlas->width,
|
||||
DXGI_FORMAT_A8_UNORM, font->atlas->buffer, &font->texture);
|
||||
font->atlas->dirty = false;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user