From: Sven Hesse Subject: [PATCH v3 6/9] wined3d: Implement texture1d_upload_data(). Message-Id: <20180207153509.10627-6-shesse@codeweavers.com> Date: Wed, 7 Feb 2018 16:35:06 +0100 In-Reply-To: <20180207153509.10627-1-shesse@codeweavers.com> References: <20180207153509.10627-1-shesse@codeweavers.com> Signed-off-by: Sven Hesse --- dlls/wined3d/texture.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 71 insertions(+), 1 deletion(-) diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index d2bc70fae1..ff52a820a2 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -1636,7 +1636,77 @@ 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; + struct wined3d_surface *surface = texture->sub_resources[sub_resource_idx].u.surface; + + 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->conv_byte_count) + { + 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->upload(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"); + } + + if (surface->texture_target == GL_TEXTURE_1D_ARRAY) + { + gl_info->gl_ops.gl.p_glTexSubImage2D(GL_TEXTURE_1D_ARRAY, level, x, surface->texture_layer, update_w, 1, format->glFormat, format->glType, mem); + checkGLcall("glTexSubImage2D"); + } + else + { + 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.16.1