improve image creation tests and windows opengl ci

This commit is contained in:
2025-08-26 20:43:16 +02:00
parent f5f632cf72
commit e652f382a4
6 changed files with 64 additions and 128 deletions

View File

@@ -31,22 +31,30 @@ jobs:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Download Mesa - name: Install 7zip
run: | run: choco install -y 7zip
curl -LO https://github.com/pal1000/mesa-dist-win/releases/download/23.3.1/mesa3d-23.3.1-release-msvc.7z
7z x mesa3d-23.3.1-release-msvc.7z -omesa
- name: Set Mesa in PATH - name: Download Mesa (prebuilt, MSVC x64)
run: echo "$env:GITHUB_WORKSPACE\\mesa\\x64" | Out-File -Append -FilePath $env:GITHUB_PATH shell: pwsh
- name: Set Mesa env
run: | run: |
echo "LIBGL_ALWAYS_SOFTWARE=1" >> $env:GITHUB_ENV $ver = "24.3.4"
echo "MESA_GL_VERSION_OVERRIDE=4.3" >> $env:GITHUB_ENV $uri = "https://github.com/pal1000/mesa-dist-win/releases/download/$ver/mesa3d-$ver-release-msvc.7z"
echo "MESA_GLES_VERSION_OVERRIDE=3.2" >> $env:GITHUB_ENV Invoke-WebRequest $uri -OutFile "$env:RUNNER_TEMP\mesa.7z"
echo "LIBGL_DEBUG=verbose" >> $env:GITHUB_ENV 7z x "$env:RUNNER_TEMP\mesa.7z" "-o$env:RUNNER_TEMP\mesa" -y
echo "EGL_LOG_LEVEL=debug" >> $env:GITHUB_ENV
echo "MESA_VERBOSE=all" >> $env:GITHUB_ENV - name: Drop Mesa next to the exe (EGL headless)
shell: pwsh
run: |
$dll_dir = "$env:RUNNER_TEMP\mesa\x64"
Copy-Item "$dll_dir\opengl32.dll" -Destination "build\Release"
Copy-Item "$dll_dir\libgallium_wgl.dll" -Destination "build\Release"
Copy-Item "$dll_dir\libEGL.dll" -Destination "build\Release"
# If you use OSMesa (Mesa < 25.1): also copy osmesa.dll
- name: Force llvmpipe + core 4.5
run: |
setx GALLIUM_DRIVER llvmpipe
setx MESA_GL_VERSION_OVERRIDE 4.5
# Force xmake to a specific folder (for cache) # Force xmake to a specific folder (for cache)
- name: Set xmake env - name: Set xmake env

View File

@@ -92,7 +92,7 @@ PulseImage OpenGLCreateImageTryAndFail(PulseDevice device, const PulseImageCreat
if(image_type == GL_INVALID_ENUM) if(image_type == GL_INVALID_ENUM)
{ {
if(PULSE_IS_BACKEND_LOW_LEVEL_DEBUG(device->backend)) if(PULSE_IS_BACKEND_LOW_LEVEL_DEBUG(device->backend) && !try_and_fail)
PulseLogErrorFmt(device->backend, "%s image type is not supported", device->backend->backend == PULSE_BACKEND_OPENGL ? "(OpenGL)" : "(OpenGL ES)"); PulseLogErrorFmt(device->backend, "%s image type is not supported", device->backend->backend == PULSE_BACKEND_OPENGL ? "(OpenGL)" : "(OpenGL ES)");
PulseSetInternalError(PULSE_ERROR_INITIALIZATION_FAILED); PulseSetInternalError(PULSE_ERROR_INITIALIZATION_FAILED);
free(opengl_image); free(opengl_image);
@@ -101,7 +101,7 @@ PulseImage OpenGLCreateImageTryAndFail(PulseDevice device, const PulseImageCreat
} }
if(image_format == GL_INVALID_ENUM) if(image_format == GL_INVALID_ENUM)
{ {
if(PULSE_IS_BACKEND_LOW_LEVEL_DEBUG(device->backend)) if(PULSE_IS_BACKEND_LOW_LEVEL_DEBUG(device->backend) && !try_and_fail)
PulseLogErrorFmt(device->backend, "%s image format is not supported", device->backend->backend == PULSE_BACKEND_OPENGL ? "(OpenGL)" : "(OpenGL ES)"); PulseLogErrorFmt(device->backend, "%s image format is not supported", device->backend->backend == PULSE_BACKEND_OPENGL ? "(OpenGL)" : "(OpenGL ES)");
PulseSetInternalError(PULSE_ERROR_INVALID_IMAGE_FORMAT); PulseSetInternalError(PULSE_ERROR_INVALID_IMAGE_FORMAT);
free(opengl_image); free(opengl_image);

View File

@@ -215,10 +215,11 @@ PulseDevice WebGPUCreateDevice(PulseBackend backend, PulseDevice* forbiden_devic
#ifndef PULSE_PLAT_WASM #ifndef PULSE_PLAT_WASM
WGPUFeatureName features[] = { WGPUFeatureName features[] = {
WGPUNativeFeature_TextureAdapterSpecificFormatFeatures, (WGPUFeatureName)WGPUNativeFeature_TextureAdapterSpecificFormatFeatures,
WGPUFeatureName_TextureCompressionBC,
}; };
descriptor.requiredFeatures = features; descriptor.requiredFeatures = features;
descriptor.requiredFeatureCount = 1; descriptor.requiredFeatureCount = PULSE_SIZEOF_ARRAY(features);
#endif #endif
WGPURequestDeviceCallbackInfo device_callback = { 0 }; WGPURequestDeviceCallbackInfo device_callback = { 0 };

View File

@@ -176,26 +176,11 @@ bool WebGPUIsImageFormatValid(PulseDevice device, PulseImageFormat format, Pulse
wgpu_usage |= WGPUTextureUsage_StorageBinding | WGPUTextureUsage_CopySrc | WGPUTextureUsage_CopyDst; wgpu_usage |= WGPUTextureUsage_StorageBinding | WGPUTextureUsage_CopySrc | WGPUTextureUsage_CopyDst;
if(wgpu_format == WGPUTextureFormat_Undefined) if(wgpu_format == WGPUTextureFormat_Undefined)
{
if(PULSE_IS_BACKEND_LOW_LEVEL_DEBUG(device->backend))
PulseLogError(device->backend, "(WebGPU) unsupported image format");
PulseSetInternalError(PULSE_ERROR_INVALID_IMAGE_FORMAT);
return false; return false;
}
if(wgpu_usage == WGPUTextureUsage_None) if(wgpu_usage == WGPUTextureUsage_None)
{
if(PULSE_IS_BACKEND_LOW_LEVEL_DEBUG(device->backend))
PulseLogError(device->backend, "(WebGPU) unsupported image usage");
PulseSetInternalError(PULSE_ERROR_INVALID_IMAGE_USAGE);
return false; return false;
}
if(dimension == WGPUTextureDimension_Undefined) if(dimension == WGPUTextureDimension_Undefined)
{
if(PULSE_IS_BACKEND_LOW_LEVEL_DEBUG(device->backend))
PulseLogError(device->backend, "(WebGPU) unsupported image type");
PulseSetInternalError(PULSE_ERROR_INVALID_IMAGE_FORMAT);
return false; return false;
}
return true; return true;
} }

View File

@@ -10,103 +10,45 @@ void TestImageCreation()
PulseDevice device; PulseDevice device;
SetupDevice(backend, &device); SetupDevice(backend, &device);
{ PulseImageUsageFlags usages[] = {
PulseImageCreateInfo image_create_info = { 0 }; PULSE_IMAGE_USAGE_STORAGE_READ,
image_create_info.type = PULSE_IMAGE_TYPE_2D; PULSE_IMAGE_USAGE_STORAGE_WRITE,
image_create_info.format = PULSE_IMAGE_FORMAT_R8G8B8A8_UNORM; PULSE_IMAGE_USAGE_STORAGE_SIMULTANEOUS_READWRITE,
image_create_info.usage = PULSE_IMAGE_USAGE_STORAGE_READ; PULSE_IMAGE_USAGE_STORAGE_WRITE | PULSE_IMAGE_USAGE_STORAGE_READ,
image_create_info.width = 256; };
image_create_info.height = 256;
image_create_info.layer_count_or_depth = 1;
PulseImage image = PulseCreateImage(device, &image_create_info);
TEST_ASSERT_NOT_EQUAL_MESSAGE(image, PULSE_NULL_HANDLE, PulseVerbaliseErrorType(PulseGetLastErrorType()));
PulseDestroyImage(device, image);
}
{
PulseImageCreateInfo image_create_info = { 0 };
image_create_info.type = PULSE_IMAGE_TYPE_2D_ARRAY;
image_create_info.format = PULSE_IMAGE_FORMAT_R8G8B8A8_UNORM;
image_create_info.usage = PULSE_IMAGE_USAGE_STORAGE_READ;
image_create_info.width = 256;
image_create_info.height = 256;
image_create_info.layer_count_or_depth = 1;
PulseImage image = PulseCreateImage(device, &image_create_info);
TEST_ASSERT_NOT_EQUAL_MESSAGE(image, PULSE_NULL_HANDLE, PulseVerbaliseErrorType(PulseGetLastErrorType()));
PulseDestroyImage(device, image);
}
for(unsigned int format = 0; format < (unsigned int)PULSE_IMAGE_FORMAT_MAX_ENUM; format++)
{
for(unsigned int type = 0; type < (unsigned int)PULSE_IMAGE_TYPE_MAX_ENUM; type++)
{
for(unsigned int usages = 0; usages < 4; usages++)
{ {
PulseImageCreateInfo image_create_info = { 0 }; PulseImageCreateInfo image_create_info = { 0 };
image_create_info.type = PULSE_IMAGE_TYPE_3D; image_create_info.type = type;
image_create_info.format = PULSE_IMAGE_FORMAT_R8G8B8A8_UNORM; image_create_info.format = format;
image_create_info.usage = PULSE_IMAGE_USAGE_STORAGE_READ; image_create_info.usage = usages;
image_create_info.width = 256; image_create_info.width = 256;
image_create_info.height = 256; image_create_info.height = 256;
image_create_info.layer_count_or_depth = 1; image_create_info.layer_count_or_depth = (type == PULSE_IMAGE_TYPE_CUBE || type == PULSE_IMAGE_TYPE_CUBE_ARRAY) ? 6 : 1;
PulseImage image = PulseCreateImage(device, &image_create_info);
TEST_ASSERT_NOT_EQUAL_MESSAGE(image, PULSE_NULL_HANDLE, PulseVerbaliseErrorType(PulseGetLastErrorType()));
PulseDestroyImage(device, image);
}
if(PulseIsImageFormatValid(device, format, type, usages))
{ {
PulseImageCreateInfo image_create_info = { 0 };
image_create_info.type = PULSE_IMAGE_TYPE_CUBE;
image_create_info.format = PULSE_IMAGE_FORMAT_R8G8B8A8_UNORM;
image_create_info.usage = PULSE_IMAGE_USAGE_STORAGE_READ;
image_create_info.width = 256;
image_create_info.height = 256;
image_create_info.layer_count_or_depth = 6;
PulseImage image = PulseCreateImage(device, &image_create_info); PulseImage image = PulseCreateImage(device, &image_create_info);
TEST_ASSERT_NOT_EQUAL_MESSAGE(image, PULSE_NULL_HANDLE, PulseVerbaliseErrorType(PulseGetLastErrorType())); TEST_ASSERT_NOT_EQUAL_MESSAGE(image, PULSE_NULL_HANDLE, PulseVerbaliseErrorType(PulseGetLastErrorType()));
PulseDestroyImage(device, image); PulseDestroyImage(device, image);
} }
else
{ {
PulseImageCreateInfo image_create_info = { 0 }; DISABLE_ERRORS;
image_create_info.type = PULSE_IMAGE_TYPE_CUBE_ARRAY;
image_create_info.format = PULSE_IMAGE_FORMAT_R8G8B8A8_UNORM;
image_create_info.usage = PULSE_IMAGE_USAGE_STORAGE_READ;
image_create_info.width = 256;
image_create_info.height = 256;
image_create_info.layer_count_or_depth = 12;
PulseImage image = PulseCreateImage(device, &image_create_info); PulseImage image = PulseCreateImage(device, &image_create_info);
TEST_ASSERT_NOT_EQUAL_MESSAGE(image, PULSE_NULL_HANDLE, PulseVerbaliseErrorType(PulseGetLastErrorType())); TEST_ASSERT_EQUAL(image, PULSE_NULL_HANDLE);
PulseDestroyImage(device, image); PulseDestroyImage(device, image);
ENABLE_ERRORS;
} }
{
PulseImageCreateInfo image_create_info = { 0 };
image_create_info.type = PULSE_IMAGE_TYPE_2D;
image_create_info.format = PULSE_IMAGE_FORMAT_R8G8B8A8_UNORM;
image_create_info.usage = PULSE_IMAGE_USAGE_STORAGE_WRITE;
image_create_info.width = 256;
image_create_info.height = 256;
image_create_info.layer_count_or_depth = 1;
PulseImage image = PulseCreateImage(device, &image_create_info);
TEST_ASSERT_NOT_EQUAL_MESSAGE(image, PULSE_NULL_HANDLE, PulseVerbaliseErrorType(PulseGetLastErrorType()));
PulseDestroyImage(device, image);
} }
{
PulseImageCreateInfo image_create_info = { 0 };
image_create_info.type = PULSE_IMAGE_TYPE_2D;
image_create_info.format = PULSE_IMAGE_FORMAT_R8G8B8A8_UNORM;
image_create_info.usage = PULSE_IMAGE_USAGE_STORAGE_SIMULTANEOUS_READWRITE;
image_create_info.width = 256;
image_create_info.height = 256;
image_create_info.layer_count_or_depth = 1;
PulseImage image = PulseCreateImage(device, &image_create_info);
TEST_ASSERT_NOT_EQUAL_MESSAGE(image, PULSE_NULL_HANDLE, PulseVerbaliseErrorType(PulseGetLastErrorType()));
PulseDestroyImage(device, image);
} }
{
PulseImageCreateInfo image_create_info = { 0 };
image_create_info.type = PULSE_IMAGE_TYPE_2D;
image_create_info.format = PULSE_IMAGE_FORMAT_R8_SNORM;
image_create_info.usage = PULSE_IMAGE_USAGE_STORAGE_READ;
image_create_info.width = 256;
image_create_info.height = 256;
image_create_info.layer_count_or_depth = 1;
PulseImage image = PulseCreateImage(device, &image_create_info);
TEST_ASSERT_NOT_EQUAL_MESSAGE(image, PULSE_NULL_HANDLE, PulseVerbaliseErrorType(PulseGetLastErrorType()));
PulseDestroyImage(device, image);
} }
DISABLE_ERRORS; DISABLE_ERRORS;