mirror of
git://source.winehq.org/git/wine.git
synced 2024-09-15 08:20:20 +00:00
d3dx10: Add support for loading MipLevels data in load_texture_data.
This commit is contained in:
parent
d1c03fe48a
commit
13801e63c9
|
@ -1138,7 +1138,7 @@ static void check_resource_info(ID3D10Resource *resource, const struct test_imag
|
||||||
ok_(__FILE__, line)(desc_2d.Height == expected_height,
|
ok_(__FILE__, line)(desc_2d.Height == expected_height,
|
||||||
"Got unexpected Height %u, expected %u.\n",
|
"Got unexpected Height %u, expected %u.\n",
|
||||||
desc_2d.Height, expected_height);
|
desc_2d.Height, expected_height);
|
||||||
todo_wine_if(expected_mip_levels != 1)
|
todo_wine_if(expected_mip_levels != image->expected_info.MipLevels)
|
||||||
ok_(__FILE__, line)(desc_2d.MipLevels == expected_mip_levels,
|
ok_(__FILE__, line)(desc_2d.MipLevels == expected_mip_levels,
|
||||||
"Got unexpected MipLevels %u, expected %u.\n",
|
"Got unexpected MipLevels %u, expected %u.\n",
|
||||||
desc_2d.MipLevels, expected_mip_levels);
|
desc_2d.MipLevels, expected_mip_levels);
|
||||||
|
|
|
@ -816,7 +816,7 @@ static HRESULT convert_image(IWICImagingFactory *factory, IWICBitmapFrameDecode
|
||||||
HRESULT load_texture_data(const void *data, SIZE_T size, D3DX10_IMAGE_LOAD_INFO *load_info,
|
HRESULT load_texture_data(const void *data, SIZE_T size, D3DX10_IMAGE_LOAD_INFO *load_info,
|
||||||
D3D10_SUBRESOURCE_DATA **resource_data)
|
D3D10_SUBRESOURCE_DATA **resource_data)
|
||||||
{
|
{
|
||||||
unsigned int stride, frame_size, i;
|
unsigned int stride, frame_size, i, j;
|
||||||
IWICDdsFrameDecode *dds_frame = NULL;
|
IWICDdsFrameDecode *dds_frame = NULL;
|
||||||
IWICBitmapFrameDecode *frame = NULL;
|
IWICBitmapFrameDecode *frame = NULL;
|
||||||
IWICImagingFactory *factory = NULL;
|
IWICImagingFactory *factory = NULL;
|
||||||
|
@ -884,14 +884,17 @@ HRESULT load_texture_data(const void *data, SIZE_T size, D3DX10_IMAGE_LOAD_INFO
|
||||||
|
|
||||||
for (i = 0; i < img_info.ArraySize; ++i)
|
for (i = 0; i < img_info.ArraySize; ++i)
|
||||||
{
|
{
|
||||||
if (FAILED(hr = IWICDdsDecoder_GetFrame(dds_decoder, i, 0, 0, &frame)))
|
for (j = 0; j < img_info.MipLevels; ++j)
|
||||||
|
{
|
||||||
|
if (FAILED(hr = IWICDdsDecoder_GetFrame(dds_decoder, i, j, 0, &frame)))
|
||||||
goto end;
|
goto end;
|
||||||
if (FAILED(hr = IWICBitmapFrameDecode_QueryInterface(frame, &IID_IWICDdsFrameDecode, (void **)&dds_frame)))
|
if (FAILED(hr = IWICBitmapFrameDecode_QueryInterface(frame,
|
||||||
|
&IID_IWICDdsFrameDecode, (void **)&dds_frame)))
|
||||||
goto end;
|
goto end;
|
||||||
if (FAILED(hr = dds_get_frame_info(dds_frame, &img_info, &format_info, &stride, &frame_size)))
|
if (FAILED(hr = dds_get_frame_info(dds_frame, &img_info, &format_info, &stride, &frame_size)))
|
||||||
goto end;
|
goto end;
|
||||||
|
|
||||||
if (!i)
|
if (!i && !j)
|
||||||
{
|
{
|
||||||
img_info.Width = (img_info.Width + format_info.BlockWidth - 1) & ~(format_info.BlockWidth - 1);
|
img_info.Width = (img_info.Width + format_info.BlockWidth - 1) & ~(format_info.BlockWidth - 1);
|
||||||
img_info.Height = (img_info.Height + format_info.BlockHeight - 1) & ~(format_info.BlockHeight - 1);
|
img_info.Height = (img_info.Height + format_info.BlockHeight - 1) & ~(format_info.BlockHeight - 1);
|
||||||
|
@ -904,6 +907,7 @@ HRESULT load_texture_data(const void *data, SIZE_T size, D3DX10_IMAGE_LOAD_INFO
|
||||||
IWICBitmapFrameDecode_Release(frame);
|
IWICBitmapFrameDecode_Release(frame);
|
||||||
frame = NULL;
|
frame = NULL;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!(res_data = malloc(size)))
|
if (!(res_data = malloc(size)))
|
||||||
{
|
{
|
||||||
|
@ -915,14 +919,17 @@ HRESULT load_texture_data(const void *data, SIZE_T size, D3DX10_IMAGE_LOAD_INFO
|
||||||
size = 0;
|
size = 0;
|
||||||
for (i = 0; i < img_info.ArraySize; ++i)
|
for (i = 0; i < img_info.ArraySize; ++i)
|
||||||
{
|
{
|
||||||
if (FAILED(hr = IWICDdsDecoder_GetFrame(dds_decoder, i, 0, 0, &frame)))
|
for (j = 0; j < img_info.MipLevels; ++j)
|
||||||
|
{
|
||||||
|
if (FAILED(hr = IWICDdsDecoder_GetFrame(dds_decoder, i, j, 0, &frame)))
|
||||||
goto end;
|
goto end;
|
||||||
if (FAILED(hr = IWICBitmapFrameDecode_QueryInterface(frame, &IID_IWICDdsFrameDecode, (void **)&dds_frame)))
|
if (FAILED(hr = IWICBitmapFrameDecode_QueryInterface(frame,
|
||||||
|
&IID_IWICDdsFrameDecode, (void **)&dds_frame)))
|
||||||
goto end;
|
goto end;
|
||||||
if (FAILED(hr = dds_get_frame_info(dds_frame, &img_info, &format_info, &stride, &frame_size)))
|
if (FAILED(hr = dds_get_frame_info(dds_frame, &img_info, &format_info, &stride, &frame_size)))
|
||||||
goto end;
|
goto end;
|
||||||
|
|
||||||
buffer = res_data + sizeof(**resource_data) * img_info.ArraySize + size;
|
buffer = res_data + sizeof(**resource_data) * img_info.ArraySize * img_info.MipLevels + size;
|
||||||
size += frame_size;
|
size += frame_size;
|
||||||
|
|
||||||
if (img_info.Format == format_info.DxgiFormat)
|
if (img_info.Format == format_info.DxgiFormat)
|
||||||
|
@ -947,9 +954,10 @@ HRESULT load_texture_data(const void *data, SIZE_T size, D3DX10_IMAGE_LOAD_INFO
|
||||||
IWICBitmapFrameDecode_Release(frame);
|
IWICBitmapFrameDecode_Release(frame);
|
||||||
frame = NULL;
|
frame = NULL;
|
||||||
|
|
||||||
(*resource_data)[i].pSysMem = buffer;
|
(*resource_data)[i * img_info.MipLevels + j].pSysMem = buffer;
|
||||||
(*resource_data)[i].SysMemPitch = stride;
|
(*resource_data)[i * img_info.MipLevels + j].SysMemPitch = stride;
|
||||||
(*resource_data)[i].SysMemSlicePitch = frame_size;
|
(*resource_data)[i * img_info.MipLevels + j].SysMemSlicePitch = frame_size;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -984,7 +992,7 @@ HRESULT load_texture_data(const void *data, SIZE_T size, D3DX10_IMAGE_LOAD_INFO
|
||||||
|
|
||||||
load_info->Width = img_info.Width;
|
load_info->Width = img_info.Width;
|
||||||
load_info->Height = img_info.Height;
|
load_info->Height = img_info.Height;
|
||||||
load_info->MipLevels = 1;
|
load_info->MipLevels = img_info.MipLevels;
|
||||||
load_info->Format = img_info.Format;
|
load_info->Format = img_info.Format;
|
||||||
load_info->Usage = D3D10_USAGE_DEFAULT;
|
load_info->Usage = D3D10_USAGE_DEFAULT;
|
||||||
load_info->BindFlags = D3D10_BIND_SHADER_RESOURCE;
|
load_info->BindFlags = D3D10_BIND_SHADER_RESOURCE;
|
||||||
|
|
Loading…
Reference in a new issue