2016-08-22 18:26:36 +00:00
|
|
|
//--------------------------------------------------------------------------------------
|
2020-05-10 00:22:35 +00:00
|
|
|
// File: DDSTextureLoader11.h
|
2016-08-22 18:26:36 +00:00
|
|
|
//
|
2016-09-23 05:34:50 +00:00
|
|
|
// Functions for loading a DDS texture and creating a Direct3D runtime resource for it
|
2016-08-22 18:26:36 +00:00
|
|
|
//
|
|
|
|
// Note these functions are useful as a light-weight runtime loader for DDS files. For
|
|
|
|
// a full-featured DDS file reader, writer, and texture processing pipeline see
|
|
|
|
// the 'Texconv' sample and the 'DirectXTex' library.
|
|
|
|
//
|
2021-02-27 06:59:42 +00:00
|
|
|
// Copyright (c) Microsoft Corporation.
|
2018-02-24 06:24:46 +00:00
|
|
|
// Licensed under the MIT License.
|
2016-08-22 18:26:36 +00:00
|
|
|
//
|
|
|
|
// http://go.microsoft.com/fwlink/?LinkId=248926
|
|
|
|
// http://go.microsoft.com/fwlink/?LinkId=248929
|
|
|
|
//--------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <d3d11_1.h>
|
2020-03-10 08:05:10 +00:00
|
|
|
|
2021-11-08 18:25:31 +00:00
|
|
|
#pragma comment(lib,"dxguid.lib")
|
|
|
|
|
2020-12-31 21:53:09 +00:00
|
|
|
#include <cstddef>
|
2020-03-10 08:05:10 +00:00
|
|
|
#include <cstdint>
|
2016-08-22 18:26:36 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DirectX
|
|
|
|
{
|
2019-12-11 20:04:52 +00:00
|
|
|
#ifndef DDS_ALPHA_MODE_DEFINED
|
|
|
|
#define DDS_ALPHA_MODE_DEFINED
|
2020-05-21 07:40:33 +00:00
|
|
|
enum DDS_ALPHA_MODE : uint32_t
|
2016-08-22 18:26:36 +00:00
|
|
|
{
|
2022-04-04 22:03:02 +00:00
|
|
|
DDS_ALPHA_MODE_UNKNOWN = 0,
|
|
|
|
DDS_ALPHA_MODE_STRAIGHT = 1,
|
2016-08-22 18:26:36 +00:00
|
|
|
DDS_ALPHA_MODE_PREMULTIPLIED = 2,
|
2022-04-04 22:03:02 +00:00
|
|
|
DDS_ALPHA_MODE_OPAQUE = 3,
|
|
|
|
DDS_ALPHA_MODE_CUSTOM = 4,
|
2016-08-22 18:26:36 +00:00
|
|
|
};
|
2019-12-11 20:04:52 +00:00
|
|
|
#endif
|
2016-08-22 18:26:36 +00:00
|
|
|
|
|
|
|
// Standard version
|
|
|
|
HRESULT CreateDDSTextureFromMemory(
|
|
|
|
_In_ ID3D11Device* d3dDevice,
|
|
|
|
_In_reads_bytes_(ddsDataSize) const uint8_t* ddsData,
|
|
|
|
_In_ size_t ddsDataSize,
|
|
|
|
_Outptr_opt_ ID3D11Resource** texture,
|
|
|
|
_Outptr_opt_ ID3D11ShaderResourceView** textureView,
|
|
|
|
_In_ size_t maxsize = 0,
|
2020-03-10 08:05:10 +00:00
|
|
|
_Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr) noexcept;
|
2016-08-22 18:26:36 +00:00
|
|
|
|
|
|
|
HRESULT CreateDDSTextureFromFile(
|
|
|
|
_In_ ID3D11Device* d3dDevice,
|
|
|
|
_In_z_ const wchar_t* szFileName,
|
|
|
|
_Outptr_opt_ ID3D11Resource** texture,
|
|
|
|
_Outptr_opt_ ID3D11ShaderResourceView** textureView,
|
|
|
|
_In_ size_t maxsize = 0,
|
2020-03-10 08:05:10 +00:00
|
|
|
_Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr) noexcept;
|
2016-08-22 18:26:36 +00:00
|
|
|
|
|
|
|
// Standard version with optional auto-gen mipmap support
|
|
|
|
HRESULT CreateDDSTextureFromMemory(
|
|
|
|
_In_ ID3D11Device* d3dDevice,
|
|
|
|
_In_opt_ ID3D11DeviceContext* d3dContext,
|
|
|
|
_In_reads_bytes_(ddsDataSize) const uint8_t* ddsData,
|
|
|
|
_In_ size_t ddsDataSize,
|
|
|
|
_Outptr_opt_ ID3D11Resource** texture,
|
|
|
|
_Outptr_opt_ ID3D11ShaderResourceView** textureView,
|
|
|
|
_In_ size_t maxsize = 0,
|
2020-03-10 08:05:10 +00:00
|
|
|
_Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr) noexcept;
|
2016-08-22 18:26:36 +00:00
|
|
|
|
|
|
|
HRESULT CreateDDSTextureFromFile(
|
|
|
|
_In_ ID3D11Device* d3dDevice,
|
|
|
|
_In_opt_ ID3D11DeviceContext* d3dContext,
|
|
|
|
_In_z_ const wchar_t* szFileName,
|
|
|
|
_Outptr_opt_ ID3D11Resource** texture,
|
|
|
|
_Outptr_opt_ ID3D11ShaderResourceView** textureView,
|
|
|
|
_In_ size_t maxsize = 0,
|
2020-03-10 08:05:10 +00:00
|
|
|
_Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr) noexcept;
|
2016-08-22 18:26:36 +00:00
|
|
|
|
|
|
|
// Extended version
|
|
|
|
HRESULT CreateDDSTextureFromMemoryEx(
|
|
|
|
_In_ ID3D11Device* d3dDevice,
|
|
|
|
_In_reads_bytes_(ddsDataSize) const uint8_t* ddsData,
|
|
|
|
_In_ size_t ddsDataSize,
|
|
|
|
_In_ size_t maxsize,
|
|
|
|
_In_ D3D11_USAGE usage,
|
|
|
|
_In_ unsigned int bindFlags,
|
|
|
|
_In_ unsigned int cpuAccessFlags,
|
|
|
|
_In_ unsigned int miscFlags,
|
|
|
|
_In_ bool forceSRGB,
|
|
|
|
_Outptr_opt_ ID3D11Resource** texture,
|
|
|
|
_Outptr_opt_ ID3D11ShaderResourceView** textureView,
|
2020-03-10 08:05:10 +00:00
|
|
|
_Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr) noexcept;
|
2016-08-22 18:26:36 +00:00
|
|
|
|
|
|
|
HRESULT CreateDDSTextureFromFileEx(
|
|
|
|
_In_ ID3D11Device* d3dDevice,
|
|
|
|
_In_z_ const wchar_t* szFileName,
|
|
|
|
_In_ size_t maxsize,
|
|
|
|
_In_ D3D11_USAGE usage,
|
|
|
|
_In_ unsigned int bindFlags,
|
|
|
|
_In_ unsigned int cpuAccessFlags,
|
|
|
|
_In_ unsigned int miscFlags,
|
|
|
|
_In_ bool forceSRGB,
|
|
|
|
_Outptr_opt_ ID3D11Resource** texture,
|
|
|
|
_Outptr_opt_ ID3D11ShaderResourceView** textureView,
|
2020-03-10 08:05:10 +00:00
|
|
|
_Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr) noexcept;
|
2016-08-22 18:26:36 +00:00
|
|
|
|
|
|
|
// Extended version with optional auto-gen mipmap support
|
|
|
|
HRESULT CreateDDSTextureFromMemoryEx(
|
|
|
|
_In_ ID3D11Device* d3dDevice,
|
|
|
|
_In_opt_ ID3D11DeviceContext* d3dContext,
|
|
|
|
_In_reads_bytes_(ddsDataSize) const uint8_t* ddsData,
|
|
|
|
_In_ size_t ddsDataSize,
|
|
|
|
_In_ size_t maxsize,
|
|
|
|
_In_ D3D11_USAGE usage,
|
|
|
|
_In_ unsigned int bindFlags,
|
|
|
|
_In_ unsigned int cpuAccessFlags,
|
|
|
|
_In_ unsigned int miscFlags,
|
|
|
|
_In_ bool forceSRGB,
|
|
|
|
_Outptr_opt_ ID3D11Resource** texture,
|
|
|
|
_Outptr_opt_ ID3D11ShaderResourceView** textureView,
|
2020-03-10 08:05:10 +00:00
|
|
|
_Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr) noexcept;
|
2016-08-22 18:26:36 +00:00
|
|
|
|
|
|
|
HRESULT CreateDDSTextureFromFileEx(
|
|
|
|
_In_ ID3D11Device* d3dDevice,
|
|
|
|
_In_opt_ ID3D11DeviceContext* d3dContext,
|
|
|
|
_In_z_ const wchar_t* szFileName,
|
|
|
|
_In_ size_t maxsize,
|
|
|
|
_In_ D3D11_USAGE usage,
|
|
|
|
_In_ unsigned int bindFlags,
|
|
|
|
_In_ unsigned int cpuAccessFlags,
|
|
|
|
_In_ unsigned int miscFlags,
|
|
|
|
_In_ bool forceSRGB,
|
|
|
|
_Outptr_opt_ ID3D11Resource** texture,
|
|
|
|
_Outptr_opt_ ID3D11ShaderResourceView** textureView,
|
2020-03-10 08:05:10 +00:00
|
|
|
_Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr) noexcept;
|
2019-08-01 00:05:23 +00:00
|
|
|
}
|