wined3d: Implement creating 2D array textures.
Signed-off-by: Józef Kucia <jkucia@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
64014ae3ed
commit
64da6b0526
|
@ -993,14 +993,25 @@ void wined3d_surface_upload_data(struct wined3d_surface *surface, const struct w
|
||||||
else
|
else
|
||||||
internal = format->glInternal;
|
internal = format->glInternal;
|
||||||
|
|
||||||
TRACE("glCompressedTexSubImage2D, target %#x, level %d, x %d, y %d, w %d, h %d, "
|
TRACE("Uploading compressed data, target %#x, level %u, layer %u, x %d, y %d, w %u, h %u, "
|
||||||
"format %#x, image_size %#x, addr %p.\n", surface->texture_target, surface->texture_level,
|
"format %#x, image_size %#x, addr %p.\n",
|
||||||
|
surface->texture_target, surface->texture_level, surface->texture_layer,
|
||||||
dst_point->x, dst_point->y, update_w, update_h, internal, row_count * row_length, addr);
|
dst_point->x, dst_point->y, update_w, update_h, internal, row_count * row_length, addr);
|
||||||
|
|
||||||
if (row_length == src_pitch)
|
if (row_length == src_pitch)
|
||||||
{
|
{
|
||||||
GL_EXTCALL(glCompressedTexSubImage2D(surface->texture_target, surface->texture_level,
|
if (surface->texture_target == GL_TEXTURE_2D_ARRAY)
|
||||||
dst_point->x, dst_point->y, update_w, update_h, internal, row_count * row_length, addr));
|
{
|
||||||
|
GL_EXTCALL(glCompressedTexSubImage3D(surface->texture_target, surface->texture_level,
|
||||||
|
dst_point->x, dst_point->y, surface->texture_layer, update_w, update_h, 1,
|
||||||
|
internal, row_count * row_length, addr));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GL_EXTCALL(glCompressedTexSubImage2D(surface->texture_target, surface->texture_level,
|
||||||
|
dst_point->x, dst_point->y, update_w, update_h,
|
||||||
|
internal, row_count * row_length, addr));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1010,13 +1021,23 @@ void wined3d_surface_upload_data(struct wined3d_surface *surface, const struct w
|
||||||
* can't use the unpack row length like for glTexSubImage2D. */
|
* can't use the unpack row length like for glTexSubImage2D. */
|
||||||
for (row = 0, y = dst_point->y; row < row_count; ++row)
|
for (row = 0, y = dst_point->y; row < row_count; ++row)
|
||||||
{
|
{
|
||||||
GL_EXTCALL(glCompressedTexSubImage2D(surface->texture_target, surface->texture_level,
|
if (surface->texture_target == GL_TEXTURE_2D_ARRAY)
|
||||||
dst_point->x, y, update_w, format->block_height, internal, row_length, addr));
|
{
|
||||||
|
GL_EXTCALL(glCompressedTexSubImage3D(surface->texture_target, surface->texture_level,
|
||||||
|
dst_point->x, y, surface->texture_layer, update_w, format->block_height, 1,
|
||||||
|
internal, row_length, addr));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GL_EXTCALL(glCompressedTexSubImage2D(surface->texture_target, surface->texture_level,
|
||||||
|
dst_point->x, y, update_w, format->block_height, internal, row_length, addr));
|
||||||
|
}
|
||||||
|
|
||||||
y += format->block_height;
|
y += format->block_height;
|
||||||
addr += src_pitch;
|
addr += src_pitch;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
checkGLcall("glCompressedTexSubImage2D");
|
checkGLcall("Upload compressed surface data");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1025,15 +1046,25 @@ void wined3d_surface_upload_data(struct wined3d_surface *surface, const struct w
|
||||||
addr += src_rect->top * src_pitch;
|
addr += src_rect->top * src_pitch;
|
||||||
addr += src_rect->left * format->byte_count;
|
addr += src_rect->left * format->byte_count;
|
||||||
|
|
||||||
TRACE("glTexSubImage2D, target %#x, level %d, x %d, y %d, w %d, h %d, format %#x, type %#x, addr %p.\n",
|
TRACE("Uploading data, target %#x, level %u, layer %u, x %d, y %d, w %u, h %u, "
|
||||||
surface->texture_target, surface->texture_level, dst_point->x, dst_point->y,
|
"format %#x, type %#x, addr %p.\n",
|
||||||
update_w, update_h, format->glFormat, format->glType, addr);
|
surface->texture_target, surface->texture_level, surface->texture_layer,
|
||||||
|
dst_point->x, dst_point->y, update_w, update_h, format->glFormat, format->glType, addr);
|
||||||
|
|
||||||
gl_info->gl_ops.gl.p_glPixelStorei(GL_UNPACK_ROW_LENGTH, src_pitch / format->byte_count);
|
gl_info->gl_ops.gl.p_glPixelStorei(GL_UNPACK_ROW_LENGTH, src_pitch / format->byte_count);
|
||||||
gl_info->gl_ops.gl.p_glTexSubImage2D(surface->texture_target, surface->texture_level,
|
if (surface->texture_target == GL_TEXTURE_2D_ARRAY)
|
||||||
dst_point->x, dst_point->y, update_w, update_h, format->glFormat, format->glType, addr);
|
{
|
||||||
|
GL_EXTCALL(glTexSubImage3D(surface->texture_target, surface->texture_level,
|
||||||
|
dst_point->x, dst_point->y, surface->texture_layer, update_w, update_h, 1,
|
||||||
|
format->glFormat, format->glType, addr));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gl_info->gl_ops.gl.p_glTexSubImage2D(surface->texture_target, surface->texture_level,
|
||||||
|
dst_point->x, dst_point->y, update_w, update_h, format->glFormat, format->glType, addr);
|
||||||
|
}
|
||||||
gl_info->gl_ops.gl.p_glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
gl_info->gl_ops.gl.p_glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
||||||
checkGLcall("glTexSubImage2D");
|
checkGLcall("Upload surface data");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data->buffer_object)
|
if (data->buffer_object)
|
||||||
|
|
|
@ -1359,10 +1359,10 @@ static BOOL texture2d_load_location(struct wined3d_texture *texture, unsigned in
|
||||||
/* Context activation is done by the caller. */
|
/* Context activation is done by the caller. */
|
||||||
static void texture2d_prepare_texture(struct wined3d_texture *texture, struct wined3d_context *context, BOOL srgb)
|
static void texture2d_prepare_texture(struct wined3d_texture *texture, struct wined3d_context *context, BOOL srgb)
|
||||||
{
|
{
|
||||||
UINT sub_count = texture->level_count * texture->layer_count;
|
|
||||||
const struct wined3d_format *format = texture->resource.format;
|
const struct wined3d_format *format = texture->resource.format;
|
||||||
const struct wined3d_gl_info *gl_info = context->gl_info;
|
const struct wined3d_gl_info *gl_info = context->gl_info;
|
||||||
const struct wined3d_color_key_conversion *conversion;
|
const struct wined3d_color_key_conversion *conversion;
|
||||||
|
unsigned int sub_call_count;
|
||||||
GLenum internal;
|
GLenum internal;
|
||||||
UINT i;
|
UINT i;
|
||||||
|
|
||||||
|
@ -1394,7 +1394,10 @@ static void texture2d_prepare_texture(struct wined3d_texture *texture, struct wi
|
||||||
|
|
||||||
TRACE("internal %#x, format %#x, type %#x.\n", internal, format->glFormat, format->glType);
|
TRACE("internal %#x, format %#x, type %#x.\n", internal, format->glFormat, format->glType);
|
||||||
|
|
||||||
for (i = 0; i < sub_count; ++i)
|
sub_call_count = texture->level_count;
|
||||||
|
if (texture->target != GL_TEXTURE_2D_ARRAY)
|
||||||
|
sub_call_count *= texture->layer_count;
|
||||||
|
for (i = 0; i < sub_call_count; ++i)
|
||||||
{
|
{
|
||||||
struct wined3d_surface *surface = texture->sub_resources[i].u.surface;
|
struct wined3d_surface *surface = texture->sub_resources[i].u.surface;
|
||||||
GLsizei width, height;
|
GLsizei width, height;
|
||||||
|
@ -1407,12 +1410,22 @@ static void texture2d_prepare_texture(struct wined3d_texture *texture, struct wi
|
||||||
height /= format->height_scale.denominator;
|
height /= format->height_scale.denominator;
|
||||||
}
|
}
|
||||||
|
|
||||||
TRACE("surface %p, target %#x, level %d, width %d, height %d.\n",
|
TRACE("surface %p, target %#x, level %u, width %u, height %u.\n",
|
||||||
surface, surface->texture_target, surface->texture_level, width, height);
|
surface, surface->texture_target, surface->texture_level, width, height);
|
||||||
|
|
||||||
gl_info->gl_ops.gl.p_glTexImage2D(surface->texture_target, surface->texture_level,
|
if (texture->target == GL_TEXTURE_2D_ARRAY)
|
||||||
internal, width, height, 0, format->glFormat, format->glType, NULL);
|
{
|
||||||
checkGLcall("glTexImage2D");
|
GL_EXTCALL(glTexImage3D(surface->texture_target, surface->texture_level,
|
||||||
|
internal, width, height, texture->layer_count, 0,
|
||||||
|
format->glFormat, format->glType, NULL));
|
||||||
|
checkGLcall("glTexImage3D");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gl_info->gl_ops.gl.p_glTexImage2D(surface->texture_target, surface->texture_level,
|
||||||
|
internal, width, height, 0, format->glFormat, format->glType, NULL);
|
||||||
|
checkGLcall("glTexImage2D");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1778,8 +1791,12 @@ static HRESULT texture_init(struct wined3d_texture *texture, const struct wined3
|
||||||
unsigned int i, j;
|
unsigned int i, j;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
if (!(desc->usage & WINED3DUSAGE_LEGACY_CUBEMAP) && layer_count != 1)
|
if (!(desc->usage & WINED3DUSAGE_LEGACY_CUBEMAP) && layer_count > 1
|
||||||
FIXME("Array textures not implemented.\n");
|
&& !gl_info->supported[EXT_TEXTURE_ARRAY])
|
||||||
|
{
|
||||||
|
WARN("OpenGL implementation does not support array textures.\n");
|
||||||
|
return WINED3DERR_INVALIDCALL;
|
||||||
|
}
|
||||||
|
|
||||||
/* TODO: It should only be possible to create textures for formats
|
/* TODO: It should only be possible to create textures for formats
|
||||||
* that are reported as supported. */
|
* that are reported as supported. */
|
||||||
|
@ -1909,6 +1926,8 @@ static HRESULT texture_init(struct wined3d_texture *texture, const struct wined3
|
||||||
}
|
}
|
||||||
if (desc->usage & WINED3DUSAGE_LEGACY_CUBEMAP)
|
if (desc->usage & WINED3DUSAGE_LEGACY_CUBEMAP)
|
||||||
texture->target = GL_TEXTURE_CUBE_MAP_ARB;
|
texture->target = GL_TEXTURE_CUBE_MAP_ARB;
|
||||||
|
else if (layer_count > 1)
|
||||||
|
texture->target = GL_TEXTURE_2D_ARRAY;
|
||||||
else
|
else
|
||||||
texture->target = GL_TEXTURE_2D;
|
texture->target = GL_TEXTURE_2D;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue