GPU: Update to set supported shader formats inside CreateDevice

This commit is contained in:
Logan
2025-05-18 13:04:20 +12:00
committed by Sam Lantinga
parent 514d96de07
commit 8289656a4e
4 changed files with 17 additions and 1 deletions

View File

@@ -672,7 +672,6 @@ SDL_GPUDevice *SDL_CreateGPUDeviceWithProperties(SDL_PropertiesID props)
result = selectedBackend->CreateDevice(debug_mode, preferLowPower, props); result = selectedBackend->CreateDevice(debug_mode, preferLowPower, props);
if (result != NULL) { if (result != NULL) {
result->backend = selectedBackend->name; result->backend = selectedBackend->name;
result->shader_formats = selectedBackend->shader_formats;
result->debug_mode = debug_mode; result->debug_mode = debug_mode;
} }
} }

View File

@@ -9182,8 +9182,23 @@ static SDL_GPUDevice *D3D12_CreateDevice(bool debugMode, bool preferLowPower, SD
return NULL; return NULL;
} }
SDL_GPUShaderFormat shaderFormats = SDL_GPU_SHADERFORMAT_DXBC;
D3D12_FEATURE_DATA_SHADER_MODEL shaderModel;
shaderModel.HighestShaderModel = D3D_SHADER_MODEL_6_0;
res = ID3D12Device_CheckFeatureSupport(
renderer->device,
D3D12_FEATURE_SHADER_MODEL,
&shaderModel,
sizeof(shaderModel));
if (SUCCEEDED(res) && shaderModel.HighestShaderModel >= D3D_SHADER_MODEL_6_0) {
shaderFormats |= SDL_GPU_SHADERFORMAT_DXIL;
}
ASSIGN_DRIVER(D3D12) ASSIGN_DRIVER(D3D12)
result->driverData = (SDL_GPURenderer *)renderer; result->driverData = (SDL_GPURenderer *)renderer;
result->shader_formats = shaderFormats;
result->debug_mode = debugMode; result->debug_mode = debugMode;
renderer->sdlGPUDevice = result; renderer->sdlGPUDevice = result;

View File

@@ -4610,6 +4610,7 @@ static SDL_GPUDevice *METAL_CreateDevice(bool debugMode, bool preferLowPower, SD
SDL_GPUDevice *result = SDL_calloc(1, sizeof(SDL_GPUDevice)); SDL_GPUDevice *result = SDL_calloc(1, sizeof(SDL_GPUDevice));
ASSIGN_DRIVER(METAL) ASSIGN_DRIVER(METAL)
result->driverData = (SDL_GPURenderer *)renderer; result->driverData = (SDL_GPURenderer *)renderer;
result->shader_formats = SDL_GPU_SHADERFORMAT_MSL | SDL_GPU_SHADERFORMAT_METALLIB;
renderer->sdlGPUDevice = result; renderer->sdlGPUDevice = result;
return result; return result;

View File

@@ -11793,6 +11793,7 @@ static SDL_GPUDevice *VULKAN_CreateDevice(bool debugMode, bool preferLowPower, S
ASSIGN_DRIVER(VULKAN) ASSIGN_DRIVER(VULKAN)
result->driverData = (SDL_GPURenderer *)renderer; result->driverData = (SDL_GPURenderer *)renderer;
result->shader_formats = SDL_GPU_SHADERFORMAT_SPIRV;
/* /*
* Create initial swapchain array * Create initial swapchain array