Commit a3a8075e authored by Joshua Ashton's avatar Joshua Ashton 🐸

[d3d9] Adjust usages for specific resource types.

parent a160ac51
Pipeline #55 passed with stage
in 1 minute and 40 seconds
......@@ -659,8 +659,8 @@ namespace dxup {
D3D11_BUFFER_DESC desc;
desc.ByteWidth = Length;
desc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
desc.CPUAccessFlags = convert::cpuFlags(Pool, Usage);
desc.Usage = convert::usage(Pool, Usage);
desc.CPUAccessFlags = convert::cpuFlags(Pool, Usage, D3DRTYPE_VERTEXBUFFER);
desc.Usage = convert::usage(Pool, Usage, D3DRTYPE_VERTEXBUFFER);
desc.MiscFlags = 0;
desc.StructureByteStride = 0;
......@@ -696,8 +696,8 @@ namespace dxup {
D3D11_BUFFER_DESC desc;
desc.ByteWidth = Length;
desc.BindFlags = D3D11_BIND_INDEX_BUFFER;
desc.CPUAccessFlags = convert::cpuFlags(Pool, Usage);
desc.Usage = convert::usage(Pool, Usage);
desc.CPUAccessFlags = convert::cpuFlags(Pool, Usage, D3DRTYPE_INDEXBUFFER);
desc.Usage = convert::usage(Pool, Usage, D3DRTYPE_INDEXBUFFER);
desc.MiscFlags = 0;
desc.StructureByteStride = 0;
......
......@@ -99,14 +99,14 @@ namespace dxup {
if (outTexture == nullptr)
return log::d3derr(D3DERR_INVALIDCALL, "Direct3DTexture9::Create: outTexture was nullptr.");
D3D11_USAGE d3d11Usage = convert::usage(pool, usage);
D3D11_USAGE d3d11Usage = convert::usage(pool, usage, D3DRTYPE_TEXTURE);
D3D11_TEXTURE2D_DESC desc;
desc.Width = width;
desc.Height = height;
desc.Format = convert::format(format);
desc.Usage = d3d11Usage;
desc.CPUAccessFlags = convert::cpuFlags(pool, usage);
desc.CPUAccessFlags = convert::cpuFlags(pool, usage, D3DRTYPE_TEXTURE);
desc.MipLevels = d3d11Usage == D3D11_USAGE_DYNAMIC ? 1 : levels;
desc.ArraySize = 1;
......@@ -118,10 +118,12 @@ namespace dxup {
if (!(usage & D3DUSAGE_DEPTHSTENCIL) && d3d11Usage != D3D11_USAGE_STAGING)
desc.BindFlags |= D3D11_BIND_SHADER_RESOURCE;
desc.BindFlags |= ( (usage & D3DUSAGE_RENDERTARGET) || (usage & D3DUSAGE_AUTOGENMIPMAP) ) ? D3D11_BIND_RENDER_TARGET : 0;
desc.BindFlags |= (usage & D3DUSAGE_DEPTHSTENCIL) ? D3D11_BIND_DEPTH_STENCIL : 0;
if (d3d11Usage != D3D11_USAGE_STAGING) {
desc.BindFlags |= ((usage & D3DUSAGE_RENDERTARGET) || (usage & D3DUSAGE_AUTOGENMIPMAP)) ? D3D11_BIND_RENDER_TARGET : 0;
desc.BindFlags |= (usage & D3DUSAGE_DEPTHSTENCIL) ? D3D11_BIND_DEPTH_STENCIL : 0;
desc.MiscFlags |= (usage & D3DUSAGE_AUTOGENMIPMAP) ? D3D11_RESOURCE_MISC_GENERATE_MIPS : 0;
desc.MiscFlags |= (usage & D3DUSAGE_AUTOGENMIPMAP) ? D3D11_RESOURCE_MISC_GENERATE_MIPS : 0;
}
Com<ID3D11Texture2D> texture;
HRESULT result = device->GetD3D11Device()->CreateTexture2D(&desc, nullptr, &texture);
......@@ -247,12 +249,14 @@ namespace dxup {
if (outTexture == nullptr)
return log::d3derr(D3DERR_INVALIDCALL, "Direct3DCubeTexture9::Create: outTexture was nullptr.");
D3D11_USAGE d3d11Usage = convert::usage(pool, usage, D3DRTYPE_CUBETEXTURE);
D3D11_TEXTURE2D_DESC desc;
desc.Width = edgeLength;
desc.Height = edgeLength;
desc.Format = convert::format(format);
desc.Usage = D3D11_USAGE_DEFAULT;
desc.CPUAccessFlags = 0;
desc.Usage = d3d11Usage;
desc.CPUAccessFlags = convert::cpuFlags(pool, usage, D3DRTYPE_CUBETEXTURE);
desc.MipLevels = levels;
desc.ArraySize = 6;
......@@ -261,9 +265,13 @@ namespace dxup {
desc.BindFlags = 0;
desc.MiscFlags = 0;
// Todo! Investigate below flags:
desc.BindFlags |= ((usage & D3DUSAGE_RENDERTARGET) || (usage & D3DUSAGE_AUTOGENMIPMAP)) ? D3D11_BIND_RENDER_TARGET : 0;
desc.MiscFlags |= (usage & D3DUSAGE_AUTOGENMIPMAP) ? D3D11_RESOURCE_MISC_GENERATE_MIPS : 0;
if (d3d11Usage != D3D11_USAGE_STAGING) {
desc.BindFlags |= D3D11_BIND_SHADER_RESOURCE;
// Todo! Investigate below flags:
desc.BindFlags |= ((usage & D3DUSAGE_RENDERTARGET) || (usage & D3DUSAGE_AUTOGENMIPMAP)) ? D3D11_BIND_RENDER_TARGET : 0;
desc.MiscFlags |= (usage & D3DUSAGE_AUTOGENMIPMAP) ? D3D11_RESOURCE_MISC_GENERATE_MIPS : 0;
}
Com<ID3D11Texture2D> texture;
HRESULT result = device->GetD3D11Device()->CreateTexture2D(&desc, nullptr, &texture);
......@@ -385,14 +393,14 @@ namespace dxup {
if (outTexture == nullptr)
return log::d3derr(D3DERR_INVALIDCALL, "Direct3DVolumeTexture9::Create: outTexture was nullptr.");
D3D11_USAGE d3d11Usage = convert::usage(pool, usage);
D3D11_USAGE d3d11Usage = convert::usage(pool, usage, D3DRTYPE_VOLUMETEXTURE);
D3D11_TEXTURE3D_DESC desc;
desc.Width = width;
desc.Height = height;
desc.Format = convert::format(format);
desc.Usage = d3d11Usage;
desc.CPUAccessFlags = convert::cpuFlags(pool, usage);
desc.CPUAccessFlags = convert::cpuFlags(pool, usage, D3DRTYPE_VOLUMETEXTURE);
desc.MipLevels = d3d11Usage == D3D11_USAGE_DYNAMIC ? 1 : levels;
desc.BindFlags = 0;
desc.MiscFlags = 0;
......
......@@ -185,18 +185,18 @@ namespace dxup {
return scanlineConverter.toT(ScanlineOrdering);
}
D3D11_USAGE usage(D3DPOOL pool, UINT usage) {
D3D11_USAGE usage(D3DPOOL pool, UINT usage, D3DRESOURCETYPE type) {
if (pool == D3DPOOL_SYSTEMMEM || pool == D3DPOOL_SCRATCH)
return D3D11_USAGE_STAGING;
if (usage & D3DUSAGE_DYNAMIC && !(usage & D3DUSAGE_RENDERTARGET) && !(usage & D3DUSAGE_DEPTHSTENCIL) && !(usage & D3DUSAGE_AUTOGENMIPMAP))
if (usage & D3DUSAGE_DYNAMIC && !(usage & D3DUSAGE_RENDERTARGET) && !(usage & D3DUSAGE_DEPTHSTENCIL) && !(usage & D3DUSAGE_AUTOGENMIPMAP) && type != D3DRTYPE_CUBETEXTURE)
return D3D11_USAGE_DYNAMIC;
return D3D11_USAGE_DEFAULT;
}
UINT cpuFlags(D3DPOOL pool, UINT usage) {
D3D11_USAGE d3d11Usage = convert::usage(pool, usage);
UINT cpuFlags(D3DPOOL pool, UINT usage, D3DRESOURCETYPE type) {
D3D11_USAGE d3d11Usage = convert::usage(pool, usage, type);
if (d3d11Usage != D3D11_USAGE_DEFAULT) {
if (usage & D3DUSAGE_WRITEONLY)
return D3D11_CPU_ACCESS_WRITE;
......
......@@ -18,8 +18,8 @@ namespace dxup {
DXGI_MODE_SCANLINE_ORDER scanlineOrdering(D3DSCANLINEORDERING ScanlineOrdering);
D3DSCANLINEORDERING scanlineOrdering(DXGI_MODE_SCANLINE_ORDER ScanlineOrdering);
UINT cpuFlags(D3DPOOL pool, UINT usage);
D3D11_USAGE usage(D3DPOOL pool, UINT usage);
UINT cpuFlags(D3DPOOL pool, UINT usage, D3DRESOURCETYPE type);
D3D11_USAGE usage(D3DPOOL pool, UINT usage, D3DRESOURCETYPE type);
UINT primitiveData(D3DPRIMITIVETYPE type, UINT count, D3D_PRIMITIVE_TOPOLOGY& topology);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment