diff --git a/.gitlab-ci/expectations/host/piglit-virgl-gles-fails.txt b/.gitlab-ci/expectations/host/piglit-virgl-gles-fails.txt index 85c2af2..9926ae6 100644 --- a/.gitlab-ci/expectations/host/piglit-virgl-gles-fails.txt +++ b/.gitlab-ci/expectations/host/piglit-virgl-gles-fails.txt @@ -21,6 +21,8 @@ spec@arb_color_buffer_float@gl_rgba8_snorm-render,Fail spec@arb_color_buffer_float@gl_rgba8_snorm-render-fog,Fail spec@arb_compute_shader@execution@min-dvec4-double-large-group-size,Fail spec@arb_copy_image@arb_copy_image-formats,Fail +spec@arb_copy_image@arb_copy_image-formats --samples=2,Crash +spec@arb_copy_image@arb_copy_image-formats --samples=4,Crash spec@arb_copy_image@arb_copy_image-formats@Source: GL_ALPHA16/Destination: GL_ALPHA16,Fail spec@arb_copy_image@arb_copy_image-formats@Source: GL_COMPRESSED_RED_RGTC1/Destination: GL_COMPRESSED_RED_RGTC1,Fail spec@arb_copy_image@arb_copy_image-formats@Source: GL_COMPRESSED_RED_RGTC1/Destination: GL_RGBA16_SNORM,Fail @@ -585,7 +587,7 @@ spec@ext_framebuffer_multisample@draw-buffers-alpha-to-coverage 2,Fail spec@ext_framebuffer_multisample@draw-buffers-alpha-to-one 2,Fail spec@ext_framebuffer_multisample@draw-buffers-alpha-to-one 4,Fail spec@ext_framebuffer_multisample@enable-flag,Fail -spec@ext_framebuffer_multisample@fast-clear,Fail +spec@ext_framebuffer_multisample@fast-clear,Crash spec@ext_framebuffer_multisample@formats 2,Fail spec@ext_framebuffer_multisample@formats 4,Fail spec@ext_framebuffer_multisample@formats all_samples,Fail @@ -2556,6 +2558,8 @@ spec@khr_texture_compression_astc@sliced-3d-miptree-gl srgb-fp@sRGB decode full spec@khr_texture_compression_astc@sliced-3d-miptree-gl srgb@sRGB decode,ExpectedFail spec@khr_texture_compression_astc@void-extent-dl-bug,Fail spec@nv_copy_image@nv_copy_image-formats,Fail +spec@nv_copy_image@nv_copy_image-formats --samples=2,Crash +spec@nv_copy_image@nv_copy_image-formats --samples=4,Crash spec@nv_copy_image@nv_copy_image-formats@Source: GL_ALPHA16/Destination: GL_ALPHA16,Fail spec@nv_copy_image@nv_copy_image-formats@Source: GL_COMPRESSED_RED_RGTC1/Destination: GL_COMPRESSED_RED_RGTC1,Fail spec@nv_copy_image@nv_copy_image-formats@Source: GL_COMPRESSED_RGBA_BPTC_UNORM/Destination: GL_COMPRESSED_RGBA_BPTC_UNORM,Fail diff --git a/.gitlab-ci/expectations/virt/piglit-virgl-gles-fails.txt b/.gitlab-ci/expectations/virt/piglit-virgl-gles-fails.txt index f290ba4..f2b6e4b 100644 --- a/.gitlab-ci/expectations/virt/piglit-virgl-gles-fails.txt +++ b/.gitlab-ci/expectations/virt/piglit-virgl-gles-fails.txt @@ -21,6 +21,36 @@ spec@arb_color_buffer_float@gl_rgba8_snorm-render,Fail spec@arb_color_buffer_float@gl_rgba8_snorm-render-fog,Fail spec@arb_compute_shader@execution@min-dvec4-double-large-group-size,Fail spec@arb_copy_image@arb_copy_image-formats,Fail +spec@arb_copy_image@arb_copy_image-formats --samples=2,Fail +spec@arb_copy_image@arb_copy_image-formats --samples=2@Source: GL_ALPHA12/Destination: GL_ALPHA12,Fail +spec@arb_copy_image@arb_copy_image-formats --samples=2@Source: GL_ALPHA16/Destination: GL_ALPHA16,Fail +spec@arb_copy_image@arb_copy_image-formats --samples=2@Source: GL_INTENSITY/Destination: GL_INTENSITY,Fail +spec@arb_copy_image@arb_copy_image-formats --samples=2@Source: GL_INTENSITY12/Destination: GL_INTENSITY12,Fail +spec@arb_copy_image@arb_copy_image-formats --samples=2@Source: GL_INTENSITY16/Destination: GL_INTENSITY16,Fail +spec@arb_copy_image@arb_copy_image-formats --samples=2@Source: GL_INTENSITY8/Destination: GL_INTENSITY8,Fail +spec@arb_copy_image@arb_copy_image-formats --samples=2@Source: GL_LUMINANCE/Destination: GL_LUMINANCE,Fail +spec@arb_copy_image@arb_copy_image-formats --samples=2@Source: GL_LUMINANCE12/Destination: GL_LUMINANCE12,Fail +spec@arb_copy_image@arb_copy_image-formats --samples=2@Source: GL_LUMINANCE12_ALPHA12/Destination: GL_LUMINANCE12_ALPHA12,Fail +spec@arb_copy_image@arb_copy_image-formats --samples=2@Source: GL_LUMINANCE16/Destination: GL_LUMINANCE16,Fail +spec@arb_copy_image@arb_copy_image-formats --samples=2@Source: GL_LUMINANCE16_ALPHA16/Destination: GL_LUMINANCE16_ALPHA16,Fail +spec@arb_copy_image@arb_copy_image-formats --samples=2@Source: GL_LUMINANCE8/Destination: GL_LUMINANCE8,Fail +spec@arb_copy_image@arb_copy_image-formats --samples=2@Source: GL_LUMINANCE8_ALPHA8/Destination: GL_LUMINANCE8_ALPHA8,Fail +spec@arb_copy_image@arb_copy_image-formats --samples=2@Source: GL_LUMINANCE_ALPHA/Destination: GL_LUMINANCE_ALPHA,Fail +spec@arb_copy_image@arb_copy_image-formats --samples=4,Fail +spec@arb_copy_image@arb_copy_image-formats --samples=4@Source: GL_ALPHA12/Destination: GL_ALPHA12,Fail +spec@arb_copy_image@arb_copy_image-formats --samples=4@Source: GL_ALPHA16/Destination: GL_ALPHA16,Fail +spec@arb_copy_image@arb_copy_image-formats --samples=4@Source: GL_INTENSITY/Destination: GL_INTENSITY,Fail +spec@arb_copy_image@arb_copy_image-formats --samples=4@Source: GL_INTENSITY12/Destination: GL_INTENSITY12,Fail +spec@arb_copy_image@arb_copy_image-formats --samples=4@Source: GL_INTENSITY16/Destination: GL_INTENSITY16,Fail +spec@arb_copy_image@arb_copy_image-formats --samples=4@Source: GL_INTENSITY8/Destination: GL_INTENSITY8,Fail +spec@arb_copy_image@arb_copy_image-formats --samples=4@Source: GL_LUMINANCE/Destination: GL_LUMINANCE,Fail +spec@arb_copy_image@arb_copy_image-formats --samples=4@Source: GL_LUMINANCE12/Destination: GL_LUMINANCE12,Fail +spec@arb_copy_image@arb_copy_image-formats --samples=4@Source: GL_LUMINANCE12_ALPHA12/Destination: GL_LUMINANCE12_ALPHA12,Fail +spec@arb_copy_image@arb_copy_image-formats --samples=4@Source: GL_LUMINANCE16/Destination: GL_LUMINANCE16,Fail +spec@arb_copy_image@arb_copy_image-formats --samples=4@Source: GL_LUMINANCE16_ALPHA16/Destination: GL_LUMINANCE16_ALPHA16,Fail +spec@arb_copy_image@arb_copy_image-formats --samples=4@Source: GL_LUMINANCE8/Destination: GL_LUMINANCE8,Fail +spec@arb_copy_image@arb_copy_image-formats --samples=4@Source: GL_LUMINANCE8_ALPHA8/Destination: GL_LUMINANCE8_ALPHA8,Fail +spec@arb_copy_image@arb_copy_image-formats --samples=4@Source: GL_LUMINANCE_ALPHA/Destination: GL_LUMINANCE_ALPHA,Fail spec@arb_copy_image@arb_copy_image-formats@Source: GL_ALPHA16/Destination: GL_ALPHA16,Fail spec@arb_copy_image@arb_copy_image-formats@Source: GL_COMPRESSED_RED_RGTC1/Destination: GL_COMPRESSED_RED_RGTC1,Fail spec@arb_copy_image@arb_copy_image-formats@Source: GL_COMPRESSED_RED_RGTC1/Destination: GL_RGBA16_SNORM,Fail @@ -2582,6 +2612,36 @@ spec@khr_texture_compression_astc@sliced-3d-miptree-gl srgb-fp@sRGB decode full spec@khr_texture_compression_astc@sliced-3d-miptree-gl srgb@sRGB decode,ExpectedFail spec@khr_texture_compression_astc@void-extent-dl-bug,Fail spec@nv_copy_image@nv_copy_image-formats,Fail +spec@nv_copy_image@nv_copy_image-formats --samples=2,Fail +spec@nv_copy_image@nv_copy_image-formats --samples=2@Source: GL_ALPHA12/Destination: GL_ALPHA12,Fail +spec@nv_copy_image@nv_copy_image-formats --samples=2@Source: GL_ALPHA16/Destination: GL_ALPHA16,Fail +spec@nv_copy_image@nv_copy_image-formats --samples=2@Source: GL_INTENSITY/Destination: GL_INTENSITY,Fail +spec@nv_copy_image@nv_copy_image-formats --samples=2@Source: GL_INTENSITY12/Destination: GL_INTENSITY12,Fail +spec@nv_copy_image@nv_copy_image-formats --samples=2@Source: GL_INTENSITY16/Destination: GL_INTENSITY16,Fail +spec@nv_copy_image@nv_copy_image-formats --samples=2@Source: GL_INTENSITY8/Destination: GL_INTENSITY8,Fail +spec@nv_copy_image@nv_copy_image-formats --samples=2@Source: GL_LUMINANCE/Destination: GL_LUMINANCE,Fail +spec@nv_copy_image@nv_copy_image-formats --samples=2@Source: GL_LUMINANCE12/Destination: GL_LUMINANCE12,Fail +spec@nv_copy_image@nv_copy_image-formats --samples=2@Source: GL_LUMINANCE12_ALPHA12/Destination: GL_LUMINANCE12_ALPHA12,Fail +spec@nv_copy_image@nv_copy_image-formats --samples=2@Source: GL_LUMINANCE16/Destination: GL_LUMINANCE16,Fail +spec@nv_copy_image@nv_copy_image-formats --samples=2@Source: GL_LUMINANCE16_ALPHA16/Destination: GL_LUMINANCE16_ALPHA16,Fail +spec@nv_copy_image@nv_copy_image-formats --samples=2@Source: GL_LUMINANCE8/Destination: GL_LUMINANCE8,Fail +spec@nv_copy_image@nv_copy_image-formats --samples=2@Source: GL_LUMINANCE8_ALPHA8/Destination: GL_LUMINANCE8_ALPHA8,Fail +spec@nv_copy_image@nv_copy_image-formats --samples=2@Source: GL_LUMINANCE_ALPHA/Destination: GL_LUMINANCE_ALPHA,Fail +spec@nv_copy_image@nv_copy_image-formats --samples=4,Fail +spec@nv_copy_image@nv_copy_image-formats --samples=4@Source: GL_ALPHA12/Destination: GL_ALPHA12,Fail +spec@nv_copy_image@nv_copy_image-formats --samples=4@Source: GL_ALPHA16/Destination: GL_ALPHA16,Fail +spec@nv_copy_image@nv_copy_image-formats --samples=4@Source: GL_INTENSITY/Destination: GL_INTENSITY,Fail +spec@nv_copy_image@nv_copy_image-formats --samples=4@Source: GL_INTENSITY12/Destination: GL_INTENSITY12,Fail +spec@nv_copy_image@nv_copy_image-formats --samples=4@Source: GL_INTENSITY16/Destination: GL_INTENSITY16,Fail +spec@nv_copy_image@nv_copy_image-formats --samples=4@Source: GL_INTENSITY8/Destination: GL_INTENSITY8,Fail +spec@nv_copy_image@nv_copy_image-formats --samples=4@Source: GL_LUMINANCE/Destination: GL_LUMINANCE,Fail +spec@nv_copy_image@nv_copy_image-formats --samples=4@Source: GL_LUMINANCE12/Destination: GL_LUMINANCE12,Fail +spec@nv_copy_image@nv_copy_image-formats --samples=4@Source: GL_LUMINANCE12_ALPHA12/Destination: GL_LUMINANCE12_ALPHA12,Fail +spec@nv_copy_image@nv_copy_image-formats --samples=4@Source: GL_LUMINANCE16/Destination: GL_LUMINANCE16,Fail +spec@nv_copy_image@nv_copy_image-formats --samples=4@Source: GL_LUMINANCE16_ALPHA16/Destination: GL_LUMINANCE16_ALPHA16,Fail +spec@nv_copy_image@nv_copy_image-formats --samples=4@Source: GL_LUMINANCE8/Destination: GL_LUMINANCE8,Fail +spec@nv_copy_image@nv_copy_image-formats --samples=4@Source: GL_LUMINANCE8_ALPHA8/Destination: GL_LUMINANCE8_ALPHA8,Fail +spec@nv_copy_image@nv_copy_image-formats --samples=4@Source: GL_LUMINANCE_ALPHA/Destination: GL_LUMINANCE_ALPHA,Fail spec@nv_copy_image@nv_copy_image-formats@Source: GL_ALPHA16/Destination: GL_ALPHA16,Fail spec@nv_copy_image@nv_copy_image-formats@Source: GL_COMPRESSED_RED_RGTC1/Destination: GL_COMPRESSED_RED_RGTC1,Fail spec@nv_copy_image@nv_copy_image-formats@Source: GL_COMPRESSED_RGBA_BPTC_UNORM/Destination: GL_COMPRESSED_RGBA_BPTC_UNORM,Fail diff --git a/src/vrend_formats.c b/src/vrend_formats.c index 7190bce..0c3e6b2 100644 --- a/src/vrend_formats.c +++ b/src/vrend_formats.c @@ -655,6 +655,34 @@ void vrend_check_texture_storage(struct vrend_format_table *table) } } +void vrend_check_texture_multisample(struct vrend_format_table *table, + bool enable_storage) +{ + bool is_desktop_gl = epoxy_is_desktop_gl(); + for (int i = 0; i < VIRGL_FORMAT_MAX_EXTENDED; i++) { + bool function_available = + (table[i].flags & VIRGL_TEXTURE_CAN_TEXTURE_STORAGE) ? enable_storage : is_desktop_gl; + + if (table[i].internalformat != 0 && + !(table[i].flags & VIRGL_TEXTURE_CAN_MULTISAMPLE) && + function_available) { + GLuint tex_id; + glGenTextures(1, &tex_id); + glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, tex_id); + if (table[i].flags & VIRGL_TEXTURE_CAN_TEXTURE_STORAGE) { + glTexStorage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, 2, + table[i].internalformat, 32, 32, GL_TRUE); + } else { + glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, 2, + table[i].internalformat, 32, 32, GL_TRUE); + } + if (glGetError() == GL_NO_ERROR) + table[i].flags |= VIRGL_TEXTURE_CAN_MULTISAMPLE; + glDeleteTextures(1, &tex_id); + } + } +} + bool vrend_check_framebuffer_mixed_color_attachements() { GLuint tex_id[2]; diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c index aca3826..640c44e 100644 --- a/src/vrend_renderer.c +++ b/src/vrend_renderer.c @@ -832,6 +832,11 @@ static inline bool vrend_format_can_readback(enum virgl_formats format) return tex_conv_table[format].flags & VIRGL_TEXTURE_CAN_READBACK; } +static inline bool vrend_format_can_multisample(enum virgl_formats format) +{ + return tex_conv_table[format].flags & VIRGL_TEXTURE_CAN_MULTISAMPLE; +} + static inline bool vrend_format_can_render(enum virgl_formats format) { return tex_conv_table[format].bindings & VIRGL_BIND_RENDER_TARGET; @@ -6572,6 +6577,11 @@ int vrend_renderer_init(const struct vrend_if_cbs *cbs, uint32_t flags) vrend_check_texture_storage(tex_conv_table); + if (has_feature(feat_multisample)) { + vrend_check_texture_multisample(tex_conv_table, + has_feature(feat_storage_multisample)); + } + /* disable for format testing */ if (has_feature(feat_debug_cb)) { glDisable(GL_DEBUG_OUTPUT); @@ -6818,8 +6828,9 @@ static int check_resource_valid(const struct vrend_renderer_resource_create_args /* only texture 2d and 2d array can have multiple samples */ if (args->nr_samples > 0) { - if (!has_feature(feat_texture_multisample)) { - snprintf(errmsg, 256, "Multisample textures not supported"); + if (!vrend_format_can_multisample(args->format)) { + snprintf(errmsg, 256, "Unsupported multisample texture format %s", + util_format_name(args->format)); return -1; } @@ -6832,10 +6843,6 @@ static int check_resource_valid(const struct vrend_renderer_resource_create_args snprintf(errmsg, 256, "Multisample textures don't support mipmaps"); return -1; } - if (!format_can_texture_storage && vrend_state.use_gles) { - snprintf(errmsg, 256, "Unsupported multisample texture format %d", args->format); - return -1; - } } if (args->last_level > 0) { diff --git a/src/vrend_renderer.h b/src/vrend_renderer.h index 0a9050e..b40b943 100644 --- a/src/vrend_renderer.h +++ b/src/vrend_renderer.h @@ -101,6 +101,7 @@ struct vrend_resource { #define VIRGL_TEXTURE_CAN_TEXTURE_STORAGE (1 << 1) #define VIRGL_TEXTURE_CAN_READBACK (1 << 2) #define VIRGL_TEXTURE_CAN_TARGET_RECTANGLE (1 << 3) +#define VIRGL_TEXTURE_CAN_MULTISAMPLE (1 << 4) struct vrend_format_table { enum virgl_formats format; @@ -415,6 +416,8 @@ void vrend_build_format_list_gl(void); void vrend_build_format_list_gles(void); void vrend_build_emulated_format_list_gles(void); void vrend_check_texture_storage(struct vrend_format_table *table); +void vrend_check_texture_multisample(struct vrend_format_table *table, + bool enable_storage); void vrend_renderer_resource_destroy(struct vrend_resource *res);