[PATCH 6/9] wined3d: Implement texture1d_upload_data().
Sven Hesse
shesse at codeweavers.com
Tue Jan 2 09:25:41 CST 2018
Signed-off-by: Sven Hesse <shesse at codeweavers.com>
---
dlls/wined3d/texture.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 62 insertions(+), 1 deletion(-)
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index ac441fe677..ffd6e88f30 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -1630,7 +1630,68 @@ static void texture1d_upload_data(struct wined3d_texture *texture, unsigned int
const struct wined3d_context *context, const struct wined3d_box *box,
const struct wined3d_const_bo_address *data, unsigned int row_pitch, unsigned int slice_pitch)
{
- FIXME("Not implemented.\n");
+ const struct wined3d_format *format = texture->resource.format;
+ unsigned int level = sub_resource_idx % texture->level_count;
+ const struct wined3d_gl_info *gl_info = context->gl_info;
+ unsigned int x, update_w;
+ unsigned int dst_row_pitch, dst_slice_pitch;
+ unsigned int width;
+ const void *mem = data->addr;
+ void *converted_mem = NULL;
+
+ TRACE("texture %p, sub_resource_idx %u, context %p, box %s, data {%#x:%p}, row_pitch %#x, slice_pitch %#x.\n",
+ texture, sub_resource_idx, context, debug_box(box),
+ data->buffer_object, data->addr, row_pitch, slice_pitch);
+
+ width = wined3d_texture_get_level_width(texture, level);
+
+ if (!box)
+ {
+ x = 0;
+ update_w = width;
+ }
+ else
+ {
+ x = box->left;
+ update_w = box->right - box->left;
+ }
+
+ if (format->convert)
+ {
+ if (data->buffer_object)
+ ERR("Loading a converted texture from a PBO.\n");
+ if (texture->resource.format_flags & WINED3DFMT_FLAG_BLOCKS)
+ ERR("Converting a block-based format.\n");
+
+ dst_row_pitch = update_w * format->conv_byte_count;
+
+ converted_mem = wined3d_calloc(1, dst_row_pitch);
+ format->convert(data->addr, converted_mem, row_pitch, slice_pitch, dst_row_pitch, dst_row_pitch, update_w, 1, 1);
+ mem = converted_mem;
+ }
+ else
+ {
+ wined3d_texture_get_pitch(texture, sub_resource_idx, &dst_row_pitch, &dst_slice_pitch);
+ if (row_pitch != dst_row_pitch || slice_pitch != dst_slice_pitch)
+ FIXME("Ignoring row/slice pitch (%u/%u).\n", row_pitch, slice_pitch);
+ }
+
+ if (data->buffer_object)
+ {
+ GL_EXTCALL(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, data->buffer_object));
+ checkGLcall("glBindBuffer");
+ }
+
+ gl_info->gl_ops.gl.p_glTexSubImage1D(GL_TEXTURE_1D, level, x, update_w, format->glFormat, format->glType, mem);
+ checkGLcall("glTexSubImage1D");
+
+ if (data->buffer_object)
+ {
+ GL_EXTCALL(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0));
+ checkGLcall("glBindBuffer");
+ }
+
+ HeapFree(GetProcessHeap(), 0, converted_mem);
}
/* Context activation is done by the caller. */
--
2.15.1
More information about the wine-devel
mailing list