ReactOS 0.4.17-dev-923-g4c9a150
texture.c File Reference
#include "wine/debug.h"
#include "d3d10_1.h"
#include "d3dx10.h"
#include "wincodec.h"
#include "dxhelpers.h"
Include dependency graph for texture.c:

Go to the source code of this file.

Macros

#define COBJMACROS
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (d3dx)
 
HRESULT WINAPI WICCreateImagingFactory_Proxy (UINT sdk_version, IWICImagingFactory **imaging_factory)
 
static D3DX10_IMAGE_FILE_FORMAT wic_container_guid_to_file_format (GUID *container_format)
 
static const GUID * dxgi_format_to_wic_guid (DXGI_FORMAT format)
 
static D3D10_RESOURCE_DIMENSION wic_dimension_to_d3dx10_dimension (WICDdsDimension wic_dimension)
 
static unsigned int get_bpp_from_format (DXGI_FORMAT format)
 
static DXGI_FORMAT get_d3dx10_dds_format (DXGI_FORMAT format)
 
HRESULT WINAPI D3DX10GetImageInfoFromFileA (const char *src_file, ID3DX10ThreadPump *pump, D3DX10_IMAGE_INFO *info, HRESULT *result)
 
HRESULT WINAPI D3DX10GetImageInfoFromFileW (const WCHAR *src_file, ID3DX10ThreadPump *pump, D3DX10_IMAGE_INFO *info, HRESULT *result)
 
HRESULT WINAPI D3DX10GetImageInfoFromResourceA (HMODULE module, const char *resource, ID3DX10ThreadPump *pump, D3DX10_IMAGE_INFO *info, HRESULT *result)
 
HRESULT WINAPI D3DX10GetImageInfoFromResourceW (HMODULE module, const WCHAR *resource, ID3DX10ThreadPump *pump, D3DX10_IMAGE_INFO *info, HRESULT *result)
 
HRESULT get_image_info (const void *data, SIZE_T size, D3DX10_IMAGE_INFO *img_info)
 
HRESULT WINAPI D3DX10GetImageInfoFromMemory (const void *src_data, SIZE_T src_data_size, ID3DX10ThreadPump *pump, D3DX10_IMAGE_INFO *img_info, HRESULT *result)
 
static HRESULT create_texture (ID3D10Device *device, const void *data, SIZE_T size, D3DX10_IMAGE_LOAD_INFO *load_info, ID3D10Resource **texture)
 
HRESULT WINAPI D3DX10CreateTextureFromFileA (ID3D10Device *device, const char *src_file, D3DX10_IMAGE_LOAD_INFO *load_info, ID3DX10ThreadPump *pump, ID3D10Resource **texture, HRESULT *hresult)
 
HRESULT WINAPI D3DX10CreateTextureFromFileW (ID3D10Device *device, const WCHAR *src_file, D3DX10_IMAGE_LOAD_INFO *load_info, ID3DX10ThreadPump *pump, ID3D10Resource **texture, HRESULT *hresult)
 
HRESULT WINAPI D3DX10CreateTextureFromResourceA (ID3D10Device *device, HMODULE module, const char *resource, D3DX10_IMAGE_LOAD_INFO *load_info, ID3DX10ThreadPump *pump, ID3D10Resource **texture, HRESULT *hresult)
 
HRESULT WINAPI D3DX10CreateTextureFromResourceW (ID3D10Device *device, HMODULE module, const WCHAR *resource, D3DX10_IMAGE_LOAD_INFO *load_info, ID3DX10ThreadPump *pump, ID3D10Resource **texture, HRESULT *hresult)
 
void init_load_info (const D3DX10_IMAGE_LOAD_INFO *load_info, D3DX10_IMAGE_LOAD_INFO *out)
 
static HRESULT dds_get_frame_info (IWICDdsFrameDecode *frame, const D3DX10_IMAGE_INFO *img_info, WICDdsFormatInfo *format_info, unsigned int *stride, unsigned int *frame_size)
 
static HRESULT convert_image (IWICImagingFactory *factory, IWICBitmapFrameDecode *frame, const GUID *dst_format, unsigned int stride, unsigned int frame_size, BYTE *buffer)
 
HRESULT load_texture_data (const void *data, SIZE_T size, D3DX10_IMAGE_LOAD_INFO *load_info, D3D10_SUBRESOURCE_DATA **resource_data)
 
HRESULT create_d3d_texture (ID3D10Device *device, D3DX10_IMAGE_LOAD_INFO *load_info, D3D10_SUBRESOURCE_DATA *resource_data, ID3D10Resource **texture)
 
HRESULT WINAPI D3DX10CreateTextureFromMemory (ID3D10Device *device, const void *src_data, SIZE_T src_data_size, D3DX10_IMAGE_LOAD_INFO *load_info, ID3DX10ThreadPump *pump, ID3D10Resource **texture, HRESULT *hresult)
 

Variables

struct {
   const GUID *   wic_container_guid
 
   D3DX10_IMAGE_FILE_FORMAT   d3dx_file_format
 
} file_formats []
 
struct {
   const GUID *   wic_guid
 
   DXGI_FORMAT   dxgi_format
 
} wic_pixel_formats []
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 21 of file texture.c.

Function Documentation

◆ convert_image()

static HRESULT convert_image ( IWICImagingFactory *  factory,
IWICBitmapFrameDecode *  frame,
const GUID *  dst_format,
unsigned int  stride,
unsigned int  frame_size,
BYTE *  buffer 
)
static

Definition at line 779 of file texture.c.

