зеркало из https://github.com/microsoft/DirectXTK.git
XboxDDSTextureLoader updates
This commit is contained in:
Родитель
96d9ef1c4d
Коммит
93aba977e8
|
@ -1,60 +1,62 @@
|
|||
//--------------------------------------------------------------------------------------
|
||||
// File: XboxDDSTextureLoader.h
|
||||
//
|
||||
// Functions for loading a DDS texture using the XBOX extended header and creating a
|
||||
// Direct3D11.X runtime resource for it via the CreatePlacement APIs
|
||||
//
|
||||
// Note these functions will not load standard DDS files. Use the DDSTextureLoader
|
||||
// module in the DirectXTex package or as part of the DirectXTK library to load
|
||||
// these files which use standard Direct3D resource creation APIs.
|
||||
//
|
||||
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
|
||||
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
|
||||
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
|
||||
// PARTICULAR PURPOSE.
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//
|
||||
// http://go.microsoft.com/fwlink/?LinkId=248926
|
||||
// http://go.microsoft.com/fwlink/?LinkId=248929
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
#pragma once
|
||||
|
||||
#if !defined(_XBOX_ONE) || !defined(_TITLE)
|
||||
#error This module only supports Xbox One exclusive apps
|
||||
#endif
|
||||
|
||||
#include <d3d11_x.h>
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
namespace Xbox
|
||||
{
|
||||
enum DDS_ALPHA_MODE
|
||||
{
|
||||
DDS_ALPHA_MODE_UNKNOWN = 0,
|
||||
DDS_ALPHA_MODE_STRAIGHT = 1,
|
||||
DDS_ALPHA_MODE_PREMULTIPLIED = 2,
|
||||
DDS_ALPHA_MODE_OPAQUE = 3,
|
||||
DDS_ALPHA_MODE_CUSTOM = 4,
|
||||
};
|
||||
|
||||
HRESULT __cdecl CreateDDSTextureFromMemory(
|
||||
_In_ ID3D11DeviceX* d3dDevice,
|
||||
_In_reads_bytes_(ddsDataSize) const uint8_t* ddsData,
|
||||
_In_ size_t ddsDataSize,
|
||||
_Outptr_opt_ ID3D11Resource** texture,
|
||||
_Outptr_opt_ ID3D11ShaderResourceView** textureView,
|
||||
_Outptr_ void** grfxMemory,
|
||||
_Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr,
|
||||
_In_ bool forceSRGB = false);
|
||||
|
||||
HRESULT __cdecl CreateDDSTextureFromFile( _In_ ID3D11DeviceX* d3dDevice,
|
||||
_In_z_ const wchar_t* szFileName,
|
||||
_Outptr_opt_ ID3D11Resource** texture,
|
||||
_Outptr_opt_ ID3D11ShaderResourceView** textureView,
|
||||
_Outptr_ void** grfxMemory,
|
||||
_Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr,
|
||||
_In_ bool forceSRGB = false);
|
||||
//--------------------------------------------------------------------------------------
|
||||
// File: XboxDDSTextureLoader.h
|
||||
//
|
||||
// Functions for loading a DDS texture using the XBOX extended header and creating a
|
||||
// Direct3D11.X runtime resource for it via the CreatePlacement APIs
|
||||
//
|
||||
// Note these functions will not load standard DDS files. Use the DDSTextureLoader
|
||||
// module in the DirectXTex package or as part of the DirectXTK library to load
|
||||
// these files which use standard Direct3D resource creation APIs.
|
||||
//
|
||||
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
|
||||
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
|
||||
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
|
||||
// PARTICULAR PURPOSE.
|
||||
//
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
//
|
||||
// http://go.microsoft.com/fwlink/?LinkId=248926
|
||||
// http://go.microsoft.com/fwlink/?LinkId=248929
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
#pragma once
|
||||
|
||||
#if !defined(_XBOX_ONE) || !defined(_TITLE)
|
||||
#error This module only supports Xbox One exclusive apps
|
||||
#endif
|
||||
|
||||
#include <d3d11_x.h>
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
namespace Xbox
|
||||
{
|
||||
enum DDS_ALPHA_MODE
|
||||
{
|
||||
DDS_ALPHA_MODE_UNKNOWN = 0,
|
||||
DDS_ALPHA_MODE_STRAIGHT = 1,
|
||||
DDS_ALPHA_MODE_PREMULTIPLIED = 2,
|
||||
DDS_ALPHA_MODE_OPAQUE = 3,
|
||||
DDS_ALPHA_MODE_CUSTOM = 4,
|
||||
};
|
||||
|
||||
HRESULT __cdecl CreateDDSTextureFromMemory(
|
||||
_In_ ID3D11DeviceX* d3dDevice,
|
||||
_In_reads_bytes_(ddsDataSize) const uint8_t* ddsData,
|
||||
_In_ size_t ddsDataSize,
|
||||
_Outptr_opt_ ID3D11Resource** texture,
|
||||
_Outptr_opt_ ID3D11ShaderResourceView** textureView,
|
||||
_Outptr_ void** grfxMemory,
|
||||
_Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr,
|
||||
_In_ bool forceSRGB = false);
|
||||
|
||||
HRESULT __cdecl CreateDDSTextureFromFile( _In_ ID3D11DeviceX* d3dDevice,
|
||||
_In_z_ const wchar_t* szFileName,
|
||||
_Outptr_opt_ ID3D11Resource** texture,
|
||||
_Outptr_opt_ ID3D11ShaderResourceView** textureView,
|
||||
_Outptr_ void** grfxMemory,
|
||||
_Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr,
|
||||
_In_ bool forceSRGB = false);
|
||||
|
||||
void FreeDDSTextureMemory( _In_opt_ void* grfxMemory );
|
||||
}
|
|
@ -575,7 +575,7 @@ namespace
|
|||
texture, textureView);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
D3DFreeGraphicsMemory(*grfxMemory);
|
||||
(void)D3DFreeGraphicsMemory(*grfxMemory);
|
||||
*grfxMemory = nullptr;
|
||||
}
|
||||
|
||||
|
@ -772,3 +772,13 @@ HRESULT Xbox::CreateDDSTextureFromFile( ID3D11DeviceX* d3dDevice,
|
|||
|
||||
return hr;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
_Use_decl_annotations_
|
||||
void Xbox::FreeDDSTextureMemory(void* grfxMemory)
|
||||
{
|
||||
if (grfxMemory)
|
||||
{
|
||||
(void)D3DFreeGraphicsMemory(grfxMemory);
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче