Skip to content

Commit d17e9fc

Browse files
committed
Backends: SDL_GPU: shallow tweaks + disable anisotropy in sampler. Examples: SDL+Vulkan: Fixed incorrect defines.
1 parent 3e6bdc2 commit d17e9fc

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

backends/imgui_impl_sdlgpu3.cpp

+7-6
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ static void ImGui_ImplSDLGPU3_SetupRenderState(ImDrawData* draw_data, SDL_GPUGra
8989
SDL_GPUBufferBinding index_buffer_binding = {};
9090
index_buffer_binding.buffer = fd->IndexBuffer;
9191
index_buffer_binding.offset = 0;
92-
SDL_BindGPUVertexBuffers(render_pass,0,&vertex_buffer_binding,1);
93-
SDL_BindGPUIndexBuffer(render_pass,&index_buffer_binding,sizeof(ImDrawIdx) == 2 ? SDL_GPU_INDEXELEMENTSIZE_16BIT : SDL_GPU_INDEXELEMENTSIZE_32BIT);
92+
SDL_BindGPUVertexBuffers(render_pass,0, &vertex_buffer_binding, 1);
93+
SDL_BindGPUIndexBuffer(render_pass, &index_buffer_binding, sizeof(ImDrawIdx) == 2 ? SDL_GPU_INDEXELEMENTSIZE_16BIT : SDL_GPU_INDEXELEMENTSIZE_32BIT);
9494
}
9595

9696
// Setup viewport
@@ -101,7 +101,7 @@ static void ImGui_ImplSDLGPU3_SetupRenderState(ImDrawData* draw_data, SDL_GPUGra
101101
viewport.h = (float)fb_height;
102102
viewport.min_depth = 0.0f;
103103
viewport.max_depth = 1.0f;
104-
SDL_SetGPUViewport(render_pass,&viewport);
104+
SDL_SetGPUViewport(render_pass, &viewport);
105105

106106
// Setup scale and translation
107107
// Our visible imgui space lies from draw_data->DisplayPps (top left) to draw_data->DisplayPos+data_data->DisplaySize (bottom right). DisplayPos is (0,0) for single viewport apps.
@@ -118,6 +118,7 @@ static void CreateOrResizeBuffer(SDL_GPUBuffer** buffer, uint32_t* old_size, uin
118118
ImGui_ImplSDLGPU3_Data* bd = ImGui_ImplSDLGPU3_GetBackendData();
119119
ImGui_ImplSDLGPU3_InitInfo* v = &bd->InitInfo;
120120

121+
// Even though this is fairly rarely called.
121122
SDL_WaitForGPUIdle(v->Device);
122123
SDL_ReleaseGPUBuffer(v->Device, *buffer);
123124

@@ -196,8 +197,8 @@ void Imgui_ImplSDLGPU3_PrepareDrawData(ImDrawData* draw_data, SDL_GPUCommandBuff
196197
index_buffer_region.size = index_size;
197198

198199
SDL_GPUCopyPass* copy_pass = SDL_BeginGPUCopyPass(command_buffer);
199-
SDL_UploadToGPUBuffer(copy_pass, &vertex_buffer_location, &vertex_buffer_region,true);
200-
SDL_UploadToGPUBuffer(copy_pass, &index_buffer_location, &index_buffer_region,true);
200+
SDL_UploadToGPUBuffer(copy_pass, &vertex_buffer_location, &vertex_buffer_region, true);
201+
SDL_UploadToGPUBuffer(copy_pass, &index_buffer_location, &index_buffer_region, true);
201202
SDL_EndGPUCopyPass(copy_pass);
202203
SDL_ReleaseGPUTransferBuffer(v->Device, index_transferbuffer);
203204
SDL_ReleaseGPUTransferBuffer(v->Device, vertex_transferbuffer);
@@ -527,7 +528,7 @@ void ImGui_ImplSDLGPU3_CreateDeviceObjects()
527528
sampler_info.mip_lod_bias = 0.0f;
528529
sampler_info.min_lod = -1000.0f;
529530
sampler_info.max_lod = 1000.0f;
530-
sampler_info.enable_anisotropy = true;
531+
sampler_info.enable_anisotropy = false;
531532
sampler_info.max_anisotropy = 1.0f;
532533
sampler_info.enable_compare = false;
533534

examples/example_sdl2_vulkan/main.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ static void SetupVulkanWindow(ImGui_ImplVulkanH_Window* wd, VkSurfaceKHR surface
217217
wd->SurfaceFormat = ImGui_ImplVulkanH_SelectSurfaceFormat(g_PhysicalDevice, wd->Surface, requestSurfaceImageFormat, (size_t)IM_ARRAYSIZE(requestSurfaceImageFormat), requestSurfaceColorSpace);
218218

219219
// Select Present Mode
220-
#ifdef APP_UNLIMITED_FRAME_RATE
220+
#ifdef APP_USE_UNLIMITED_FRAME_RATE
221221
VkPresentModeKHR present_modes[] = { VK_PRESENT_MODE_MAILBOX_KHR, VK_PRESENT_MODE_IMMEDIATE_KHR, VK_PRESENT_MODE_FIFO_KHR };
222222
#else
223223
VkPresentModeKHR present_modes[] = { VK_PRESENT_MODE_FIFO_KHR };

examples/example_sdl3_vulkan/main.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ static void SetupVulkanWindow(ImGui_ImplVulkanH_Window* wd, VkSurfaceKHR surface
222222
wd->SurfaceFormat = ImGui_ImplVulkanH_SelectSurfaceFormat(g_PhysicalDevice, wd->Surface, requestSurfaceImageFormat, (size_t)IM_ARRAYSIZE(requestSurfaceImageFormat), requestSurfaceColorSpace);
223223

224224
// Select Present Mode
225-
#ifdef APP_UNLIMITED_FRAME_RATE
225+
#ifdef APP_USE_UNLIMITED_FRAME_RATE
226226
VkPresentModeKHR present_modes[] = { VK_PRESENT_MODE_MAILBOX_KHR, VK_PRESENT_MODE_IMMEDIATE_KHR, VK_PRESENT_MODE_FIFO_KHR };
227227
#else
228228
VkPresentModeKHR present_modes[] = { VK_PRESENT_MODE_FIFO_KHR };

0 commit comments

Comments
 (0)