781{
782 IWICFormatConverter *converter;
783 BOOL can_convert;
784 GUID src_format;
785 HRESULT hr;
786
787 if (FAILED(hr = IWICBitmapFrameDecode_GetPixelFormat(frame, &src_format)))
788 return hr;
789
790 if (IsEqualGUID(&src_format, dst_format))
791 {
792 if (FAILED(hr = IWICBitmapFrameDecode_CopyPixels(frame, NULL, stride, frame_size, buffer)))
793 return hr;
794 return S_OK;
795 }
796
797 if (FAILED(hr = IWICImagingFactory_CreateFormatConverter(factory, &converter)))
798 return hr;
799 if (FAILED(hr = IWICFormatConverter_CanConvert(converter, &src_format, dst_format, &can_convert)))
800 {
801 IWICFormatConverter_Release(converter);
802 return hr;
803 }
804 if (!can_convert)
805 {
806 WARN("Format converting %s to %s is not supported by WIC.\n",
807 debugstr_guid(&src_format), debugstr_guid(dst_format));
808 IWICFormatConverter_Release(converter);
809 return E_NOTIMPL;
810 }
811 if (FAILED(hr = IWICFormatConverter_Initialize(converter, (IWICBitmapSource *)frame, dst_format,
813 {
814 IWICFormatConverter_Release(converter);
815 return hr;
816 }
817 hr = IWICFormatConverter_CopyPixels(converter, NULL, stride, frame_size, buffer);
818 IWICFormatConverter_Release(converter);
819 return hr;
820}
#define WARN(fmt,...)
Definition: precomp.h:61
#define E_NOTIMPL
Definition: ddrawi.h:99
HRESULT hr
Definition: delayimp.cpp:582
#define NULL
Definition: types.h:112
unsigned int BOOL
Definition: ntddk_ex.h:94
GLsizei stride
Definition: glext.h:5848
GLuint buffer
Definition: glext.h:5915
#define S_OK
Definition: intsafe.h:52
#define FAILED(hr)
Definition: intsafe.h:51
#define debugstr_guid
Definition: kernel32.h:35
static const char * dst_format
Definition: dib.c:1339
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
Definition: main.c:439
@ WICBitmapDitherTypeErrorDiffusion
Definition: wincodec.idl:66
@ WICBitmapPaletteTypeCustom
Definition: wincodec.idl:92

Referenced by load_texture_data().

◆ create_d3d_texture()

HRESULT create_d3d_texture ( ID3D10Device *  device,
D3DX10_IMAGE_LOAD_INFO *  load_info,
D3D10_SUBRESOURCE_DATA *  resource_data,
ID3D10Resource **  texture 
)

Definition at line 1027 of file texture.c.

1029{
1030 D3D10_TEXTURE2D_DESC texture_2d_desc;
1031 ID3D10Texture2D *texture_2d;
1032 HRESULT hr;
1033
1034 memset(&texture_2d_desc, 0, sizeof(texture_2d_desc));
1035 texture_2d_desc.Width = load_info->Width;
1036 texture_2d_desc.Height = load_info->Height;
1037 texture_2d_desc.MipLevels = load_info->MipLevels;
1038 texture_2d_desc.ArraySize = load_info->MiscFlags & D3D10_RESOURCE_MISC_TEXTURECUBE ? 6 : 1;
1039 texture_2d_desc.Format = load_info->Format;
1040 texture_2d_desc.SampleDesc.Count = 1;
1041 texture_2d_desc.Usage = load_info->Usage;
1042 texture_2d_desc.BindFlags = load_info->BindFlags;
1043 texture_2d_desc.MiscFlags = load_info->MiscFlags;
1044
1045 if (FAILED(hr = ID3D10Device_CreateTexture2D(device, &texture_2d_desc, resource_data, &texture_2d)))
1046 return hr;
1047
1048 *texture = (ID3D10Resource *)texture_2d;
1049 return S_OK;
1050}
@ D3D10_RESOURCE_MISC_TEXTURECUBE
Definition: d3d10.idl:890
GLenum GLuint texture
Definition: glext.h:6295
#define memset(x, y, z)
Definition: compat.h:39
DXGI_FORMAT Format
Definition: d3d10.idl:550
DXGI_SAMPLE_DESC SampleDesc
Definition: d3d10.idl:551
D3D10_USAGE Usage
Definition: d3d10.idl:552
DXGI_FORMAT Format
Definition: d3dx10tex.h:81
D3D10_USAGE Usage
Definition: d3dx10tex.h:77
Definition: devices.h:37

Referenced by create_texture(), and texture_processor_CreateDeviceObject().

◆ create_texture()

static HRESULT create_texture ( ID3D10Device *  device,
const void *  data,
SIZE_T  size,
D3DX10_IMAGE_LOAD_INFO *  load_info,
ID3D10Resource **  texture 
)
static

Definition at line 558 of file texture.c.

560{
562 D3DX10_IMAGE_LOAD_INFO load_info_copy;
563 HRESULT hr;
564
565 init_load_info(load_info, &load_info_copy);
566
567 if (FAILED((hr = load_texture_data(data, size, &load_info_copy, &resource_data))))
568 return hr;
569 hr = create_d3d_texture(device, &load_info_copy, resource_data, texture);
571 return hr;
572}
#define free
Definition: debug_ros.c:5
HRESULT load_texture_data(const void *data, SIZE_T size, D3DX10_IMAGE_LOAD_INFO *load_info, D3D10_SUBRESOURCE_DATA **resource_data)
Definition: texture.c:822
HRESULT create_d3d_texture(ID3D10Device *device, D3DX10_IMAGE_LOAD_INFO *load_info, D3D10_SUBRESOURCE_DATA *resource_data, ID3D10Resource **texture)
Definition: texture.c:1027
void init_load_info(const D3DX10_IMAGE_LOAD_INFO *load_info, D3DX10_IMAGE_LOAD_INFO *out)
Definition: texture.c:730
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLsizeiptr size
Definition: glext.h:5919

Referenced by D3DX10CreateTextureFromFileW(), D3DX10CreateTextureFromMemory(), D3DX10CreateTextureFromResourceA(), and D3DX10CreateTextureFromResourceW().

◆ D3DX10CreateTextureFromFileA()

HRESULT WINAPI D3DX10CreateTextureFromFileA ( ID3D10Device *  device,
const char *  src_file,
D3DX10_IMAGE_LOAD_INFO *  load_info,
ID3DX10ThreadPump *  pump,
ID3D10Resource **  texture,
HRESULT *  hresult 
)

Definition at line 574 of file texture.c.

576{
577 WCHAR *buffer;
578 int str_len;
579 HRESULT hr;
580
581 TRACE("device %p, src_file %s, load_info %p, pump %p, texture %p, hresult %p.\n",
582 device, debugstr_a(src_file), load_info, pump, texture, hresult);
583
584 if (!device)
585 return E_INVALIDARG;
586 if (!src_file)
587 return E_FAIL;
588
589 if (!(str_len = MultiByteToWideChar(CP_ACP, 0, src_file, -1, NULL, 0)))
591
592 if (!(buffer = malloc(str_len * sizeof(*buffer))))
593 return E_OUTOFMEMORY;
594
595 MultiByteToWideChar(CP_ACP, 0, src_file, -1, buffer, str_len);
596 hr = D3DX10CreateTextureFromFileW(device, buffer, load_info, pump, texture, hresult);
597
598 free(buffer);
599
600 return hr;
601}
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_INVALIDARG
Definition: ddrawi.h:101
#define E_FAIL
Definition: ddrawi.h:102
#define malloc
Definition: debug_ros.c:4
HRESULT WINAPI D3DX10CreateTextureFromFileW(ID3D10Device *device, const WCHAR *src_file, D3DX10_IMAGE_LOAD_INFO *load_info, ID3DX10ThreadPump *pump, ID3D10Resource **texture, HRESULT *hresult)
Definition: texture.c:603
#define CP_ACP
Definition: compat.h:109
#define MultiByteToWideChar
Definition: compat.h:110
#define debugstr_a
Definition: kernel32.h:31
short WCHAR
Definition: pedump.c:58
#define TRACE(s)
Definition: solgame.cpp:4
#define str_len
Definition: treelist.c:89
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
static HRESULT HRESULT_FROM_WIN32(unsigned int x)
Definition: winerror.h:210

◆ D3DX10CreateTextureFromFileW()

HRESULT WINAPI D3DX10CreateTextureFromFileW ( ID3D10Device *  device,
const WCHAR *  src_file,
D3DX10_IMAGE_LOAD_INFO *  load_info,
ID3DX10ThreadPump *  pump,
ID3D10Resource **  texture,
HRESULT *  hresult 
)

Definition at line 603 of file texture.c.

605{
606 void *buffer = NULL;
607 DWORD size = 0;
608 HRESULT hr;
609
610 TRACE("device %p, src_file %s, load_info %p, pump %p, texture %p, hresult %p.\n",
611 device, debugstr_w(src_file), load_info, pump, texture, hresult);
612
613 if (!device)
614 return E_INVALIDARG;
615 if (!src_file)
616 return E_FAIL;
617
618 if (pump)
619 {
620 ID3DX10DataProcessor *processor;
621 ID3DX10DataLoader *loader;
622
623 if (FAILED((hr = D3DX10CreateAsyncFileLoaderW(src_file, &loader))))
624 return hr;
625 if (FAILED((hr = D3DX10CreateAsyncTextureProcessor(device, load_info, &processor))))
626 {
628 return hr;
629 }
630 if (FAILED((hr = ID3DX10ThreadPump_AddWorkItem(pump, loader, processor, hresult, (void **)texture))))
631 {
634 }
635 return hr;
636 }
637
638 if (SUCCEEDED((hr = load_file(src_file, &buffer, &size))))
639 {
640 hr = create_texture(device, buffer, size, load_info, texture);
641 free(buffer);
642 }
643 if (hresult)
644 *hresult = hr;
645 return hr;
646}
#define ID3DX10ThreadPump_AddWorkItem(p, a, b, c, d)
Definition: d3dx10core.h:141
#define ID3DX10DataLoader_Destroy(p)
Definition: d3dx10core.h:88
#define ID3DX10DataProcessor_Destroy(p)
Definition: d3dx10core.h:109
HRESULT WINAPI D3DX10CreateAsyncTextureProcessor(ID3D10Device *device, D3DX10_IMAGE_LOAD_INFO *load_info, ID3DX10DataProcessor **processor)
Definition: async.c:580
HRESULT WINAPI D3DX10CreateAsyncFileLoaderW(const WCHAR *filename, ID3DX10DataLoader **loader)
Definition: async.c:467
HRESULT load_file(const WCHAR *path, void **data, DWORD *size)
Definition: async.c:91
static HRESULT create_texture(ID3D10Device *device, const void *data, SIZE_T size, D3DX10_IMAGE_LOAD_INFO *load_info, ID3D10Resource **texture)
Definition: texture.c:558
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define debugstr_w
Definition: kernel32.h:32
Definition: loader.c:72

Referenced by D3DX10CreateTextureFromFileA().

◆ D3DX10CreateTextureFromMemory()

HRESULT WINAPI D3DX10CreateTextureFromMemory ( ID3D10Device *  device,
const void *  src_data,
SIZE_T  src_data_size,
D3DX10_IMAGE_LOAD_INFO *  load_info,
ID3DX10ThreadPump *  pump,
ID3D10Resource **  texture,
HRESULT *  hresult 
)

Definition at line 1052 of file texture.c.

1054{
1055 HRESULT hr;
1056
1057 TRACE("device %p, src_data %p, src_data_size %Iu, load_info %p, pump %p, texture %p, hresult %p.\n",
1058 device, src_data, src_data_size, load_info, pump, texture, hresult);
1059
1060 if (!device)
1061 return E_INVALIDARG;
1062 if (!src_data)
1063 return E_FAIL;
1064
1065 if (pump)
1066 {
1067 ID3DX10DataProcessor *processor;
1068 ID3DX10DataLoader *loader;
1069
1070 if (FAILED((hr = D3DX10CreateAsyncMemoryLoader(src_data, src_data_size, &loader))))
1071 return hr;
1072 if (FAILED((hr = D3DX10CreateAsyncTextureProcessor(device, load_info, &processor))))
1073 {
1075 return hr;
1076 }
1077 if (FAILED((hr = ID3DX10ThreadPump_AddWorkItem(pump, loader, processor, hresult, (void **)texture))))
1078 {
1081 }
1082 return hr;
1083 }
1084
1085 hr = create_texture(device, src_data, src_data_size, load_info, texture);
1086 if (hresult)
1087 *hresult = hr;
1088 return hr;
1089}
HRESULT WINAPI D3DX10CreateAsyncMemoryLoader(const void *data, SIZE_T data_size, ID3DX10DataLoader **loader)
Definition: async.c:423

◆ D3DX10CreateTextureFromResourceA()

HRESULT WINAPI D3DX10CreateTextureFromResourceA ( ID3D10Device *  device,
HMODULE  module,
const char *  resource,
D3DX10_IMAGE_LOAD_INFO *  load_info,
ID3DX10ThreadPump *  pump,
ID3D10Resource **  texture,
HRESULT *  hresult 
)

Definition at line 648 of file texture.c.

650{
651 void *buffer;
652 DWORD size;
653 HRESULT hr;
654
655 TRACE("device %p, module %p, resource %s, load_info %p, pump %p, texture %p, hresult %p.\n",
656 device, module, debugstr_a(resource), load_info, pump, texture, hresult);
657
658 if (!device)
659 return E_INVALIDARG;
660
661 if (pump)
662 {
663 ID3DX10DataProcessor *processor;
664 ID3DX10DataLoader *loader;
665
667 return hr;
668 if (FAILED((hr = D3DX10CreateAsyncTextureProcessor(device, load_info, &processor))))
669 {
671 return hr;
672 }
673 if (FAILED((hr = ID3DX10ThreadPump_AddWorkItem(pump, loader, processor, hresult, (void **)texture))))
674 {
677 }
678 return hr;
679 }
680
682 return hr;
683 hr = create_texture(device, buffer, size, load_info, texture);
684 if (hresult)
685 *hresult = hr;
686 return hr;
687}
HRESULT load_resourceA(HMODULE module, const char *resource, void **data, DWORD *size)
Definition: async.c:213
HRESULT WINAPI D3DX10CreateAsyncResourceLoaderA(HMODULE module, const char *resource, ID3DX10DataLoader **loader)
Definition: async.c:496

◆ D3DX10CreateTextureFromResourceW()

HRESULT WINAPI D3DX10CreateTextureFromResourceW ( ID3D10Device *  device,
HMODULE  module,
const WCHAR *  resource,
D3DX10_IMAGE_LOAD_INFO *  load_info,
ID3DX10ThreadPump *  pump,
ID3D10Resource **  texture,
HRESULT *  hresult 
)

Definition at line 689 of file texture.c.

691{
692 void *buffer;
693 DWORD size;
694 HRESULT hr;
695
696 TRACE("device %p, module %p, resource %s, load_info %p, pump %p, texture %p, hresult %p.\n",
697 device, module, debugstr_w(resource), load_info, pump, texture, hresult);
698
699 if (!device)
700 return E_INVALIDARG;
701
702 if (pump)
703 {
704 ID3DX10DataProcessor *processor;
705 ID3DX10DataLoader *loader;
706
708 return hr;
709 if (FAILED((hr = D3DX10CreateAsyncTextureProcessor(device, load_info, &processor))))
710 {
712 return hr;
713 }
714 if (FAILED((hr = ID3DX10ThreadPump_AddWorkItem(pump, loader, processor, hresult, (void **)texture))))
715 {
718 }
719 return hr;
720 }
721
723 return hr;
724 hr = create_texture(device, buffer, size, load_info, texture);
725 if (hresult)
726 *hresult = hr;
727 return hr;
728}
HRESULT load_resourceW(HMODULE module, const WCHAR *resource, void **data, DWORD *size)
Definition: async.c:223
HRESULT WINAPI D3DX10CreateAsyncResourceLoaderW(HMODULE module, const WCHAR *resource, ID3DX10DataLoader **loader)
Definition: async.c:528

◆ D3DX10GetImageInfoFromFileA()

HRESULT WINAPI D3DX10GetImageInfoFromFileA ( const char *  src_file,
ID3DX10ThreadPump *  pump,
D3DX10_IMAGE_INFO *  info,
HRESULT *  result 
)

Definition at line 279 of file texture.c.

281{
282 WCHAR *buffer;
283 int str_len;
284 HRESULT hr;
285
286 TRACE("src_file %s, pump %p, info %p, result %p.\n", debugstr_a(src_file), pump, info, result);
287
288 if (!src_file)
289 return E_FAIL;
290
291 str_len = MultiByteToWideChar(CP_ACP, 0, src_file, -1, NULL, 0);
292 if (!str_len)
294
295 buffer = malloc(str_len * sizeof(*buffer));
296 if (!buffer)
297 return E_OUTOFMEMORY;
298
299 MultiByteToWideChar(CP_ACP, 0, src_file, -1, buffer, str_len);
301
302 free(buffer);
303
304 return hr;
305}
HRESULT WINAPI D3DX10GetImageInfoFromFileW(const WCHAR *src_file, ID3DX10ThreadPump *pump, D3DX10_IMAGE_INFO *info, HRESULT *result)
Definition: texture.c:307
GLuint64EXT * result
Definition: glext.h:11304

◆ D3DX10GetImageInfoFromFileW()

HRESULT WINAPI D3DX10GetImageInfoFromFileW ( const WCHAR *  src_file,
ID3DX10ThreadPump *  pump,
D3DX10_IMAGE_INFO *  info,
HRESULT *  result 
)

Definition at line 307 of file texture.c.

309{
310 void *buffer = NULL;
311 DWORD size = 0;
312 HRESULT hr;
313
314 TRACE("src_file %s, pump %p, info %p, result %p.\n", debugstr_w(src_file), pump, info, result);
315
316 if (!src_file)
317 return E_FAIL;
318
319 if (pump)
320 {
321 ID3DX10DataProcessor *processor;
322 ID3DX10DataLoader *loader;
323
324 if (FAILED((hr = D3DX10CreateAsyncFileLoaderW(src_file, &loader))))
325 return hr;
327 {
329 return hr;
330 }
331 hr = ID3DX10ThreadPump_AddWorkItem(pump, loader, processor, result, NULL);
332 if (FAILED(hr))
333 {
336 }
337 return hr;
338 }
339
340 if (SUCCEEDED((hr = load_file(src_file, &buffer, &size))))
341 {
343 free(buffer);
344 }
345 if (result)
346 *result = hr;
347 return hr;
348}
HRESULT WINAPI D3DX10CreateAsyncTextureInfoProcessor(D3DX10_IMAGE_INFO *info, ID3DX10DataProcessor **processor)
Definition: async.c:560
HRESULT get_image_info(const void *data, SIZE_T size, D3DX10_IMAGE_INFO *img_info)
Definition: texture.c:426

Referenced by D3DX10GetImageInfoFromFileA().

◆ D3DX10GetImageInfoFromMemory()

HRESULT WINAPI D3DX10GetImageInfoFromMemory ( const void *  src_data,
SIZE_T  src_data_size,
ID3DX10ThreadPump *  pump,
D3DX10_IMAGE_INFO *  img_info,
HRESULT *  result 
)

Definition at line 521 of file texture.c.

523{
524 HRESULT hr;
525
526 TRACE("src_data %p, src_data_size %Iu, pump %p, img_info %p, hresult %p.\n",
527 src_data, src_data_size, pump, img_info, result);
528
529 if (!src_data)
530 return E_FAIL;
531
532 if (pump)
533 {
534 ID3DX10DataProcessor *processor;
535 ID3DX10DataLoader *loader;
536
537 if (FAILED((hr = D3DX10CreateAsyncMemoryLoader(src_data, src_data_size, &loader))))
538 return hr;
539 if (FAILED((hr = D3DX10CreateAsyncTextureInfoProcessor(img_info, &processor))))
540 {
542 return hr;
543 }
544 if (FAILED((hr = ID3DX10ThreadPump_AddWorkItem(pump, loader, processor, result, NULL))))
545 {
548 }
549 return hr;
550 }
551
552 hr = get_image_info(src_data, src_data_size, img_info);
553 if (result)
554 *result = hr;
555 return hr;
556}

Referenced by load_texture_data().

◆ D3DX10GetImageInfoFromResourceA()

HRESULT WINAPI D3DX10GetImageInfoFromResourceA ( HMODULE  module,
const char *  resource,
ID3DX10ThreadPump *  pump,
D3DX10_IMAGE_INFO *  info,
HRESULT *  result 
)

Definition at line 350 of file texture.c.

352{
353 void *buffer;
354 HRESULT hr;
355 DWORD size;
356
357 TRACE("module %p, resource %s, pump %p, info %p, result %p.\n",
359
360 if (pump)
361 {
362 ID3DX10DataProcessor *processor;
363 ID3DX10DataLoader *loader;
364
366 return hr;
368 {
370 return hr;
371 }
372 if (FAILED((hr = ID3DX10ThreadPump_AddWorkItem(pump, loader, processor, result, NULL))))
373 {
376 }
377 return hr;
378 }
379
381 return hr;
383 if (result)
384 *result = hr;
385 return hr;
386}

◆ D3DX10GetImageInfoFromResourceW()

HRESULT WINAPI D3DX10GetImageInfoFromResourceW ( HMODULE  module,
const WCHAR *  resource,
ID3DX10ThreadPump *  pump,
D3DX10_IMAGE_INFO *  info,
HRESULT *  result 
)

Definition at line 388 of file texture.c.

390{
391 void *buffer;
392 HRESULT hr;
393 DWORD size;
394
395 TRACE("module %p, resource %s, pump %p, info %p, result %p.\n",
397
398 if (pump)
399 {
400 ID3DX10DataProcessor *processor;
401 ID3DX10DataLoader *loader;
402
404 return hr;
406 {
408 return hr;
409 }
410 if (FAILED((hr = ID3DX10ThreadPump_AddWorkItem(pump, loader, processor, result, NULL))))
411 {
414 }
415 return hr;
416 }
417
419 return hr;
421 if (result)
422 *result = hr;
423 return hr;
424}

◆ dds_get_frame_info()

static HRESULT dds_get_frame_info ( IWICDdsFrameDecode *  frame,
const D3DX10_IMAGE_INFO *  img_info,
WICDdsFormatInfo *  format_info,
unsigned int *  stride,
unsigned int *  frame_size 
)
static

Definition at line 753 of file texture.c.

755{
756 unsigned int width, height;
757 HRESULT hr;
758
759 if (FAILED(hr = IWICDdsFrameDecode_GetFormatInfo(frame, format_info)))
760 return hr;
761 if (FAILED(hr = IWICDdsFrameDecode_GetSizeInBlocks(frame, &width, &height)))
762 return hr;
763
764 if (img_info->Format == format_info->DxgiFormat)
765 {
766 *stride = width * format_info->BytesPerBlock;
767 *frame_size = *stride * height;
768 }
769 else
770 {
771 width *= format_info->BlockWidth;
772 height *= format_info->BlockHeight;
773 *stride = (width * get_bpp_from_format(img_info->Format) + 7) / 8;
774 *frame_size = *stride * height;
775 }
776 return S_OK;
777}
format_info
static unsigned int get_bpp_from_format(DXGI_FORMAT format)
Definition: texture.c:115
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLint GLint GLsizei width
Definition: gl.h:1546
DXGI_FORMAT Format
Definition: d3dx10tex.h:65

Referenced by load_texture_data().

◆ dxgi_format_to_wic_guid()

static const GUID * dxgi_format_to_wic_guid ( DXGI_FORMAT  format)
static

Definition at line 86 of file texture.c.

87{
88 unsigned int i;
89
90 for (i = 0; i < ARRAY_SIZE(wic_pixel_formats); ++i)
91 {
93 return wic_pixel_formats[i].wic_guid;
94 }
95
96 return NULL;
97}
#define ARRAY_SIZE(A)
Definition: main.h:20
DXGI_FORMAT dxgi_format
Definition: texture.c:51
static const struct @278 wic_pixel_formats[]
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248

Referenced by load_texture_data().

◆ get_bpp_from_format()

static unsigned int get_bpp_from_format ( DXGI_FORMAT  format)
static

Definition at line 115 of file texture.c.

116{
117 switch (format)
118 {
123 return 128;
128 return 96;
143 case DXGI_FORMAT_Y416:
144 case DXGI_FORMAT_Y210:
145 case DXGI_FORMAT_Y216:
146 return 64;
182 case DXGI_FORMAT_AYUV:
183 case DXGI_FORMAT_Y410:
184 case DXGI_FORMAT_YUY2:
185 return 32;
186 case DXGI_FORMAT_P010:
187 case DXGI_FORMAT_P016:
188 return 24;
203 case DXGI_FORMAT_A8P8:
205 return 16;
206 case DXGI_FORMAT_NV12:
208 case DXGI_FORMAT_NV11:
209 return 12;
216 case DXGI_FORMAT_AI44:
217 case DXGI_FORMAT_IA44:
218 case DXGI_FORMAT_P8:
234 return 8;
241 return 4;
243 return 1;
244 default:
245 return 0;
246 }
247}
@ DXGI_FORMAT_R16_UINT
Definition: dxgiformat.idl:80
@ DXGI_FORMAT_B8G8R8A8_UNORM
Definition: dxgiformat.idl:110
@ DXGI_FORMAT_R8_TYPELESS
Definition: dxgiformat.idl:83
@ DXGI_FORMAT_Y410
Definition: dxgiformat.idl:124
@ DXGI_FORMAT_BC3_UNORM_SRGB
Definition: dxgiformat.idl:101
@ DXGI_FORMAT_R8G8_B8G8_UNORM
Definition: dxgiformat.idl:91
@ DXGI_FORMAT_R32G32B32_TYPELESS
Definition: dxgiformat.idl:28
@ DXGI_FORMAT_BC3_TYPELESS
Definition: dxgiformat.idl:99
@ DXGI_FORMAT_R16G16_SNORM
Definition: dxgiformat.idl:60
@ DXGI_FORMAT_D32_FLOAT_S8X24_UINT
Definition: dxgiformat.idl:43
@ DXGI_FORMAT_R32G32B32A32_SINT
Definition: dxgiformat.idl:27
@ DXGI_FORMAT_BC5_UNORM
Definition: dxgiformat.idl:106
@ DXGI_FORMAT_Y216
Definition: dxgiformat.idl:132
@ DXGI_FORMAT_BC1_UNORM
Definition: dxgiformat.idl:94
@ DXGI_FORMAT_R8G8_UINT
Definition: dxgiformat.idl:73
@ DXGI_FORMAT_420_OPAQUE
Definition: dxgiformat.idl:129
@ DXGI_FORMAT_R32G32B32A32_UINT
Definition: dxgiformat.idl:26
@ DXGI_FORMAT_R16G16B16A16_SNORM
Definition: dxgiformat.idl:36
@ DXGI_FORMAT_R32_FLOAT
Definition: dxgiformat.idl:64
@ DXGI_FORMAT_R16G16B16A16_UNORM
Definition: dxgiformat.idl:34
@ DXGI_FORMAT_R32_SINT
Definition: dxgiformat.idl:66
@ DXGI_FORMAT_R8G8_UNORM
Definition: dxgiformat.idl:72
@ DXGI_FORMAT_R16G16_UNORM
Definition: dxgiformat.idl:58
@ DXGI_FORMAT_BC1_UNORM_SRGB
Definition: dxgiformat.idl:95
@ DXGI_FORMAT_A8P8
Definition: dxgiformat.idl:137
@ DXGI_FORMAT_R16G16_SINT
Definition: dxgiformat.idl:61
@ DXGI_FORMAT_R24_UNORM_X8_TYPELESS
Definition: dxgiformat.idl:69
@ DXGI_FORMAT_R8G8B8A8_TYPELESS
Definition: dxgiformat.idl:50
@ DXGI_FORMAT_BC2_TYPELESS
Definition: dxgiformat.idl:96
@ DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS
Definition: dxgiformat.idl:44
@ DXGI_FORMAT_R32G32B32_FLOAT
Definition: dxgiformat.idl:29
@ DXGI_FORMAT_R32G32B32_SINT
Definition: dxgiformat.idl:31
@ DXGI_FORMAT_R32G32B32A32_TYPELESS
Definition: dxgiformat.idl:24
@ DXGI_FORMAT_B8G8R8A8_UNORM_SRGB
Definition: dxgiformat.idl:114
@ DXGI_FORMAT_B8G8R8X8_TYPELESS
Definition: dxgiformat.idl:115
@ DXGI_FORMAT_B8G8R8A8_TYPELESS
Definition: dxgiformat.idl:113
@ DXGI_FORMAT_X24_TYPELESS_G8_UINT
Definition: dxgiformat.idl:70
@ DXGI_FORMAT_R16_SINT
Definition: dxgiformat.idl:82
@ DXGI_FORMAT_R1_UNORM
Definition: dxgiformat.idl:89
@ DXGI_FORMAT_R16G16B16A16_UINT
Definition: dxgiformat.idl:35
@ DXGI_FORMAT_R16_UNORM
Definition: dxgiformat.idl:79
@ DXGI_FORMAT_R8G8B8A8_SINT
Definition: dxgiformat.idl:55
@ DXGI_FORMAT_D24_UNORM_S8_UINT
Definition: dxgiformat.idl:68
@ DXGI_FORMAT_R8G8B8A8_SNORM
Definition: dxgiformat.idl:54
@ DXGI_FORMAT_A8_UNORM
Definition: dxgiformat.idl:88
@ DXGI_FORMAT_R8G8B8A8_UINT
Definition: dxgiformat.idl:53
@ DXGI_FORMAT_R10G10B10A2_TYPELESS
Definition: dxgiformat.idl:46
@ DXGI_FORMAT_R32G32_FLOAT
Definition: dxgiformat.idl:39
@ DXGI_FORMAT_BC6H_UF16
Definition: dxgiformat.idl:118
@ DXGI_FORMAT_BC6H_SF16
Definition: dxgiformat.idl:119
@ DXGI_FORMAT_R10G10B10A2_UNORM
Definition: dxgiformat.idl:47
@ DXGI_FORMAT_R8_SNORM
Definition: dxgiformat.idl:86
@ DXGI_FORMAT_R9G9B9E5_SHAREDEXP
Definition: dxgiformat.idl:90
@ DXGI_FORMAT_P010
Definition: dxgiformat.idl:127
@ DXGI_FORMAT_R16G16B16A16_TYPELESS
Definition: dxgiformat.idl:32
@ DXGI_FORMAT_R16G16B16A16_FLOAT
Definition: dxgiformat.idl:33
@ DXGI_FORMAT_BC7_TYPELESS
Definition: dxgiformat.idl:120
@ DXGI_FORMAT_P016
Definition: dxgiformat.idl:128
@ DXGI_FORMAT_R32_TYPELESS
Definition: dxgiformat.idl:62
@ DXGI_FORMAT_R8_UNORM
Definition: dxgiformat.idl:84
@ DXGI_FORMAT_R32G32_UINT
Definition: dxgiformat.idl:40
@ DXGI_FORMAT_R11G11B10_FLOAT
Definition: dxgiformat.idl:49
@ DXGI_FORMAT_R8G8B8A8_UNORM
Definition: dxgiformat.idl:51
@ DXGI_FORMAT_AYUV
Definition: dxgiformat.idl:123
@ DXGI_FORMAT_Y416
Definition: dxgiformat.idl:125
@ DXGI_FORMAT_G8R8_G8B8_UNORM
Definition: dxgiformat.idl:92
@ DXGI_FORMAT_YUY2
Definition: dxgiformat.idl:130
@ DXGI_FORMAT_D16_UNORM
Definition: dxgiformat.idl:78
@ DXGI_FORMAT_R16_FLOAT
Definition: dxgiformat.idl:77
@ DXGI_FORMAT_Y210
Definition: dxgiformat.idl:131
@ DXGI_FORMAT_R10G10B10A2_UINT
Definition: dxgiformat.idl:48
@ DXGI_FORMAT_BC6H_TYPELESS
Definition: dxgiformat.idl:117
@ DXGI_FORMAT_BC7_UNORM
Definition: dxgiformat.idl:121
@ DXGI_FORMAT_BC5_TYPELESS
Definition: dxgiformat.idl:105
@ DXGI_FORMAT_R32G32_SINT
Definition: dxgiformat.idl:41
@ DXGI_FORMAT_BC2_UNORM_SRGB
Definition: dxgiformat.idl:98
@ DXGI_FORMAT_R16_SNORM
Definition: dxgiformat.idl:81
@ DXGI_FORMAT_R8_SINT
Definition: dxgiformat.idl:87
@ DXGI_FORMAT_BC5_SNORM
Definition: dxgiformat.idl:107
@ DXGI_FORMAT_R32_UINT
Definition: dxgiformat.idl:65
@ DXGI_FORMAT_BC4_TYPELESS
Definition: dxgiformat.idl:102
@ DXGI_FORMAT_R32G32B32A32_FLOAT
Definition: dxgiformat.idl:25
@ DXGI_FORMAT_R24G8_TYPELESS
Definition: dxgiformat.idl:67
@ DXGI_FORMAT_IA44
Definition: dxgiformat.idl:135
@ DXGI_FORMAT_NV11
Definition: dxgiformat.idl:133
@ DXGI_FORMAT_R8G8_SINT
Definition: dxgiformat.idl:75
@ DXGI_FORMAT_R16_TYPELESS
Definition: dxgiformat.idl:76
@ DXGI_FORMAT_BC3_UNORM
Definition: dxgiformat.idl:100
@ DXGI_FORMAT_R32G32B32_UINT
Definition: dxgiformat.idl:30
@ DXGI_FORMAT_R16G16_TYPELESS
Definition: dxgiformat.idl:56
@ DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
Definition: dxgiformat.idl:52
@ DXGI_FORMAT_R16G16_UINT
Definition: dxgiformat.idl:59
@ DXGI_FORMAT_D32_FLOAT
Definition: dxgiformat.idl:63
@ DXGI_FORMAT_R8G8_TYPELESS
Definition: dxgiformat.idl:71
@ DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM
Definition: dxgiformat.idl:112
@ DXGI_FORMAT_R16G16B16A16_SINT
Definition: dxgiformat.idl:37
@ DXGI_FORMAT_BC1_TYPELESS
Definition: dxgiformat.idl:93
@ DXGI_FORMAT_BC7_UNORM_SRGB
Definition: dxgiformat.idl:122
@ DXGI_FORMAT_BC2_UNORM
Definition: dxgiformat.idl:97
@ DXGI_FORMAT_R32G32_TYPELESS
Definition: dxgiformat.idl:38
@ DXGI_FORMAT_R32G8X24_TYPELESS
Definition: dxgiformat.idl:42
@ DXGI_FORMAT_B4G4R4A4_UNORM
Definition: dxgiformat.idl:138
@ DXGI_FORMAT_AI44
Definition: dxgiformat.idl:134
@ DXGI_FORMAT_R16G16_FLOAT
Definition: dxgiformat.idl:57
@ DXGI_FORMAT_B5G6R5_UNORM
Definition: dxgiformat.idl:108
@ DXGI_FORMAT_BC4_UNORM
Definition: dxgiformat.idl:103
@ DXGI_FORMAT_X32_TYPELESS_G8X24_UINT
Definition: dxgiformat.idl:45
@ DXGI_FORMAT_R8G8_SNORM
Definition: dxgiformat.idl:74
@ DXGI_FORMAT_B8G8R8X8_UNORM_SRGB
Definition: dxgiformat.idl:116
@ DXGI_FORMAT_P8
Definition: dxgiformat.idl:136
@ DXGI_FORMAT_R8_UINT
Definition: dxgiformat.idl:85
@ DXGI_FORMAT_BC4_SNORM
Definition: dxgiformat.idl:104
@ DXGI_FORMAT_NV12
Definition: dxgiformat.idl:126
@ DXGI_FORMAT_B5G5R5A1_UNORM
Definition: dxgiformat.idl:109
@ DXGI_FORMAT_B8G8R8X8_UNORM
Definition: dxgiformat.idl:111

Referenced by dds_get_frame_info(), and load_texture_data().

◆ get_d3dx10_dds_format()

static DXGI_FORMAT get_d3dx10_dds_format ( DXGI_FORMAT  format)
static

Definition at line 249 of file texture.c.

250{
251 static const struct
252 {
255 }
256 format_map[] =
257 {
267 };
268
269 unsigned int i;
270
271 for (i = 0; i < ARRAY_SIZE(format_map); ++i)
272 {
273 if (format == format_map[i].src)
274 return format_map[i].dst;
275 }
276 return format;
277}
DXGI_FORMAT
Definition: dxgiformat.idl:22
@ DXGI_FORMAT_UNKNOWN
Definition: dxgiformat.idl:23
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340

Referenced by get_image_info().

◆ get_image_info()

HRESULT get_image_info ( const void *  data,
SIZE_T  size,
D3DX10_IMAGE_INFO *  img_info 
)

Definition at line 426 of file texture.c.

427{
430 IWICDdsDecoder *dds_decoder = NULL;
432 WICDdsParameters dds_params;
434 unsigned int frame_count;
435 GUID container_format;
436 HRESULT hr;
437
438 WICCreateImagingFactory_Proxy(WINCODEC_SDK_VERSION, &factory);
439 IWICImagingFactory_CreateStream(factory, &stream);
440 hr = IWICStream_InitializeFromMemory(stream, (BYTE *)data, size);
441 if (FAILED(hr))
442 {
443 WARN("Failed to initialize stream.\n");
444 goto end;
445 }
446 hr = IWICImagingFactory_CreateDecoderFromStream(factory, (IStream *)stream, NULL, 0, &decoder);
447 if (FAILED(hr))
448 goto end;
449
450 hr = IWICBitmapDecoder_GetContainerFormat(decoder, &container_format);
451 if (FAILED(hr))
452 goto end;
453 img_info->ImageFileFormat = wic_container_guid_to_file_format(&container_format);
455 {
456 hr = E_FAIL;
457 WARN("Unsupported image file format %s.\n", debugstr_guid(&container_format));
458 goto end;
459 }
460
461 hr = IWICBitmapDecoder_GetFrameCount(decoder, &frame_count);
462 if (FAILED(hr) || !frame_count)
463 goto end;
464 hr = IWICBitmapDecoder_GetFrame(decoder, 0, &frame);
465 if (FAILED(hr))
466 goto end;
467 hr = IWICBitmapFrameDecode_GetSize(frame, &img_info->Width, &img_info->Height);
468 if (FAILED(hr))
469 goto end;
470
471 if (img_info->ImageFileFormat == D3DX10_IFF_DDS)
472 {
473 hr = IWICBitmapDecoder_QueryInterface(decoder, &IID_IWICDdsDecoder, (void **)&dds_decoder);
474 if (FAILED(hr))
475 goto end;
476 hr = IWICDdsDecoder_GetParameters(dds_decoder, &dds_params);
477 if (FAILED(hr))
478 goto end;
479 img_info->ArraySize = dds_params.ArraySize;
480 img_info->Depth = dds_params.Depth;
481 img_info->MipLevels = dds_params.MipLevels;
483 img_info->Format = get_d3dx10_dds_format(dds_params.DxgiFormat);
484 img_info->MiscFlags = 0;
485 if (dds_params.Dimension == WICDdsTextureCube)
486 {
488 img_info->ArraySize *= 6;
489 }
490 }
491 else
492 {
493 img_info->ArraySize = 1;
494 img_info->Depth = 1;
495 img_info->MipLevels = 1;
498 img_info->MiscFlags = 0;
499 }
500
501end:
502 if (dds_decoder)
503 IWICDdsDecoder_Release(dds_decoder);
504 if (frame)
505 IWICBitmapFrameDecode_Release(frame);
506 if (decoder)
507 IWICBitmapDecoder_Release(decoder);
508 if (stream)
509 IWICStream_Release(stream);
510 if (factory)
511 IWICImagingFactory_Release(factory);
512
513 if (hr != S_OK)
514 {
515 WARN("Invalid or unsupported image file.\n");
516 return E_FAIL;
517 }
518 return S_OK;
519}
@ D3D10_RESOURCE_DIMENSION_TEXTURE2D
Definition: d3d10.idl:456
@ D3DX10_IFF_DDS
Definition: d3dx10tex.h:50
@ D3DX10_IFF_FORCE_DWORD
Definition: d3dx10tex.h:54
static D3DX10_IMAGE_FILE_FORMAT wic_container_guid_to_file_format(GUID *container_format)
Definition: texture.c:74
HRESULT WINAPI WICCreateImagingFactory_Proxy(UINT sdk_version, IWICImagingFactory **imaging_factory)
Definition: proxy.c:649
static D3D10_RESOURCE_DIMENSION wic_dimension_to_d3dx10_dimension(WICDdsDimension wic_dimension)
Definition: texture.c:99
static DXGI_FORMAT get_d3dx10_dds_format(DXGI_FORMAT format)
Definition: texture.c:249
GLuint GLuint end
Definition: gl.h:1545
D3D10_RESOURCE_DIMENSION ResourceDimension
Definition: d3dx10tex.h:66
D3DX10_IMAGE_FILE_FORMAT ImageFileFormat
Definition: d3dx10tex.h:67
WICDdsDimension Dimension
Definition: wincodec.idl:353
DXGI_FORMAT DxgiFormat
Definition: wincodec.idl:352
Definition: parse.h:23
@ WICDdsTextureCube
Definition: wincodec.idl:201
unsigned char BYTE
Definition: xxhash.c:193

Referenced by D3DX10GetImageInfoFromFileW(), D3DX10GetImageInfoFromMemory(), D3DX10GetImageInfoFromResourceA(), D3DX10GetImageInfoFromResourceW(), and texture_info_processor_Process().

◆ init_load_info()

void init_load_info ( const D3DX10_IMAGE_LOAD_INFO *  load_info,
D3DX10_IMAGE_LOAD_INFO *  out 
)

Definition at line 730 of file texture.c.

731{
732 if (load_info)
733 {
734 *out = *load_info;
735 return;
736 }
737
738 out->Width = D3DX10_DEFAULT;
739 out->Height = D3DX10_DEFAULT;
740 out->Depth = D3DX10_DEFAULT;
741 out->FirstMipLevel = D3DX10_DEFAULT;
742 out->MipLevels = D3DX10_DEFAULT;
743 out->Usage = D3DX10_DEFAULT;
744 out->BindFlags = D3DX10_DEFAULT;
745 out->CpuAccessFlags = D3DX10_DEFAULT;
746 out->MiscFlags = D3DX10_DEFAULT;
747 out->Format = D3DX10_DEFAULT;
748 out->Filter = D3DX10_DEFAULT;
749 out->MipFilter = D3DX10_DEFAULT;
750 out->pSrcInfo = NULL;
751}
#define D3DX10_DEFAULT
Definition: d3dx10.h:25
wchar_t tm const _CrtWcstime_Writes_and_advances_ptr_ count wchar_t ** out
Definition: wcsftime.cpp:383

Referenced by create_texture(), and D3DX10CreateAsyncTextureProcessor().

◆ load_texture_data()

HRESULT load_texture_data ( const void *  data,
SIZE_T  size,
D3DX10_IMAGE_LOAD_INFO *  load_info,
D3D10_SUBRESOURCE_DATA **  resource_data 
)

Definition at line 822 of file texture.c.

824{
825 unsigned int stride, frame_size, i, j;
826 IWICDdsFrameDecode *dds_frame = NULL;
829 IWICDdsDecoder *dds_decoder = NULL;
831 BYTE *res_data = NULL, *buffer;
832 D3DX10_IMAGE_INFO img_info;
834 const GUID *dst_format;
835 HRESULT hr;
836
837 if (load_info->Width != D3DX10_DEFAULT)
838 FIXME("load_info->Width is ignored.\n");
839 if (load_info->Height != D3DX10_DEFAULT)
840 FIXME("load_info->Height is ignored.\n");
841 if (load_info->Depth != D3DX10_DEFAULT)
842 FIXME("load_info->Depth is ignored.\n");
843 if (load_info->FirstMipLevel != D3DX10_DEFAULT)
844 FIXME("load_info->FirstMipLevel is ignored.\n");
845 if (load_info->MipLevels != D3DX10_DEFAULT)
846 FIXME("load_info->MipLevels is ignored.\n");
847 if (load_info->Usage != D3DX10_DEFAULT)
848 FIXME("load_info->Usage is ignored.\n");
849 if (load_info->BindFlags != D3DX10_DEFAULT)
850 FIXME("load_info->BindFlags is ignored.\n");
851 if (load_info->CpuAccessFlags != D3DX10_DEFAULT)
852 FIXME("load_info->CpuAccessFlags is ignored.\n");
853 if (load_info->MiscFlags != D3DX10_DEFAULT)
854 FIXME("load_info->MiscFlags is ignored.\n");
855 if (load_info->Format != D3DX10_DEFAULT)
856 FIXME("load_info->Format is ignored.\n");
857 if (load_info->Filter != D3DX10_DEFAULT)
858 FIXME("load_info->Filter is ignored.\n");
859 if (load_info->MipFilter != D3DX10_DEFAULT)
860 FIXME("load_info->MipFilter is ignored.\n");
861 if (load_info->pSrcInfo)
862 FIXME("load_info->pSrcInfo is ignored.\n");
863
865 return E_FAIL;
866 if ((!(img_info.MiscFlags & D3D10_RESOURCE_MISC_TEXTURECUBE) || img_info.ArraySize != 6)
867 && img_info.ArraySize != 1)
868 {
869 FIXME("img_info.ArraySize = %u not supported.\n", img_info.ArraySize);
870 return E_NOTIMPL;
871 }
872
873
874 if (FAILED(hr = WICCreateImagingFactory_Proxy(WINCODEC_SDK_VERSION, &factory)))
875 goto end;
876 if (FAILED(hr = IWICImagingFactory_CreateStream(factory, &stream)))
877 goto end;
878 if (FAILED(hr = IWICStream_InitializeFromMemory(stream, (BYTE *)data, size)))
879 goto end;
880 if (FAILED(hr = IWICImagingFactory_CreateDecoderFromStream(factory, (IStream *)stream, NULL, 0, &decoder)))
881 goto end;
882
883 if (img_info.ImageFileFormat == D3DX10_IFF_DDS)
884 {
886 size_t size = 0;
887
888 if (FAILED(hr = IWICBitmapDecoder_QueryInterface(decoder, &IID_IWICDdsDecoder, (void **)&dds_decoder)))
889 goto end;
890
891 for (i = 0; i < img_info.ArraySize; ++i)
892 {
893 for (j = 0; j < img_info.MipLevels; ++j)
894 {
895 if (FAILED(hr = IWICDdsDecoder_GetFrame(dds_decoder, i, j, 0, &frame)))
896 goto end;
897 if (FAILED(hr = IWICBitmapFrameDecode_QueryInterface(frame,
898 &IID_IWICDdsFrameDecode, (void **)&dds_frame)))
899 goto end;
900 if (FAILED(hr = dds_get_frame_info(dds_frame, &img_info, &format_info, &stride, &frame_size)))
901 goto end;
902
903 if (!i && !j)
904 {
905 img_info.Width = (img_info.Width + format_info.BlockWidth - 1) & ~(format_info.BlockWidth - 1);
906 img_info.Height = (img_info.Height + format_info.BlockHeight - 1) & ~(format_info.BlockHeight - 1);
907 }
908
909 size += sizeof(**resource_data) + frame_size;
910
911 IWICDdsFrameDecode_Release(dds_frame);
912 dds_frame = NULL;
913 IWICBitmapFrameDecode_Release(frame);
914 frame = NULL;
915 }
916 }
917
918 if (!(res_data = malloc(size)))
919 {
920 hr = E_FAIL;
921 goto end;
922 }
924
925 size = 0;
926 for (i = 0; i < img_info.ArraySize; ++i)
927 {
928 for (j = 0; j < img_info.MipLevels; ++j)
929 {
930 if (FAILED(hr = IWICDdsDecoder_GetFrame(dds_decoder, i, j, 0, &frame)))
931 goto end;
932 if (FAILED(hr = IWICBitmapFrameDecode_QueryInterface(frame,
933 &IID_IWICDdsFrameDecode, (void **)&dds_frame)))
934 goto end;
935 if (FAILED(hr = dds_get_frame_info(dds_frame, &img_info, &format_info, &stride, &frame_size)))
936 goto end;
937
938 buffer = res_data + sizeof(**resource_data) * img_info.ArraySize * img_info.MipLevels + size;
939 size += frame_size;
940
941 if (img_info.Format == format_info.DxgiFormat)
942 {
943 if (FAILED(hr = IWICDdsFrameDecode_CopyBlocks(dds_frame, NULL, stride, frame_size, buffer)))
944 goto end;
945 }
946 else
947 {
948 if (!(dst_format = dxgi_format_to_wic_guid(img_info.Format)))
949 {
950 hr = E_FAIL;
951 FIXME("Unsupported DXGI format %#x.\n", img_info.Format);
952 goto end;
953 }
954 if (FAILED(hr = convert_image(factory, frame, dst_format, stride, frame_size, buffer)))
955 goto end;
956 }
957
958 IWICDdsFrameDecode_Release(dds_frame);
959 dds_frame = NULL;
960 IWICBitmapFrameDecode_Release(frame);
961 frame = NULL;
962
963 (*resource_data)[i * img_info.MipLevels + j].pSysMem = buffer;
964 (*resource_data)[i * img_info.MipLevels + j].SysMemPitch = stride;
965 (*resource_data)[i * img_info.MipLevels + j].SysMemSlicePitch = frame_size;
966 }
967 }
968 }
969 else
970 {
971 if (FAILED(hr = IWICBitmapDecoder_GetFrame(decoder, 0, &frame)))
972 goto end;
973
974 stride = (img_info.Width * get_bpp_from_format(img_info.Format) + 7) / 8;
975 frame_size = stride * img_info.Height;
976
977 if (!(res_data = malloc(sizeof(**resource_data) + frame_size)))
978 {
979 hr = E_FAIL;
980 goto end;
981 }
982 buffer = res_data + sizeof(**resource_data);
983
984 if (!(dst_format = dxgi_format_to_wic_guid(img_info.Format)))
985 {
986 hr = E_FAIL;
987 FIXME("Unsupported DXGI format %#x.\n", img_info.Format);
988 goto end;
989 }
990 if (FAILED(hr = convert_image(factory, frame, dst_format, stride, frame_size, buffer)))
991 goto end;
992
994 (*resource_data)->pSysMem = buffer;
995 (*resource_data)->SysMemPitch = stride;
996 (*resource_data)->SysMemSlicePitch = frame_size;
997 }
998
999 load_info->Width = img_info.Width;
1000 load_info->Height = img_info.Height;
1001 load_info->MipLevels = img_info.MipLevels;
1002 load_info->Format = img_info.Format;
1003 load_info->Usage = D3D10_USAGE_DEFAULT;
1005 load_info->MiscFlags = img_info.MiscFlags;
1006
1007 res_data = NULL;
1008 hr = S_OK;
1009
1010end:
1011 if (dds_decoder)
1012 IWICDdsDecoder_Release(dds_decoder);
1013 if (dds_frame)
1014 IWICDdsFrameDecode_Release(dds_frame);
1015 free(res_data);
1016 if (frame)
1017 IWICBitmapFrameDecode_Release(frame);
1018 if (decoder)
1019 IWICBitmapDecoder_Release(decoder);
1020 if (stream)
1021 IWICStream_Release(stream);
1022 if (factory)
1023 IWICImagingFactory_Release(factory);
1024 return hr;
1025}
#define FIXME(fmt,...)
Definition: precomp.h:53
@ D3D10_USAGE_DEFAULT
Definition: d3d10.idl:461
@ D3D10_BIND_SHADER_RESOURCE
Definition: d3d10.idl:471
static HRESULT convert_image(IWICImagingFactory *factory, IWICBitmapFrameDecode *frame, const GUID *dst_format, unsigned int stride, unsigned int frame_size, BYTE *buffer)
Definition: texture.c:779
static const GUID * dxgi_format_to_wic_guid(DXGI_FORMAT format)
Definition: texture.c:86
static HRESULT dds_get_frame_info(IWICDdsFrameDecode *frame, const D3DX10_IMAGE_INFO *img_info, WICDdsFormatInfo *format_info, unsigned int *stride, unsigned int *frame_size)
Definition: texture.c:753
HRESULT WINAPI D3DX10GetImageInfoFromMemory(const void *src_data, SIZE_T src_data_size, ID3DX10ThreadPump *pump, D3DX10_IMAGE_INFO *img_info, HRESULT *result)
Definition: texture.c:521
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
D3DX10_IMAGE_INFO * pSrcInfo
Definition: d3dx10tex.h:84

Referenced by create_texture(), and texture_processor_Process().

◆ wic_container_guid_to_file_format()

static D3DX10_IMAGE_FILE_FORMAT wic_container_guid_to_file_format ( GUID *  container_format)
static

Definition at line 74 of file texture.c.

75{
76 unsigned int i;
77
78 for (i = 0; i < ARRAY_SIZE(file_formats); ++i)
79 {
80 if (IsEqualGUID(file_formats[i].wic_container_guid, container_format))
82 }
84}
const GUID * wic_container_guid
Definition: texture.c:34
static const struct @277 file_formats[]
D3DX10_IMAGE_FILE_FORMAT d3dx_file_format
Definition: texture.c:35

Referenced by get_image_info().

◆ wic_dimension_to_d3dx10_dimension()

static D3D10_RESOURCE_DIMENSION wic_dimension_to_d3dx10_dimension ( WICDdsDimension  wic_dimension)
static

Definition at line 99 of file texture.c.

100{
101 switch (wic_dimension)
102 {
103 case WICDdsTexture1D:
105 case WICDdsTexture2D:
108 case WICDdsTexture3D:
110 default:
112 }
113}
@ D3D10_RESOURCE_DIMENSION_TEXTURE1D
Definition: d3d10.idl:455
@ D3D10_RESOURCE_DIMENSION_UNKNOWN
Definition: d3d10.idl:453
@ D3D10_RESOURCE_DIMENSION_TEXTURE3D
Definition: d3d10.idl:457
@ WICDdsTexture2D
Definition: wincodec.idl:199
@ WICDdsTexture3D
Definition: wincodec.idl:200
@ WICDdsTexture1D
Definition: wincodec.idl:198

Referenced by get_image_info().

◆ WICCreateImagingFactory_Proxy()

HRESULT WINAPI WICCreateImagingFactory_Proxy ( UINT  sdk_version,
IWICImagingFactory **  imaging_factory 
)

Definition at line 649 of file proxy.c.

650{
651 TRACE("%x, %p\n", SDKVersion, ppIImagingFactory);
652
653 return ImagingFactory_CreateInstance(&IID_IWICImagingFactory, (void**)ppIImagingFactory);
654}
HRESULT ImagingFactory_CreateInstance(REFIID iid, void **ppv)
Definition: imgfactory.c:1606

Referenced by get_image_info(), and load_texture_data().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( d3dx  )

Variable Documentation

◆ d3dx_file_format

D3DX10_IMAGE_FILE_FORMAT d3dx_file_format

Definition at line 35 of file texture.c.

Referenced by d3dx_initialize_image_from_wic(), and wic_container_guid_to_file_format().

◆ dxgi_format

◆ 

const struct { ... } file_formats[]
Initial value:
=
{
{ &GUID_ContainerFormatBmp, D3DX10_IFF_BMP },
{ &GUID_ContainerFormatJpeg, D3DX10_IFF_JPG },
{ &GUID_ContainerFormatPng, D3DX10_IFF_PNG },
{ &GUID_ContainerFormatDds, D3DX10_IFF_DDS },
{ &GUID_ContainerFormatTiff, D3DX10_IFF_TIFF },
{ &GUID_ContainerFormatGif, D3DX10_IFF_GIF },
{ &GUID_ContainerFormatWmp, D3DX10_IFF_WMP },
}
@ D3DX10_IFF_BMP
Definition: d3dx10tex.h:47
@ D3DX10_IFF_PNG
Definition: d3dx10tex.h:49
@ D3DX10_IFF_TIFF
Definition: d3dx10tex.h:51
@ D3DX10_IFF_JPG
Definition: d3dx10tex.h:48
@ D3DX10_IFF_GIF
Definition: d3dx10tex.h:52
@ D3DX10_IFF_WMP
Definition: d3dx10tex.h:53

Referenced by wic_container_guid_to_file_format().

◆ wic_container_guid

const GUID* wic_container_guid

Definition at line 34 of file texture.c.

Referenced by wic_container_guid_to_file_format().

◆ wic_guid

const GUID* wic_guid

Definition at line 50 of file texture.c.

◆ 

const struct { ... } wic_pixel_formats[]
Initial value:
=
{
{ &GUID_WICPixelFormatBlackWhite, DXGI_FORMAT_R1_UNORM },
{ &GUID_WICPixelFormat8bppAlpha, DXGI_FORMAT_A8_UNORM },
{ &GUID_WICPixelFormat8bppGray, DXGI_FORMAT_R8_UNORM },
{ &GUID_WICPixelFormat16bppGray, DXGI_FORMAT_R16_UNORM },
{ &GUID_WICPixelFormat16bppGrayHalf, DXGI_FORMAT_R16_FLOAT },
{ &GUID_WICPixelFormat32bppGrayFloat, DXGI_FORMAT_R32_FLOAT },
{ &GUID_WICPixelFormat16bppBGR565, DXGI_FORMAT_B5G6R5_UNORM },
{ &GUID_WICPixelFormat16bppBGRA5551, DXGI_FORMAT_B5G5R5A1_UNORM },
{ &GUID_WICPixelFormat32bppBGR, DXGI_FORMAT_B8G8R8X8_UNORM },
{ &GUID_WICPixelFormat32bppBGRA, DXGI_FORMAT_B8G8R8A8_UNORM },
{ &GUID_WICPixelFormat32bppRGBA, DXGI_FORMAT_R8G8B8A8_UNORM },
{ &GUID_WICPixelFormat32bppRGBA1010102, DXGI_FORMAT_R10G10B10A2_UNORM },
{ &GUID_WICPixelFormat32bppRGBA1010102XR, DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM },
{ &GUID_WICPixelFormat64bppRGBA, DXGI_FORMAT_R16G16B16A16_UNORM },
{ &GUID_WICPixelFormat64bppRGBAHalf, DXGI_FORMAT_R16G16B16A16_FLOAT },
{ &GUID_WICPixelFormat96bppRGBFloat, DXGI_FORMAT_R32G32B32_FLOAT },
{ &GUID_WICPixelFormat128bppRGBAFloat, DXGI_FORMAT_R32G32B32A32_FLOAT }
}

Referenced by dxgi_format_to_wic_guid().