mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-03-13 19:29:14 +01:00
[d3d9] Don't pass format mapping to D3D9CommonTexture
Instead, infer it from the format. This is basically being done already, however the mapping we pass in is not correct if the image format is Unknown.
This commit is contained in:
parent
7150d2b7fb
commit
905d69e77b
@ -10,14 +10,15 @@ namespace dxvk {
|
||||
D3D9CommonTexture::D3D9CommonTexture(
|
||||
D3D9DeviceEx* pDevice,
|
||||
const D3D9_COMMON_TEXTURE_DESC* pDesc,
|
||||
D3DRESOURCETYPE ResourceType,
|
||||
D3D9_VK_FORMAT_MAPPING Mapping)
|
||||
: m_device(pDevice), m_desc(*pDesc), m_type(ResourceType), m_mapping(Mapping) {
|
||||
D3DRESOURCETYPE ResourceType)
|
||||
: m_device(pDevice), m_desc(*pDesc), m_type(ResourceType) {
|
||||
if (m_desc.Format == D3D9Format::Unknown)
|
||||
m_desc.Format = (m_desc.Usage & D3DUSAGE_DEPTHSTENCIL)
|
||||
? D3D9Format::D32
|
||||
: D3D9Format::X8R8G8B8;
|
||||
|
||||
m_mapping = pDevice->LookupFormat(m_desc.Format);
|
||||
|
||||
auto pxSize = m_mapping.VideoFormatInfo.MacroPixelSize;
|
||||
m_adjustedExtent = VkExtent3D{ m_desc.Width / pxSize.width, m_desc.Height / pxSize.height, m_desc.Depth };
|
||||
|
||||
@ -71,14 +72,12 @@ namespace dxvk {
|
||||
|
||||
HRESULT D3D9CommonTexture::NormalizeTextureProperties(
|
||||
D3D9DeviceEx* pDevice,
|
||||
D3D9_COMMON_TEXTURE_DESC* pDesc,
|
||||
D3D9_VK_FORMAT_MAPPING* pMapping) {
|
||||
D3D9_COMMON_TEXTURE_DESC* pDesc) {
|
||||
auto* options = pDevice->GetOptions();
|
||||
|
||||
//////////////////////
|
||||
// Mapping Validation
|
||||
|
||||
*pMapping = pDevice->LookupFormat(pDesc->Format);
|
||||
auto mapping = pDevice->LookupFormat(pDesc->Format);
|
||||
|
||||
// Handle DisableA8RT hack for The Sims 2
|
||||
if (pDesc->Format == D3D9Format::A8 &&
|
||||
@ -92,7 +91,7 @@ namespace dxvk {
|
||||
// SCRATCH textures can still be made if the device does not support
|
||||
// the format at all.
|
||||
|
||||
if (!pMapping->IsValid() && pDesc->Format != D3D9Format::NULL_FORMAT) {
|
||||
if (!mapping.IsValid() && pDesc->Format != D3D9Format::NULL_FORMAT) {
|
||||
auto info = pDevice->UnsupportedFormatInfo(pDesc->Format);
|
||||
|
||||
if (pDesc->Pool != D3DPOOL_SCRATCH || info.elementSize == 0)
|
||||
|
@ -93,8 +93,7 @@ namespace dxvk {
|
||||
D3D9CommonTexture(
|
||||
D3D9DeviceEx* pDevice,
|
||||
const D3D9_COMMON_TEXTURE_DESC* pDesc,
|
||||
D3DRESOURCETYPE ResourceType,
|
||||
D3D9_VK_FORMAT_MAPPING Mapping);
|
||||
D3DRESOURCETYPE ResourceType);
|
||||
|
||||
~D3D9CommonTexture();
|
||||
|
||||
@ -203,8 +202,7 @@ namespace dxvk {
|
||||
*/
|
||||
static HRESULT NormalizeTextureProperties(
|
||||
D3D9DeviceEx* pDevice,
|
||||
D3D9_COMMON_TEXTURE_DESC* pDesc,
|
||||
D3D9_VK_FORMAT_MAPPING* pMapping);
|
||||
D3D9_COMMON_TEXTURE_DESC* pDesc);
|
||||
|
||||
/**
|
||||
* \brief Lock Flags
|
||||
|
@ -398,12 +398,11 @@ namespace dxvk {
|
||||
desc.MultiSample = D3DMULTISAMPLE_NONE;
|
||||
desc.MultisampleQuality = 0;
|
||||
|
||||
D3D9_VK_FORMAT_MAPPING mapping;
|
||||
if (FAILED(D3D9CommonTexture::NormalizeTextureProperties(this, &desc, &mapping)))
|
||||
if (FAILED(D3D9CommonTexture::NormalizeTextureProperties(this, &desc)))
|
||||
return D3DERR_INVALIDCALL;
|
||||
|
||||
try {
|
||||
const Com<D3D9Texture2D> texture = new D3D9Texture2D(this, &desc, mapping);
|
||||
const Com<D3D9Texture2D> texture = new D3D9Texture2D(this, &desc);
|
||||
|
||||
void* initialData = nullptr;
|
||||
|
||||
@ -454,12 +453,11 @@ namespace dxvk {
|
||||
desc.MultiSample = D3DMULTISAMPLE_NONE;
|
||||
desc.MultisampleQuality = 0;
|
||||
|
||||
D3D9_VK_FORMAT_MAPPING mapping;
|
||||
if (FAILED(D3D9CommonTexture::NormalizeTextureProperties(this, &desc, &mapping)))
|
||||
if (FAILED(D3D9CommonTexture::NormalizeTextureProperties(this, &desc)))
|
||||
return D3DERR_INVALIDCALL;
|
||||
|
||||
try {
|
||||
const Com<D3D9Texture3D> texture = new D3D9Texture3D(this, &desc, mapping);
|
||||
const Com<D3D9Texture3D> texture = new D3D9Texture3D(this, &desc);
|
||||
m_initializer->InitTexture(texture->GetCommonTexture());
|
||||
*ppVolumeTexture = texture.ref();
|
||||
|
||||
@ -500,12 +498,11 @@ namespace dxvk {
|
||||
desc.MultiSample = D3DMULTISAMPLE_NONE;
|
||||
desc.MultisampleQuality = 0;
|
||||
|
||||
D3D9_VK_FORMAT_MAPPING mapping;
|
||||
if (FAILED(D3D9CommonTexture::NormalizeTextureProperties(this, &desc, &mapping)))
|
||||
if (FAILED(D3D9CommonTexture::NormalizeTextureProperties(this, &desc)))
|
||||
return D3DERR_INVALIDCALL;
|
||||
|
||||
try {
|
||||
const Com<D3D9TextureCube> texture = new D3D9TextureCube(this, &desc, mapping);
|
||||
const Com<D3D9TextureCube> texture = new D3D9TextureCube(this, &desc);
|
||||
m_initializer->InitTexture(texture->GetCommonTexture());
|
||||
*ppCubeTexture = texture.ref();
|
||||
|
||||
@ -3293,12 +3290,11 @@ namespace dxvk {
|
||||
desc.MultiSample = MultiSample;
|
||||
desc.MultisampleQuality = MultisampleQuality;
|
||||
|
||||
D3D9_VK_FORMAT_MAPPING mapping;
|
||||
if (FAILED(D3D9CommonTexture::NormalizeTextureProperties(this, &desc, &mapping)))
|
||||
if (FAILED(D3D9CommonTexture::NormalizeTextureProperties(this, &desc)))
|
||||
return D3DERR_INVALIDCALL;
|
||||
|
||||
try {
|
||||
const Com<D3D9Surface> surface = new D3D9Surface(this, &desc, mapping);
|
||||
const Com<D3D9Surface> surface = new D3D9Surface(this, &desc);
|
||||
m_initializer->InitTexture(surface->GetCommonTexture());
|
||||
*ppSurface = surface.ref();
|
||||
return D3D_OK;
|
||||
@ -3337,12 +3333,11 @@ namespace dxvk {
|
||||
desc.MultiSample = D3DMULTISAMPLE_NONE;
|
||||
desc.MultisampleQuality = 0;
|
||||
|
||||
D3D9_VK_FORMAT_MAPPING mapping;
|
||||
if (FAILED(D3D9CommonTexture::NormalizeTextureProperties(this, &desc, &mapping)))
|
||||
if (FAILED(D3D9CommonTexture::NormalizeTextureProperties(this, &desc)))
|
||||
return D3DERR_INVALIDCALL;
|
||||
|
||||
try {
|
||||
const Com<D3D9Surface> surface = new D3D9Surface(this, &desc, mapping);
|
||||
const Com<D3D9Surface> surface = new D3D9Surface(this, &desc);
|
||||
m_initializer->InitTexture(surface->GetCommonTexture());
|
||||
*ppSurface = surface.ref();
|
||||
return D3D_OK;
|
||||
@ -3383,12 +3378,11 @@ namespace dxvk {
|
||||
desc.MultiSample = MultiSample;
|
||||
desc.MultisampleQuality = MultisampleQuality;
|
||||
|
||||
D3D9_VK_FORMAT_MAPPING mapping;
|
||||
if (FAILED(D3D9CommonTexture::NormalizeTextureProperties(this, &desc, &mapping)))
|
||||
if (FAILED(D3D9CommonTexture::NormalizeTextureProperties(this, &desc)))
|
||||
return D3DERR_INVALIDCALL;
|
||||
|
||||
try {
|
||||
const Com<D3D9Surface> surface = new D3D9Surface(this, &desc, mapping);
|
||||
const Com<D3D9Surface> surface = new D3D9Surface(this, &desc);
|
||||
m_initializer->InitTexture(surface->GetCommonTexture());
|
||||
*ppSurface = surface.ref();
|
||||
return D3D_OK;
|
||||
@ -6523,11 +6517,10 @@ namespace dxvk {
|
||||
desc.MultiSample = pPresentationParameters->MultiSampleType;
|
||||
desc.MultisampleQuality = pPresentationParameters->MultiSampleQuality;
|
||||
|
||||
D3D9_VK_FORMAT_MAPPING mapping;
|
||||
if (FAILED(D3D9CommonTexture::NormalizeTextureProperties(this, &desc, &mapping)))
|
||||
if (FAILED(D3D9CommonTexture::NormalizeTextureProperties(this, &desc)))
|
||||
return D3DERR_NOTAVAILABLE;
|
||||
|
||||
m_autoDepthStencil = new D3D9Surface(this, &desc, mapping);
|
||||
m_autoDepthStencil = new D3D9Surface(this, &desc);
|
||||
m_initializer->InitTexture(m_autoDepthStencil->GetCommonTexture());
|
||||
SetDepthStencilSurface(m_autoDepthStencil.ptr());
|
||||
}
|
||||
|
@ -7,11 +7,10 @@ namespace dxvk {
|
||||
|
||||
D3D9Surface::D3D9Surface(
|
||||
D3D9DeviceEx* pDevice,
|
||||
const D3D9_COMMON_TEXTURE_DESC* pDesc,
|
||||
D3D9_VK_FORMAT_MAPPING Mapping)
|
||||
const D3D9_COMMON_TEXTURE_DESC* pDesc)
|
||||
: D3D9SurfaceBase(
|
||||
pDevice,
|
||||
new D3D9CommonTexture( pDevice, pDesc, D3DRTYPE_TEXTURE, Mapping ),
|
||||
new D3D9CommonTexture( pDevice, pDesc, D3DRTYPE_TEXTURE),
|
||||
0, 0,
|
||||
nullptr) { }
|
||||
|
||||
|
@ -19,8 +19,7 @@ namespace dxvk {
|
||||
|
||||
D3D9Surface(
|
||||
D3D9DeviceEx* pDevice,
|
||||
const D3D9_COMMON_TEXTURE_DESC* pDesc,
|
||||
D3D9_VK_FORMAT_MAPPING Mapping);
|
||||
const D3D9_COMMON_TEXTURE_DESC* pDesc);
|
||||
|
||||
D3D9Surface(
|
||||
D3D9DeviceEx* pDevice,
|
||||
|
@ -890,10 +890,8 @@ namespace dxvk {
|
||||
desc.Usage = D3DUSAGE_RENDERTARGET;
|
||||
desc.Discard = FALSE;
|
||||
|
||||
auto mapping = m_parent->LookupFormat(desc.Format);
|
||||
|
||||
for (uint32_t i = 0; i < NumBackBuffers; i++)
|
||||
m_backBuffers[i] = new D3D9Surface(m_parent, &desc, mapping);
|
||||
m_backBuffers[i] = new D3D9Surface(m_parent, &desc);
|
||||
|
||||
m_swapImage = m_backBuffers[0]->GetCommonTexture()->GetImage();
|
||||
|
||||
|
@ -8,9 +8,8 @@ namespace dxvk {
|
||||
|
||||
D3D9Texture2D::D3D9Texture2D(
|
||||
D3D9DeviceEx* pDevice,
|
||||
const D3D9_COMMON_TEXTURE_DESC* pDesc,
|
||||
D3D9_VK_FORMAT_MAPPING Mapping)
|
||||
: D3D9Texture2DBase( pDevice, pDesc, D3DRTYPE_TEXTURE, Mapping ) { }
|
||||
const D3D9_COMMON_TEXTURE_DESC* pDesc)
|
||||
: D3D9Texture2DBase( pDevice, pDesc, D3DRTYPE_TEXTURE ) { }
|
||||
|
||||
|
||||
HRESULT STDMETHODCALLTYPE D3D9Texture2D::QueryInterface(REFIID riid, void** ppvObject) {
|
||||
@ -87,9 +86,8 @@ namespace dxvk {
|
||||
|
||||
D3D9Texture3D::D3D9Texture3D(
|
||||
D3D9DeviceEx* pDevice,
|
||||
const D3D9_COMMON_TEXTURE_DESC* pDesc,
|
||||
D3D9_VK_FORMAT_MAPPING Mapping)
|
||||
: D3D9Texture3DBase( pDevice, pDesc, D3DRTYPE_VOLUMETEXTURE, Mapping ) { }
|
||||
const D3D9_COMMON_TEXTURE_DESC* pDesc)
|
||||
: D3D9Texture3DBase( pDevice, pDesc, D3DRTYPE_VOLUMETEXTURE ) { }
|
||||
|
||||
|
||||
HRESULT STDMETHODCALLTYPE D3D9Texture3D::QueryInterface(REFIID riid, void** ppvObject) {
|
||||
@ -166,9 +164,8 @@ namespace dxvk {
|
||||
|
||||
D3D9TextureCube::D3D9TextureCube(
|
||||
D3D9DeviceEx* pDevice,
|
||||
const D3D9_COMMON_TEXTURE_DESC* pDesc,
|
||||
D3D9_VK_FORMAT_MAPPING Mapping)
|
||||
: D3D9TextureCubeBase( pDevice, pDesc, D3DRTYPE_CUBETEXTURE, Mapping ) { }
|
||||
const D3D9_COMMON_TEXTURE_DESC* pDesc)
|
||||
: D3D9TextureCubeBase( pDevice, pDesc, D3DRTYPE_CUBETEXTURE ) { }
|
||||
|
||||
|
||||
HRESULT STDMETHODCALLTYPE D3D9TextureCube::QueryInterface(REFIID riid, void** ppvObject) {
|
||||
|
@ -22,10 +22,9 @@ namespace dxvk {
|
||||
D3D9BaseTexture(
|
||||
D3D9DeviceEx* pDevice,
|
||||
const D3D9_COMMON_TEXTURE_DESC* pDesc,
|
||||
D3DRESOURCETYPE ResourceType,
|
||||
D3D9_VK_FORMAT_MAPPING Mapping)
|
||||
D3DRESOURCETYPE ResourceType)
|
||||
: D3D9Resource<Base...> ( pDevice )
|
||||
, m_texture ( pDevice, pDesc, ResourceType, Mapping )
|
||||
, m_texture ( pDevice, pDesc, ResourceType )
|
||||
, m_lod ( 0 )
|
||||
, m_autogenFilter ( D3DTEXF_LINEAR ) {
|
||||
const uint32_t arraySlices = m_texture.Desc()->ArraySize;
|
||||
@ -117,8 +116,7 @@ namespace dxvk {
|
||||
|
||||
D3D9Texture2D(
|
||||
D3D9DeviceEx* pDevice,
|
||||
const D3D9_COMMON_TEXTURE_DESC* pDesc,
|
||||
D3D9_VK_FORMAT_MAPPING Mapping);
|
||||
const D3D9_COMMON_TEXTURE_DESC* pDesc);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject);
|
||||
|
||||
@ -143,8 +141,7 @@ namespace dxvk {
|
||||
|
||||
D3D9Texture3D(
|
||||
D3D9DeviceEx* pDevice,
|
||||
const D3D9_COMMON_TEXTURE_DESC* pDesc,
|
||||
D3D9_VK_FORMAT_MAPPING Mapping);
|
||||
const D3D9_COMMON_TEXTURE_DESC* pDesc);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject);
|
||||
|
||||
@ -169,8 +166,7 @@ namespace dxvk {
|
||||
|
||||
D3D9TextureCube(
|
||||
D3D9DeviceEx* pDevice,
|
||||
const D3D9_COMMON_TEXTURE_DESC* pDesc,
|
||||
D3D9_VK_FORMAT_MAPPING Mapping);
|
||||
const D3D9_COMMON_TEXTURE_DESC* pDesc);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject);
|
||||
|
||||
|
@ -7,11 +7,10 @@ namespace dxvk {
|
||||
|
||||
D3D9Volume::D3D9Volume(
|
||||
D3D9DeviceEx* pDevice,
|
||||
const D3D9_COMMON_TEXTURE_DESC* pDesc,
|
||||
D3D9_VK_FORMAT_MAPPING Mapping)
|
||||
const D3D9_COMMON_TEXTURE_DESC* pDesc)
|
||||
: D3D9VolumeBase(
|
||||
pDevice,
|
||||
new D3D9CommonTexture( pDevice, pDesc, D3DRTYPE_VOLUMETEXTURE, Mapping ),
|
||||
new D3D9CommonTexture( pDevice, pDesc, D3DRTYPE_VOLUMETEXTURE ),
|
||||
0, 0,
|
||||
nullptr) { }
|
||||
|
||||
|
@ -13,8 +13,7 @@ namespace dxvk {
|
||||
|
||||
D3D9Volume(
|
||||
D3D9DeviceEx* pDevice,
|
||||
const D3D9_COMMON_TEXTURE_DESC* pDesc,
|
||||
D3D9_VK_FORMAT_MAPPING Mapping);
|
||||
const D3D9_COMMON_TEXTURE_DESC* pDesc);
|
||||
|
||||
D3D9Volume(
|
||||
D3D9DeviceEx* pDevice,
|
||||
|
Loading…
x
Reference in New Issue
Block a user