From: Elizabeth Figura zfigura@codeweavers.com
--- dlls/wined3d/buffer.c | 2 ++ dlls/wined3d/decoder.c | 23 ++++++++++++++++++++++- include/wine/wined3d.h | 3 +++ 3 files changed, 27 insertions(+), 1 deletion(-)
diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c index 608be16b9df..a656f9edb2b 100644 --- a/dlls/wined3d/buffer.c +++ b/dlls/wined3d/buffer.c @@ -1142,6 +1142,8 @@ VkBufferUsageFlags vk_buffer_usage_from_bind_flags(uint32_t bind_flags) usage |= VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT; if (bind_flags & WINED3D_BIND_INDIRECT_BUFFER) usage |= VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT; + if (bind_flags & WINED3D_BIND_DECODER_SRC) + usage |= VK_BUFFER_USAGE_VIDEO_DECODE_SRC_BIT_KHR; if (bind_flags & (WINED3D_BIND_RENDER_TARGET | WINED3D_BIND_DEPTH_STENCIL)) FIXME("Ignoring some bind flags %#x.\n", bind_flags); return usage; diff --git a/dlls/wined3d/decoder.c b/dlls/wined3d/decoder.c index 262e8921d22..20a54851075 100644 --- a/dlls/wined3d/decoder.c +++ b/dlls/wined3d/decoder.c @@ -26,11 +26,12 @@ struct wined3d_decoder LONG ref; struct wined3d_device *device; struct wined3d_decoder_desc desc; - struct wined3d_buffer *parameters, *matrix, *slice_control; + struct wined3d_buffer *bitstream, *parameters, *matrix, *slice_control; };
static void wined3d_decoder_cleanup(struct wined3d_decoder *decoder) { + wined3d_buffer_decref(decoder->bitstream); wined3d_buffer_decref(decoder->parameters); wined3d_buffer_decref(decoder->matrix); wined3d_buffer_decref(decoder->slice_control); @@ -105,6 +106,23 @@ static HRESULT wined3d_decoder_init(struct wined3d_decoder *decoder, return hr; }
+ /* NVidia makes this buffer as large as width * height (as if each pixel + * is at most 1 byte). AMD makes it larger than that. + * Go with the smaller of the two. */ + buffer_desc.byte_width = desc->width * desc->height; + buffer_desc.bind_flags = WINED3D_BIND_DECODER_SRC; + buffer_desc.access = WINED3D_RESOURCE_ACCESS_GPU | WINED3D_RESOURCE_ACCESS_MAP_W; + buffer_desc.usage = WINED3DUSAGE_DYNAMIC; + + if (FAILED(hr = wined3d_buffer_create(device, &buffer_desc, + NULL, NULL, &wined3d_null_parent_ops, &decoder->bitstream))) + { + wined3d_buffer_decref(decoder->matrix); + wined3d_buffer_decref(decoder->parameters); + wined3d_buffer_decref(decoder->slice_control); + return hr; + } + return S_OK; }
@@ -433,6 +451,9 @@ struct wined3d_resource * CDECL wined3d_decoder_get_buffer( { switch (type) { + case WINED3D_DECODER_BUFFER_BITSTREAM: + return &decoder->bitstream->resource; + case WINED3D_DECODER_BUFFER_INVERSE_QUANTIZATION_MATRIX: return &decoder->matrix->resource;
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h index 8ea24f70b86..9c1ad9d0808 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -863,6 +863,7 @@ enum wined3d_decoder_buffer_type WINED3D_DECODER_BUFFER_PICTURE_PARAMETERS = 0, WINED3D_DECODER_BUFFER_INVERSE_QUANTIZATION_MATRIX = 4, WINED3D_DECODER_BUFFER_SLICE_CONTROL = 5, + WINED3D_DECODER_BUFFER_BITSTREAM = 6, };
enum wined3d_memory_segment_group @@ -923,6 +924,8 @@ enum wined3d_memory_segment_group #define WINED3D_BIND_DEPTH_STENCIL 0x00000040 #define WINED3D_BIND_UNORDERED_ACCESS 0x00000080 #define WINED3D_BIND_INDIRECT_BUFFER 0x00000100 +/* Used internally. */ +#define WINED3D_BIND_DECODER_SRC 0x80000000
#define WINED3DUSAGE_SOFTWAREPROCESSING 0x00000010 #define WINED3DUSAGE_DONOTCLIP 0x00000020