render: unify getter for texture formats

Instead of having separate getters for shm formats and DMA-BUF
formats, use the same pattern as wlr_output_impl.get_primary_formats
with a single function which takes buffer caps as input.
This commit is contained in:
Simon Ser 2024-04-12 11:27:57 +02:00 committed by Kenny Levinsen
parent c63275d75e
commit 85c1eda721
12 changed files with 78 additions and 67 deletions

View file

@ -44,6 +44,8 @@ struct wlr_gles2_renderer {
struct wlr_egl *egl;
int drm_fd;
struct wlr_drm_format_set shm_texture_formats;
const char *exts_str;
struct {
bool EXT_read_format_bgra;
@ -143,8 +145,8 @@ bool is_gles2_pixel_format_supported(const struct wlr_gles2_renderer *renderer,
const struct wlr_gles2_pixel_format *get_gles2_format_from_drm(uint32_t fmt);
const struct wlr_gles2_pixel_format *get_gles2_format_from_gl(
GLint gl_format, GLint gl_type, bool alpha);
const uint32_t *get_gles2_shm_formats(const struct wlr_gles2_renderer *renderer,
size_t *len);
void get_gles2_shm_formats(const struct wlr_gles2_renderer *renderer,
struct wlr_drm_format_set *out);
GLuint gles2_buffer_get_fbo(struct wlr_gles2_buffer *buffer);

View file

@ -60,11 +60,7 @@ struct wlr_vk_device {
struct wlr_vk_format_props *format_props;
struct wlr_drm_format_set dmabuf_render_formats;
struct wlr_drm_format_set dmabuf_texture_formats;
// supported formats for textures (contains only those formats
// that support everything we need for textures)
uint32_t shm_format_count;
uint32_t *shm_formats; // to implement vulkan_get_shm_texture_formats
struct wlr_drm_format_set shm_texture_formats;
};
// Tries to find the VkPhysicalDevice for the given drm fd.

View file

@ -20,10 +20,8 @@ struct wlr_box;
struct wlr_fbox;
struct wlr_renderer_impl {
const uint32_t *(*get_shm_texture_formats)(
struct wlr_renderer *renderer, size_t *len);
const struct wlr_drm_format_set *(*get_dmabuf_texture_formats)(
struct wlr_renderer *renderer);
const struct wlr_drm_format_set *(*get_texture_formats)(
struct wlr_renderer *renderer, uint32_t buffer_caps);
const struct wlr_drm_format_set *(*get_render_formats)(
struct wlr_renderer *renderer);
void (*destroy)(struct wlr_renderer *renderer);

View file

@ -50,11 +50,15 @@ struct wlr_renderer {
struct wlr_renderer *wlr_renderer_autocreate(struct wlr_backend *backend);
/**
* Get the shared-memory formats supporting import usage. Buffers allocated
* with a format from this list may be imported via wlr_texture_from_pixels().
* Get the formats supporting sampling usage.
*
* The buffer capabilities must be passed in.
*
* Buffers allocated with a format from this list may be passed to
* wlr_texture_from_buffer().
*/
const uint32_t *wlr_renderer_get_shm_texture_formats(
struct wlr_renderer *r, size_t *len);
const struct wlr_drm_format_set *wlr_renderer_get_texture_formats(
struct wlr_renderer *r, uint32_t buffer_caps);
/**
* Get the DMA-BUF formats supporting sampling usage. Buffers allocated with
* a format from this list may be imported via wlr_texture_from_dmabuf().