mirror of
https://github.com/libretro/RetroArch
synced 2025-01-29 18:32:44 +00:00
(D3D10/11/12) Miscellaneous corrections/safety checks
This commit is contained in:
parent
65ab04e775
commit
8ec1f3294e
@ -58,29 +58,6 @@ HRESULT WINAPI D3D10CreateDeviceAndSwapChain(
|
||||
}
|
||||
#endif
|
||||
|
||||
static DXGI_FORMAT
|
||||
d3d10_get_closest_match(D3D10Device device,
|
||||
DXGI_FORMAT desired_format, UINT desired_format_support)
|
||||
{
|
||||
DXGI_FORMAT default_list[] = {desired_format, DXGI_FORMAT_UNKNOWN};
|
||||
DXGI_FORMAT* format = dxgi_get_format_fallback_list(desired_format);
|
||||
|
||||
if(!format)
|
||||
format = default_list;
|
||||
|
||||
while (*format != DXGI_FORMAT_UNKNOWN)
|
||||
{
|
||||
UINT format_support;
|
||||
if (SUCCEEDED(device->lpVtbl->CheckFormatSupport(device, *format,
|
||||
&format_support)) &&
|
||||
((format_support & desired_format_support) == desired_format_support))
|
||||
break;
|
||||
format++;
|
||||
}
|
||||
assert(*format);
|
||||
return *format;
|
||||
}
|
||||
|
||||
void d3d10_init_texture(D3D10Device device, d3d10_texture_t* texture)
|
||||
{
|
||||
bool is_render_target = texture->desc.BindFlags & D3D10_BIND_RENDER_TARGET;
|
||||
@ -182,3 +159,95 @@ void d3d10_update_texture(
|
||||
if (texture->desc.MiscFlags & D3D10_RESOURCE_MISC_GENERATE_MIPS)
|
||||
ctx->lpVtbl->GenerateMips(ctx, texture->view);
|
||||
}
|
||||
|
||||
DXGI_FORMAT
|
||||
d3d10_get_closest_match(D3D10Device device,
|
||||
DXGI_FORMAT desired_format, UINT desired_format_support)
|
||||
{
|
||||
DXGI_FORMAT default_list[] = {desired_format, DXGI_FORMAT_UNKNOWN};
|
||||
DXGI_FORMAT* format = dxgi_get_format_fallback_list(desired_format);
|
||||
|
||||
if(!format)
|
||||
format = default_list;
|
||||
|
||||
while (*format != DXGI_FORMAT_UNKNOWN)
|
||||
{
|
||||
UINT format_support;
|
||||
if (SUCCEEDED(device->lpVtbl->CheckFormatSupport(device, *format,
|
||||
&format_support)) &&
|
||||
((format_support & desired_format_support) == desired_format_support))
|
||||
break;
|
||||
format++;
|
||||
}
|
||||
assert(*format);
|
||||
return *format;
|
||||
}
|
||||
|
||||
bool d3d10_init_shader(
|
||||
D3D10Device device,
|
||||
const char* src,
|
||||
size_t size,
|
||||
const void* src_name,
|
||||
LPCSTR vs_entry,
|
||||
LPCSTR ps_entry,
|
||||
LPCSTR gs_entry,
|
||||
const D3D10_INPUT_ELEMENT_DESC* input_element_descs,
|
||||
UINT num_elements,
|
||||
d3d10_shader_t* out)
|
||||
{
|
||||
D3DBlob vs_code = NULL;
|
||||
D3DBlob ps_code = NULL;
|
||||
D3DBlob gs_code = NULL;
|
||||
|
||||
bool success = true;
|
||||
|
||||
if (!src) /* LPCWSTR filename */
|
||||
{
|
||||
if (vs_entry && !d3d_compile_from_file((LPCWSTR)src_name, vs_entry, "vs_4_0", &vs_code))
|
||||
success = false;
|
||||
if (ps_entry && !d3d_compile_from_file((LPCWSTR)src_name, ps_entry, "ps_4_0", &ps_code))
|
||||
success = false;
|
||||
if (gs_entry && !d3d_compile_from_file((LPCWSTR)src_name, gs_entry, "gs_4_0", &gs_code))
|
||||
success = false;
|
||||
}
|
||||
else /* char array */
|
||||
{
|
||||
if (vs_entry && !d3d_compile(src, size, (LPCSTR)src_name, vs_entry, "vs_4_0", &vs_code))
|
||||
success = false;
|
||||
if (ps_entry && !d3d_compile(src, size, (LPCSTR)src_name, ps_entry, "ps_4_0", &ps_code))
|
||||
success = false;
|
||||
if (gs_entry && !d3d_compile(src, size, (LPCSTR)src_name, gs_entry, "gs_4_0", &gs_code))
|
||||
success = false;
|
||||
}
|
||||
|
||||
|
||||
if (ps_code)
|
||||
device->lpVtbl->CreatePixelShader(device,
|
||||
ps_code->lpVtbl->GetBufferPointer(ps_code),
|
||||
ps_code->lpVtbl->GetBufferSize(ps_code),
|
||||
&out->ps);
|
||||
|
||||
if (gs_code)
|
||||
device->lpVtbl->CreateGeometryShader(
|
||||
device,
|
||||
gs_code->lpVtbl->GetBufferPointer(gs_code),
|
||||
gs_code->lpVtbl->GetBufferSize(gs_code),
|
||||
&out->gs);
|
||||
|
||||
if (vs_code)
|
||||
{
|
||||
LPVOID buf_ptr = vs_code->lpVtbl->GetBufferPointer(vs_code);
|
||||
SIZE_T buf_size = vs_code->lpVtbl->GetBufferSize(vs_code);
|
||||
device->lpVtbl->CreateVertexShader(device, buf_ptr, buf_size, &out->vs);
|
||||
if (input_element_descs)
|
||||
device->lpVtbl->CreateInputLayout(
|
||||
device, (D3D10_INPUT_ELEMENT_DESC*)input_element_descs,
|
||||
num_elements, buf_ptr, buf_size, &out->layout);
|
||||
}
|
||||
|
||||
Release(vs_code);
|
||||
Release(ps_code);
|
||||
Release(gs_code);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
@ -250,6 +250,21 @@ void d3d10_update_texture(
|
||||
const void* data,
|
||||
d3d10_texture_t* texture);
|
||||
|
||||
DXGI_FORMAT d3d10_get_closest_match(
|
||||
D3D10Device device, DXGI_FORMAT desired_format, UINT desired_format_support);
|
||||
|
||||
bool d3d10_init_shader(
|
||||
D3D10Device device,
|
||||
const char* src,
|
||||
size_t size,
|
||||
const void* src_name,
|
||||
LPCSTR vs_entry,
|
||||
LPCSTR ps_entry,
|
||||
LPCSTR gs_entry,
|
||||
const D3D10_INPUT_ELEMENT_DESC* input_element_descs,
|
||||
UINT num_elements,
|
||||
d3d10_shader_t* out);
|
||||
|
||||
static INLINE void d3d10_release_shader(d3d10_shader_t* shader)
|
||||
{
|
||||
Release(shader->layout);
|
||||
@ -258,6 +273,15 @@ static INLINE void d3d10_release_shader(d3d10_shader_t* shader)
|
||||
Release(shader->gs);
|
||||
}
|
||||
|
||||
static INLINE DXGI_FORMAT
|
||||
d3d10_get_closest_match_texture2D(D3D10Device device, DXGI_FORMAT desired_format)
|
||||
{
|
||||
return d3d10_get_closest_match(
|
||||
device, desired_format,
|
||||
D3D10_FORMAT_SUPPORT_TEXTURE2D
|
||||
| D3D10_FORMAT_SUPPORT_SHADER_SAMPLE);
|
||||
}
|
||||
|
||||
static INLINE void d3d10_set_shader(D3D10Device ctx, d3d10_shader_t* shader)
|
||||
{
|
||||
ctx->lpVtbl->IASetInputLayout(ctx, shader->layout);
|
||||
|
@ -49,30 +49,36 @@ HRESULT WINAPI D3D11CreateDevice(
|
||||
pAdapter, DriverType, Software, Flags, pFeatureLevels, FeatureLevels, SDKVersion,
|
||||
ppDevice, pFeatureLevel, ppImmediateContext);
|
||||
}
|
||||
#endif
|
||||
|
||||
static DXGI_FORMAT
|
||||
d3d11_get_closest_match(D3D11Device device, DXGI_FORMAT desired_format, UINT desired_format_support)
|
||||
HRESULT WINAPI D3D11CreateDeviceAndSwapChain(
|
||||
IDXGIAdapter* pAdapter,
|
||||
D3D_DRIVER_TYPE DriverType,
|
||||
HMODULE Software,
|
||||
UINT Flags,
|
||||
CONST D3D_FEATURE_LEVEL* pFeatureLevels,
|
||||
UINT FeatureLevels,
|
||||
UINT SDKVersion,
|
||||
CONST DXGI_SWAP_CHAIN_DESC* pSwapChainDesc,
|
||||
IDXGISwapChain** ppSwapChain,
|
||||
ID3D11Device** ppDevice,
|
||||
D3D_FEATURE_LEVEL* pFeatureLevel,
|
||||
ID3D11DeviceContext** ppImmediateContext)
|
||||
{
|
||||
DXGI_FORMAT default_list[] = {desired_format, DXGI_FORMAT_UNKNOWN};
|
||||
DXGI_FORMAT* format = dxgi_get_format_fallback_list(desired_format);
|
||||
static dylib_t d3d11_dll;
|
||||
static PFN_D3D11_CREATE_DEVICE_AND_SWAP_CHAIN fp;
|
||||
|
||||
if(!format)
|
||||
format = default_list;
|
||||
|
||||
while (*format != DXGI_FORMAT_UNKNOWN)
|
||||
{
|
||||
UINT format_support;
|
||||
if (SUCCEEDED(device->lpVtbl->CheckFormatSupport(device, *format,
|
||||
&format_support)) &&
|
||||
((format_support & desired_format_support) == desired_format_support))
|
||||
break;
|
||||
format++;
|
||||
}
|
||||
assert(*format);
|
||||
return *format;
|
||||
if (!d3d11_dll)
|
||||
if (!(d3d11_dll = dylib_load("d3d11.dll")))
|
||||
return TYPE_E_CANTLOADLIBRARY;
|
||||
if (!fp)
|
||||
if (!(fp = (PFN_D3D11_CREATE_DEVICE_AND_SWAP_CHAIN)dylib_proc(
|
||||
d3d11_dll, "D3D11CreateDeviceAndSwapChain")))
|
||||
return TYPE_E_DLLFUNCTIONNOTFOUND;
|
||||
return fp(
|
||||
pAdapter, DriverType, Software, Flags, pFeatureLevels, FeatureLevels, SDKVersion,
|
||||
pSwapChainDesc, ppSwapChain, ppDevice, pFeatureLevel, ppImmediateContext);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void d3d11_init_texture(D3D11Device device, d3d11_texture_t* texture)
|
||||
{
|
||||
@ -175,3 +181,115 @@ void d3d11_update_texture(
|
||||
if (texture->desc.MiscFlags & D3D11_RESOURCE_MISC_GENERATE_MIPS)
|
||||
ctx->lpVtbl->GenerateMips(ctx, texture->view);
|
||||
}
|
||||
|
||||
DXGI_FORMAT
|
||||
d3d11_get_closest_match(D3D11Device device, DXGI_FORMAT desired_format, UINT desired_format_support)
|
||||
{
|
||||
DXGI_FORMAT default_list[] = {desired_format, DXGI_FORMAT_UNKNOWN};
|
||||
DXGI_FORMAT* format = dxgi_get_format_fallback_list(desired_format);
|
||||
|
||||
if(!format)
|
||||
format = default_list;
|
||||
|
||||
while (*format != DXGI_FORMAT_UNKNOWN)
|
||||
{
|
||||
UINT format_support;
|
||||
if (SUCCEEDED(device->lpVtbl->CheckFormatSupport(device, *format,
|
||||
&format_support)) &&
|
||||
((format_support & desired_format_support) == desired_format_support))
|
||||
break;
|
||||
format++;
|
||||
}
|
||||
assert(*format);
|
||||
return *format;
|
||||
}
|
||||
|
||||
bool d3d11_init_shader(
|
||||
D3D11Device device,
|
||||
const char* src,
|
||||
size_t size,
|
||||
const void* src_name,
|
||||
LPCSTR vs_entry,
|
||||
LPCSTR ps_entry,
|
||||
LPCSTR gs_entry,
|
||||
const D3D11_INPUT_ELEMENT_DESC* input_element_descs,
|
||||
UINT num_elements,
|
||||
d3d11_shader_t* out,
|
||||
enum d3d11_feature_level_hint hint)
|
||||
{
|
||||
D3DBlob vs_code = NULL;
|
||||
D3DBlob ps_code = NULL;
|
||||
D3DBlob gs_code = NULL;
|
||||
bool success = true;
|
||||
const char *vs_str = NULL;
|
||||
const char *ps_str = NULL;
|
||||
const char *gs_str = NULL;
|
||||
|
||||
switch (hint)
|
||||
{
|
||||
case D3D11_FEATURE_LEVEL_HINT_11_0:
|
||||
case D3D11_FEATURE_LEVEL_HINT_11_1:
|
||||
case D3D11_FEATURE_LEVEL_HINT_12_0:
|
||||
case D3D11_FEATURE_LEVEL_HINT_12_1:
|
||||
case D3D11_FEATURE_LEVEL_HINT_12_2:
|
||||
vs_str = "vs_5_0";
|
||||
ps_str = "ps_5_0";
|
||||
gs_str = "gs_5_0";
|
||||
break;
|
||||
case D3D11_FEATURE_LEVEL_HINT_DONTCARE:
|
||||
default:
|
||||
vs_str = "vs_4_0";
|
||||
ps_str = "ps_4_0";
|
||||
gs_str = "gs_4_0";
|
||||
break;
|
||||
}
|
||||
|
||||
if (!src) /* LPCWSTR filename */
|
||||
{
|
||||
if (vs_entry && !d3d_compile_from_file((LPCWSTR)src_name, vs_entry, vs_str, &vs_code))
|
||||
success = false;
|
||||
if (ps_entry && !d3d_compile_from_file((LPCWSTR)src_name, ps_entry, ps_str, &ps_code))
|
||||
success = false;
|
||||
if (gs_entry && !d3d_compile_from_file((LPCWSTR)src_name, gs_entry, gs_str, &gs_code))
|
||||
success = false;
|
||||
}
|
||||
else /* char array */
|
||||
{
|
||||
if (vs_entry && !d3d_compile(src, size, (LPCSTR)src_name, vs_entry, vs_str, &vs_code))
|
||||
success = false;
|
||||
if (ps_entry && !d3d_compile(src, size, (LPCSTR)src_name, ps_entry, ps_str, &ps_code))
|
||||
success = false;
|
||||
if (gs_entry && !d3d_compile(src, size, (LPCSTR)src_name, gs_entry, gs_str, &gs_code))
|
||||
success = false;
|
||||
}
|
||||
|
||||
if (ps_code)
|
||||
device->lpVtbl->CreatePixelShader(
|
||||
device,
|
||||
ps_code->lpVtbl->GetBufferPointer(ps_code),
|
||||
ps_code->lpVtbl->GetBufferSize(ps_code),
|
||||
NULL, &out->ps);
|
||||
|
||||
if (gs_code)
|
||||
device->lpVtbl->CreateGeometryShader(
|
||||
device,
|
||||
gs_code->lpVtbl->GetBufferPointer(gs_code),
|
||||
gs_code->lpVtbl->GetBufferSize(gs_code),
|
||||
NULL, &out->gs);
|
||||
|
||||
if (vs_code)
|
||||
{
|
||||
LPVOID buf_ptr = vs_code->lpVtbl->GetBufferPointer(vs_code);
|
||||
SIZE_T buf_size = vs_code->lpVtbl->GetBufferSize(vs_code);
|
||||
device->lpVtbl->CreateVertexShader(device, buf_ptr, buf_size, NULL, &out->vs);
|
||||
if (input_element_descs)
|
||||
device->lpVtbl->CreateInputLayout(device, input_element_descs, num_elements,
|
||||
buf_ptr, buf_size, &out->layout);
|
||||
}
|
||||
|
||||
Release(vs_code);
|
||||
Release(ps_code);
|
||||
Release(gs_code);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
@ -314,3 +314,19 @@ void d3d11_update_texture(
|
||||
DXGI_FORMAT format,
|
||||
const void* data,
|
||||
d3d11_texture_t* texture);
|
||||
|
||||
DXGI_FORMAT d3d11_get_closest_match(
|
||||
D3D11Device device, DXGI_FORMAT desired_format, UINT desired_format_support);
|
||||
|
||||
bool d3d11_init_shader(
|
||||
D3D11Device device,
|
||||
const char* src,
|
||||
size_t size,
|
||||
const void* src_name,
|
||||
LPCSTR vs_entry,
|
||||
LPCSTR ps_entry,
|
||||
LPCSTR gs_entry,
|
||||
const D3D11_INPUT_ELEMENT_DESC* input_element_descs,
|
||||
UINT num_elements,
|
||||
d3d11_shader_t* out,
|
||||
enum d3d11_feature_level_hint hint);
|
||||
|
@ -155,26 +155,16 @@ d3d12_descriptor_heap_slot_free(d3d12_descriptor_heap_t* heap, D3D12_CPU_DESCRIP
|
||||
D3D12_GPU_VIRTUAL_ADDRESS
|
||||
d3d12_create_buffer(D3D12Device device, UINT size_in_bytes, D3D12Resource* buffer)
|
||||
{
|
||||
D3D12_RESOURCE_DESC resource_desc;
|
||||
D3D12_HEAP_PROPERTIES heap_props;
|
||||
D3D12_HEAP_PROPERTIES heap_props = { D3D12_HEAP_TYPE_UPLOAD, D3D12_CPU_PAGE_PROPERTY_UNKNOWN,
|
||||
D3D12_MEMORY_POOL_UNKNOWN, 1, 1 };
|
||||
D3D12_RESOURCE_DESC resource_desc = { D3D12_RESOURCE_DIMENSION_BUFFER };
|
||||
|
||||
heap_props.Type = D3D12_HEAP_TYPE_UPLOAD;
|
||||
heap_props.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN;
|
||||
heap_props.MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN;
|
||||
heap_props.CreationNodeMask = 1;
|
||||
heap_props.VisibleNodeMask = 1;
|
||||
|
||||
resource_desc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER;
|
||||
resource_desc.Alignment = 0;
|
||||
resource_desc.Width = size_in_bytes;
|
||||
resource_desc.Height = 1;
|
||||
resource_desc.DepthOrArraySize = 1;
|
||||
resource_desc.MipLevels = 1;
|
||||
resource_desc.Format = DXGI_FORMAT_UNKNOWN;
|
||||
resource_desc.SampleDesc.Count = 1;
|
||||
resource_desc.SampleDesc.Quality = 0;
|
||||
resource_desc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR;
|
||||
resource_desc.Flags = D3D12_RESOURCE_FLAG_NONE;
|
||||
|
||||
D3D12CreateCommittedResource(
|
||||
device, (D3D12_HEAP_PROPERTIES*)&heap_props, D3D12_HEAP_FLAG_NONE, &resource_desc,
|
||||
@ -269,34 +259,26 @@ void d3d12_init_texture(D3D12Device device, d3d12_texture_t* texture)
|
||||
}
|
||||
|
||||
{
|
||||
D3D12_HEAP_PROPERTIES heap_props;
|
||||
D3D12_FEATURE_DATA_FORMAT_SUPPORT format_support;
|
||||
|
||||
heap_props.Type = D3D12_HEAP_TYPE_DEFAULT;
|
||||
heap_props.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN;
|
||||
heap_props.MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN;
|
||||
heap_props.CreationNodeMask = 1;
|
||||
heap_props.VisibleNodeMask = 1;
|
||||
|
||||
format_support.Format = texture->desc.Format;
|
||||
format_support.Support1 = D3D12_FORMAT_SUPPORT1_TEXTURE2D | D3D12_FORMAT_SUPPORT1_SHADER_SAMPLE;
|
||||
D3D12_FEATURE_DATA_FORMAT_SUPPORT format_support = {
|
||||
texture->desc.Format, D3D12_FORMAT_SUPPORT1_TEXTURE2D | D3D12_FORMAT_SUPPORT1_SHADER_SAMPLE
|
||||
};
|
||||
D3D12_HEAP_PROPERTIES heap_props = { D3D12_HEAP_TYPE_DEFAULT, D3D12_CPU_PAGE_PROPERTY_UNKNOWN,
|
||||
D3D12_MEMORY_POOL_UNKNOWN, 1, 1 };
|
||||
|
||||
if (texture->desc.MipLevels > 1)
|
||||
{
|
||||
texture->desc.Flags |= D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS;
|
||||
format_support.Support1 |= D3D12_FORMAT_SUPPORT1_MIP;
|
||||
format_support.Support2 = D3D12_FORMAT_SUPPORT2_UAV_TYPED_STORE;
|
||||
texture->desc.Flags |= D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS;
|
||||
format_support.Support1 |= D3D12_FORMAT_SUPPORT1_MIP;
|
||||
format_support.Support2 |= D3D12_FORMAT_SUPPORT2_UAV_TYPED_STORE;
|
||||
}
|
||||
else
|
||||
format_support.Support2 = D3D12_FORMAT_SUPPORT2_NONE;
|
||||
|
||||
if (texture->desc.Flags & D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET)
|
||||
format_support.Support1 |= D3D12_FORMAT_SUPPORT1_RENDER_TARGET;
|
||||
format_support.Support1 |= D3D12_FORMAT_SUPPORT1_RENDER_TARGET;
|
||||
|
||||
texture->desc.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D;
|
||||
texture->desc.DepthOrArraySize = 1;
|
||||
texture->desc.SampleDesc.Count = 1;
|
||||
texture->desc.Format = d3d12_get_closest_match(device, &format_support);
|
||||
texture->desc.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D;
|
||||
texture->desc.DepthOrArraySize = 1;
|
||||
texture->desc.SampleDesc.Count = 1;
|
||||
texture->desc.Format = d3d12_get_closest_match(device, &format_support);
|
||||
|
||||
D3D12CreateCommittedResource(
|
||||
device, &heap_props, D3D12_HEAP_FLAG_NONE, &texture->desc,
|
||||
@ -308,29 +290,27 @@ void d3d12_init_texture(D3D12Device device, d3d12_texture_t* texture)
|
||||
{
|
||||
D3D12_SHADER_RESOURCE_VIEW_DESC desc = { texture->desc.Format };
|
||||
|
||||
desc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D;
|
||||
desc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING;
|
||||
desc.Texture2D.MipLevels = texture->desc.MipLevels;
|
||||
desc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING;
|
||||
desc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D;
|
||||
desc.Texture2D.MipLevels = texture->desc.MipLevels;
|
||||
|
||||
texture->cpu_descriptor[0] = d3d12_descriptor_heap_slot_alloc(texture->srv_heap);
|
||||
texture->cpu_descriptor[0] = d3d12_descriptor_heap_slot_alloc(texture->srv_heap);
|
||||
D3D12CreateShaderResourceView(device, texture->handle, &desc, texture->cpu_descriptor[0]);
|
||||
texture->gpu_descriptor[0].ptr = texture->cpu_descriptor[0].ptr - texture->srv_heap->cpu.ptr +
|
||||
texture->gpu_descriptor[0].ptr = texture->cpu_descriptor[0].ptr - texture->srv_heap->cpu.ptr +
|
||||
texture->srv_heap->gpu.ptr;
|
||||
}
|
||||
|
||||
for (i = 1; i < texture->desc.MipLevels; i++)
|
||||
{
|
||||
D3D12_UNORDERED_ACCESS_VIEW_DESC desc;
|
||||
D3D12_UNORDERED_ACCESS_VIEW_DESC desc = { texture->desc.Format };
|
||||
|
||||
desc.Format = texture->desc.Format;
|
||||
desc.ViewDimension = D3D12_UAV_DIMENSION_TEXTURE2D;
|
||||
desc.Texture2D.MipSlice = i;
|
||||
desc.Texture2D.PlaneSlice = 0;
|
||||
desc.ViewDimension = D3D12_UAV_DIMENSION_TEXTURE2D;
|
||||
desc.Texture2D.MipSlice = i;
|
||||
|
||||
texture->cpu_descriptor[i] = d3d12_descriptor_heap_slot_alloc(texture->srv_heap);
|
||||
texture->cpu_descriptor[i] = d3d12_descriptor_heap_slot_alloc(texture->srv_heap);
|
||||
D3D12CreateUnorderedAccessView(
|
||||
device, texture->handle, NULL, &desc, texture->cpu_descriptor[i]);
|
||||
texture->gpu_descriptor[i].ptr = texture->cpu_descriptor[i].ptr - texture->srv_heap->cpu.ptr +
|
||||
texture->gpu_descriptor[i].ptr = texture->cpu_descriptor[i].ptr - texture->srv_heap->cpu.ptr +
|
||||
texture->srv_heap->gpu.ptr;
|
||||
}
|
||||
|
||||
@ -341,39 +321,30 @@ void d3d12_init_texture(D3D12Device device, d3d12_texture_t* texture)
|
||||
}
|
||||
else
|
||||
{
|
||||
D3D12_HEAP_PROPERTIES heap_props;
|
||||
D3D12_RESOURCE_DESC buffer_desc;
|
||||
D3D12_HEAP_PROPERTIES heap_props = { D3D12_HEAP_TYPE_UPLOAD, D3D12_CPU_PAGE_PROPERTY_UNKNOWN,
|
||||
D3D12_MEMORY_POOL_UNKNOWN, 1, 1 };
|
||||
D3D12_RESOURCE_DESC buffer_desc = { D3D12_RESOURCE_DIMENSION_BUFFER };
|
||||
|
||||
D3D12GetCopyableFootprints(
|
||||
device, &texture->desc, 0, 1, 0, &texture->layout, &texture->num_rows,
|
||||
&texture->row_size_in_bytes, &texture->total_bytes);
|
||||
|
||||
heap_props.Type = D3D12_HEAP_TYPE_UPLOAD;
|
||||
heap_props.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN;
|
||||
heap_props.MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN;
|
||||
heap_props.CreationNodeMask = 1;
|
||||
heap_props.VisibleNodeMask = 1;
|
||||
|
||||
buffer_desc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER;
|
||||
buffer_desc.Alignment = 0;
|
||||
buffer_desc.Width = texture->total_bytes;
|
||||
buffer_desc.Height = 1;
|
||||
buffer_desc.DepthOrArraySize = 1;
|
||||
buffer_desc.MipLevels = 1;
|
||||
buffer_desc.SampleDesc.Count = 1;
|
||||
buffer_desc.SampleDesc.Quality = 0;
|
||||
buffer_desc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR;
|
||||
buffer_desc.Flags = D3D12_RESOURCE_FLAG_NONE;
|
||||
buffer_desc.Width = texture->total_bytes;
|
||||
buffer_desc.Height = 1;
|
||||
buffer_desc.DepthOrArraySize = 1;
|
||||
buffer_desc.MipLevels = 1;
|
||||
buffer_desc.SampleDesc.Count = 1;
|
||||
buffer_desc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR;
|
||||
|
||||
D3D12CreateCommittedResource(
|
||||
device, &heap_props, D3D12_HEAP_FLAG_NONE, &buffer_desc,
|
||||
D3D12_RESOURCE_STATE_GENERIC_READ, NULL, &texture->upload_buffer);
|
||||
}
|
||||
|
||||
texture->size_data.x = texture->desc.Width;
|
||||
texture->size_data.y = texture->desc.Height;
|
||||
texture->size_data.z = 1.0f / texture->desc.Width;
|
||||
texture->size_data.w = 1.0f / texture->desc.Height;
|
||||
texture->size_data.x = texture->desc.Width;
|
||||
texture->size_data.y = texture->desc.Height;
|
||||
texture->size_data.z = 1.0f / texture->desc.Width;
|
||||
texture->size_data.w = 1.0f / texture->desc.Height;
|
||||
}
|
||||
|
||||
void d3d12_update_texture(
|
||||
@ -409,9 +380,9 @@ void d3d12_upload_texture(D3D12GraphicsCommandList cmd,
|
||||
{
|
||||
D3D12_TEXTURE_COPY_LOCATION src, dst;
|
||||
|
||||
src.pResource = texture->upload_buffer;
|
||||
src.Type = D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT;
|
||||
src.PlacedFootprint = texture->layout;
|
||||
src.pResource = texture->upload_buffer;
|
||||
src.Type = D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT;
|
||||
src.PlacedFootprint = texture->layout;
|
||||
|
||||
dst.pResource = texture->handle;
|
||||
dst.Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX;
|
||||
@ -447,13 +418,11 @@ void d3d12_upload_texture(D3D12GraphicsCommandList cmd,
|
||||
} cbuffer = { i - 1, { 1.0f / width, 1.0f / height } };
|
||||
|
||||
{
|
||||
D3D12_RESOURCE_BARRIER barrier;
|
||||
barrier.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
|
||||
barrier.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE;
|
||||
D3D12_RESOURCE_BARRIER barrier = { D3D12_RESOURCE_BARRIER_TYPE_TRANSITION };
|
||||
barrier.Transition.pResource = texture->handle;
|
||||
barrier.Transition.Subresource = i;
|
||||
barrier.Transition.StateBefore = D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE;
|
||||
barrier.Transition.StateAfter = D3D12_RESOURCE_STATE_UNORDERED_ACCESS;
|
||||
barrier.Transition.Subresource = i;
|
||||
D3D12ResourceBarrier(cmd, 1, &barrier);
|
||||
}
|
||||
|
||||
@ -463,21 +432,17 @@ void d3d12_upload_texture(D3D12GraphicsCommandList cmd,
|
||||
D3D12Dispatch(cmd, (width + 0x7) >> 3, (height + 0x7) >> 3, 1);
|
||||
|
||||
{
|
||||
D3D12_RESOURCE_BARRIER barrier;
|
||||
barrier.Type = D3D12_RESOURCE_BARRIER_TYPE_UAV;
|
||||
barrier.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE;
|
||||
D3D12_RESOURCE_BARRIER barrier = { D3D12_RESOURCE_BARRIER_TYPE_UAV };
|
||||
barrier.UAV.pResource = texture->handle;
|
||||
D3D12ResourceBarrier(cmd, 1, &barrier);
|
||||
}
|
||||
|
||||
{
|
||||
D3D12_RESOURCE_BARRIER barrier;
|
||||
barrier.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
|
||||
barrier.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE;
|
||||
D3D12_RESOURCE_BARRIER barrier = { D3D12_RESOURCE_BARRIER_TYPE_TRANSITION };
|
||||
barrier.Transition.pResource = texture->handle;
|
||||
barrier.Transition.Subresource = i;
|
||||
barrier.Transition.StateBefore = D3D12_RESOURCE_STATE_UNORDERED_ACCESS;
|
||||
barrier.Transition.StateAfter = D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE;
|
||||
barrier.Transition.Subresource = i;
|
||||
D3D12ResourceBarrier(cmd, 1, &barrier);
|
||||
}
|
||||
}
|
||||
|
@ -374,75 +374,6 @@ static void d3d10_free_shader_preset(d3d10_video_t* d3d10)
|
||||
d3d10->resize_render_targets = false;
|
||||
}
|
||||
|
||||
static bool d3d10_init_shader(
|
||||
D3D10Device device,
|
||||
const char* src,
|
||||
size_t size,
|
||||
const void* src_name,
|
||||
LPCSTR vs_entry,
|
||||
LPCSTR ps_entry,
|
||||
LPCSTR gs_entry,
|
||||
const D3D10_INPUT_ELEMENT_DESC* input_element_descs,
|
||||
UINT num_elements,
|
||||
d3d10_shader_t* out)
|
||||
{
|
||||
D3DBlob vs_code = NULL;
|
||||
D3DBlob ps_code = NULL;
|
||||
D3DBlob gs_code = NULL;
|
||||
|
||||
bool success = true;
|
||||
|
||||
if (!src) /* LPCWSTR filename */
|
||||
{
|
||||
if (vs_entry && !d3d_compile_from_file((LPCWSTR)src_name, vs_entry, "vs_4_0", &vs_code))
|
||||
success = false;
|
||||
if (ps_entry && !d3d_compile_from_file((LPCWSTR)src_name, ps_entry, "ps_4_0", &ps_code))
|
||||
success = false;
|
||||
if (gs_entry && !d3d_compile_from_file((LPCWSTR)src_name, gs_entry, "gs_4_0", &gs_code))
|
||||
success = false;
|
||||
}
|
||||
else /* char array */
|
||||
{
|
||||
if (vs_entry && !d3d_compile(src, size, (LPCSTR)src_name, vs_entry, "vs_4_0", &vs_code))
|
||||
success = false;
|
||||
if (ps_entry && !d3d_compile(src, size, (LPCSTR)src_name, ps_entry, "ps_4_0", &ps_code))
|
||||
success = false;
|
||||
if (gs_entry && !d3d_compile(src, size, (LPCSTR)src_name, gs_entry, "gs_4_0", &gs_code))
|
||||
success = false;
|
||||
}
|
||||
|
||||
|
||||
if (ps_code)
|
||||
device->lpVtbl->CreatePixelShader(device,
|
||||
ps_code->lpVtbl->GetBufferPointer(ps_code),
|
||||
ps_code->lpVtbl->GetBufferSize(ps_code),
|
||||
&out->ps);
|
||||
|
||||
if (gs_code)
|
||||
device->lpVtbl->CreateGeometryShader(
|
||||
device,
|
||||
gs_code->lpVtbl->GetBufferPointer(gs_code),
|
||||
gs_code->lpVtbl->GetBufferSize(gs_code),
|
||||
&out->gs);
|
||||
|
||||
if (vs_code)
|
||||
{
|
||||
LPVOID buf_ptr = vs_code->lpVtbl->GetBufferPointer(vs_code);
|
||||
SIZE_T buf_size = vs_code->lpVtbl->GetBufferSize(vs_code);
|
||||
device->lpVtbl->CreateVertexShader(device, buf_ptr, buf_size, &out->vs);
|
||||
if (input_element_descs)
|
||||
device->lpVtbl->CreateInputLayout(
|
||||
device, (D3D10_INPUT_ELEMENT_DESC*)input_element_descs,
|
||||
num_elements, buf_ptr, buf_size, &out->layout);
|
||||
}
|
||||
|
||||
Release(vs_code);
|
||||
Release(ps_code);
|
||||
Release(gs_code);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
static bool d3d10_gfx_set_shader(void* data, enum rarch_shader_type type, const char* path)
|
||||
{
|
||||
#if defined(HAVE_SLANG) && defined(HAVE_SPIRV_CROSS)
|
||||
@ -1193,7 +1124,7 @@ static void d3d10_init_history(d3d10_video_t* d3d10, unsigned width, unsigned he
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
/* todo: should we init history to max_width/max_height instead ?
|
||||
/* TODO/FIXME: should we init history to max_width/max_height instead ?
|
||||
* to prevent out of memory errors happening several frames later
|
||||
* and to reduce memory fragmentation */
|
||||
|
||||
@ -1408,7 +1339,7 @@ static bool d3d10_gfx_frame(
|
||||
else
|
||||
{
|
||||
int k;
|
||||
/* todo: what about frame-duping ?
|
||||
/* TODO/FIXME: what about frame-duping ?
|
||||
* maybe clone d3d10_texture_t with AddRef */
|
||||
d3d10_texture_t tmp = d3d10->frame.texture[d3d10->shader_preset->history_size];
|
||||
for (k = d3d10->shader_preset->history_size; k > 0; k--)
|
||||
|
@ -82,15 +82,6 @@ static D3D11Device cached_device_d3d11;
|
||||
static D3D_FEATURE_LEVEL cached_supportedFeatureLevel;
|
||||
static D3D11DeviceContext cached_context_d3d11;
|
||||
|
||||
/* Waitable swap chain */
|
||||
static void D3D11WaitOnSwapChain(HANDLE frameLatencyWaitableObject)
|
||||
{
|
||||
DWORD result = WaitForSingleObjectEx(
|
||||
frameLatencyWaitableObject,
|
||||
1000,
|
||||
true);
|
||||
}
|
||||
|
||||
static INLINE void d3d11_release_shader(d3d11_shader_t* shader)
|
||||
{
|
||||
Release(shader->layout);
|
||||
@ -530,96 +521,6 @@ static void d3d11_free_shader_preset(d3d11_video_t* d3d11)
|
||||
d3d11->resize_render_targets = false;
|
||||
}
|
||||
|
||||
static bool d3d11_init_shader(
|
||||
D3D11Device device,
|
||||
const char* src,
|
||||
size_t size,
|
||||
const void* src_name,
|
||||
LPCSTR vs_entry,
|
||||
LPCSTR ps_entry,
|
||||
LPCSTR gs_entry,
|
||||
const D3D11_INPUT_ELEMENT_DESC* input_element_descs,
|
||||
UINT num_elements,
|
||||
d3d11_shader_t* out,
|
||||
enum d3d11_feature_level_hint hint)
|
||||
{
|
||||
D3DBlob vs_code = NULL;
|
||||
D3DBlob ps_code = NULL;
|
||||
D3DBlob gs_code = NULL;
|
||||
bool success = true;
|
||||
const char *vs_str = NULL;
|
||||
const char *ps_str = NULL;
|
||||
const char *gs_str = NULL;
|
||||
|
||||
switch (hint)
|
||||
{
|
||||
case D3D11_FEATURE_LEVEL_HINT_11_0:
|
||||
case D3D11_FEATURE_LEVEL_HINT_11_1:
|
||||
case D3D11_FEATURE_LEVEL_HINT_12_0:
|
||||
case D3D11_FEATURE_LEVEL_HINT_12_1:
|
||||
case D3D11_FEATURE_LEVEL_HINT_12_2:
|
||||
vs_str = "vs_5_0";
|
||||
ps_str = "ps_5_0";
|
||||
gs_str = "gs_5_0";
|
||||
break;
|
||||
case D3D11_FEATURE_LEVEL_HINT_DONTCARE:
|
||||
default:
|
||||
vs_str = "vs_4_0";
|
||||
ps_str = "ps_4_0";
|
||||
gs_str = "gs_4_0";
|
||||
break;
|
||||
}
|
||||
|
||||
if (!src) /* LPCWSTR filename */
|
||||
{
|
||||
if (vs_entry && !d3d_compile_from_file((LPCWSTR)src_name, vs_entry, vs_str, &vs_code))
|
||||
success = false;
|
||||
if (ps_entry && !d3d_compile_from_file((LPCWSTR)src_name, ps_entry, ps_str, &ps_code))
|
||||
success = false;
|
||||
if (gs_entry && !d3d_compile_from_file((LPCWSTR)src_name, gs_entry, gs_str, &gs_code))
|
||||
success = false;
|
||||
}
|
||||
else /* char array */
|
||||
{
|
||||
if (vs_entry && !d3d_compile(src, size, (LPCSTR)src_name, vs_entry, vs_str, &vs_code))
|
||||
success = false;
|
||||
if (ps_entry && !d3d_compile(src, size, (LPCSTR)src_name, ps_entry, ps_str, &ps_code))
|
||||
success = false;
|
||||
if (gs_entry && !d3d_compile(src, size, (LPCSTR)src_name, gs_entry, gs_str, &gs_code))
|
||||
success = false;
|
||||
}
|
||||
|
||||
if (ps_code)
|
||||
device->lpVtbl->CreatePixelShader(
|
||||
device,
|
||||
ps_code->lpVtbl->GetBufferPointer(ps_code),
|
||||
ps_code->lpVtbl->GetBufferSize(ps_code),
|
||||
NULL, &out->ps);
|
||||
|
||||
if (gs_code)
|
||||
device->lpVtbl->CreateGeometryShader(
|
||||
device,
|
||||
gs_code->lpVtbl->GetBufferPointer(gs_code),
|
||||
gs_code->lpVtbl->GetBufferSize(gs_code),
|
||||
NULL, &out->gs);
|
||||
|
||||
if (vs_code)
|
||||
{
|
||||
LPVOID buf_ptr = vs_code->lpVtbl->GetBufferPointer(vs_code);
|
||||
SIZE_T buf_size = vs_code->lpVtbl->GetBufferSize(vs_code);
|
||||
device->lpVtbl->CreateVertexShader(device, buf_ptr, buf_size, NULL, &out->vs);
|
||||
if (input_element_descs)
|
||||
device->lpVtbl->CreateInputLayout(device, input_element_descs, num_elements,
|
||||
buf_ptr, buf_size, &out->layout);
|
||||
}
|
||||
|
||||
Release(vs_code);
|
||||
Release(ps_code);
|
||||
Release(gs_code);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
static bool d3d11_gfx_set_shader(void* data, enum rarch_shader_type type, const char* path)
|
||||
{
|
||||
#if defined(HAVE_SLANG) && defined(HAVE_SPIRV_CROSS)
|
||||
@ -1014,9 +915,6 @@ static bool d3d11_init_swapchain(d3d11_video_t* d3d11,
|
||||
#endif
|
||||
desc.SampleDesc.Count = 1;
|
||||
desc.SampleDesc.Quality = 0;
|
||||
#if 0
|
||||
desc.Scaling = DXGI_SCALING_STRETCH;
|
||||
#endif
|
||||
#ifdef HAVE_WINDOW
|
||||
desc.Windowed = TRUE;
|
||||
#endif
|
||||
@ -1090,7 +988,7 @@ static bool d3d11_init_swapchain(d3d11_video_t* d3d11,
|
||||
d3d11->has_flip_model = true;
|
||||
d3d11->has_allow_tearing = true;
|
||||
desc.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING;
|
||||
desc.Flags |= DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT;
|
||||
desc.Flags |= DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT;
|
||||
desc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD;
|
||||
#endif
|
||||
|
||||
@ -1101,7 +999,7 @@ static bool d3d11_init_swapchain(d3d11_video_t* d3d11,
|
||||
&desc, NULL, (IDXGISwapChain1**)&d3d11->swapChain)))
|
||||
return false;
|
||||
#else
|
||||
desc.Flags |= DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT;
|
||||
desc.Flags |= DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT;
|
||||
desc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
|
||||
|
||||
adapter->lpVtbl->GetParent(
|
||||
@ -1177,6 +1075,7 @@ static bool d3d11_init_swapchain(d3d11_video_t* d3d11,
|
||||
RARCH_LOG("[D3D11]: Requesting %u maximum frame latency, using %u.\n", max_latency, cur_latency);
|
||||
}
|
||||
|
||||
|
||||
#ifdef HAVE_DXGI_HDR
|
||||
/* Check display HDR support and
|
||||
initialize ST.2084 support to match
|
||||
@ -1787,7 +1686,7 @@ static void d3d11_init_history(d3d11_video_t* d3d11, unsigned width, unsigned he
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
/* todo: should we init history to max_width/max_height instead ?
|
||||
/* TODO/FIXME: should we init history to max_width/max_height instead ?
|
||||
* to prevent out of memory errors happening several frames later
|
||||
* and to reduce memory fragmentation */
|
||||
|
||||
@ -1817,6 +1716,7 @@ static void d3d11_init_render_targets(d3d11_video_t* d3d11, unsigned width, unsi
|
||||
|
||||
if (pass->fbo.valid)
|
||||
{
|
||||
|
||||
switch (pass->fbo.type_x)
|
||||
{
|
||||
case RARCH_SCALE_INPUT:
|
||||
@ -1940,8 +1840,7 @@ static bool d3d11_gfx_frame(
|
||||
{
|
||||
UINT swapchain_flags = d3d11->has_allow_tearing
|
||||
? DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING : 0;
|
||||
swapchain_flags |= DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT;
|
||||
|
||||
swapchain_flags |= DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT;
|
||||
#ifdef HAVE_DXGI_HDR
|
||||
d3d11->hdr.enable = video_hdr_enable;
|
||||
|
||||
@ -2018,7 +1917,12 @@ static bool d3d11_gfx_frame(
|
||||
#endif
|
||||
}
|
||||
else
|
||||
D3D11WaitOnSwapChain(d3d11->frameLatencyWaitableObject);
|
||||
{
|
||||
WaitForSingleObjectEx(
|
||||
d3d11->frameLatencyWaitableObject,
|
||||
1000,
|
||||
true);
|
||||
}
|
||||
|
||||
{
|
||||
D3D11Texture2D back_buffer;
|
||||
|
@ -108,15 +108,6 @@ static void d3d12_gfx_sync(d3d12_video_t* d3d12)
|
||||
}
|
||||
}
|
||||
|
||||
/* Waitable swap chain */
|
||||
static void D3D12WaitOnSwapChain(HANDLE frameLatencyWaitableObject)
|
||||
{
|
||||
DWORD result = WaitForSingleObjectEx(
|
||||
frameLatencyWaitableObject,
|
||||
1000,
|
||||
true);
|
||||
}
|
||||
|
||||
#ifdef HAVE_OVERLAY
|
||||
static void d3d12_free_overlays(d3d12_video_t* d3d12)
|
||||
{
|
||||
@ -1266,13 +1257,9 @@ static bool d3d12_init_swapchain(d3d12_video_t* d3d12,
|
||||
desc.OutputWindow = hwnd;
|
||||
desc.Windowed = TRUE;
|
||||
#endif
|
||||
#if 0
|
||||
desc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL;
|
||||
#else
|
||||
desc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD;
|
||||
#endif
|
||||
desc.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING;
|
||||
desc.Flags |= DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT;
|
||||
desc.Flags |= DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT;
|
||||
|
||||
#ifdef __WINRT__
|
||||
hr = DXGICreateSwapChainForCoreWindow(d3d12->factory, d3d12->queue.handle, corewindow, &desc, NULL, &d3d12->chain.handle);
|
||||
@ -1296,6 +1283,7 @@ static bool d3d12_init_swapchain(d3d12_video_t* d3d12,
|
||||
RARCH_LOG("[D3D12]: Requesting %u maximum frame latency, using %u.\n", max_latency, cur_latency);
|
||||
}
|
||||
|
||||
|
||||
#ifdef HAVE_WINDOW
|
||||
DXGIMakeWindowAssociation(d3d12->factory, hwnd, DXGI_MWA_NO_ALT_ENTER);
|
||||
#endif
|
||||
@ -1473,8 +1461,7 @@ static bool d3d12_create_root_signature(
|
||||
if (error)
|
||||
{
|
||||
RARCH_ERR(
|
||||
"[D3D12]: CreateRootSignature failed : %s", (const
|
||||
char*)error->lpVtbl->GetBufferPointer(error));
|
||||
"[D3D12]: CreateRootSignature failed : %s\n", (const char*)error->lpVtbl->GetBufferPointer(error));
|
||||
Release(error);
|
||||
return false;
|
||||
}
|
||||
@ -1552,12 +1539,6 @@ static void d3d12_init_descriptors(d3d12_video_t* d3d12)
|
||||
static_sampler.AddressU = D3D12_TEXTURE_ADDRESS_MODE_CLAMP;
|
||||
static_sampler.AddressV = D3D12_TEXTURE_ADDRESS_MODE_CLAMP;
|
||||
static_sampler.AddressW = D3D12_TEXTURE_ADDRESS_MODE_CLAMP;
|
||||
#if 0
|
||||
static_sampler.MaxAnisotropy = 1;
|
||||
static_sampler.ComparisonFunc = D3D12_COMPARISON_FUNC_NEVER;
|
||||
static_sampler.MinLOD = -D3D12_FLOAT32_MAX;
|
||||
static_sampler.MaxLOD = D3D12_FLOAT32_MAX;
|
||||
#endif
|
||||
|
||||
desc.NumParameters = countof(cs_root_params);
|
||||
desc.pParameters = cs_root_params;
|
||||
@ -1909,7 +1890,7 @@ static void d3d12_init_history(d3d12_video_t* d3d12, unsigned width, unsigned he
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
/* todo: should we init history to max_width/max_height instead ?
|
||||
/* TODO/FIXME: should we init history to max_width/max_height instead ?
|
||||
* to prevent out of memory errors happening several frames later
|
||||
* and to reduce memory fragmentation */
|
||||
|
||||
@ -2174,7 +2155,12 @@ static bool d3d12_gfx_frame(
|
||||
#endif
|
||||
}
|
||||
else
|
||||
D3D12WaitOnSwapChain(d3d12->chain.frameLatencyWaitableObject);
|
||||
{
|
||||
WaitForSingleObjectEx(
|
||||
d3d12->chain.frameLatencyWaitableObject,
|
||||
1000,
|
||||
true);
|
||||
}
|
||||
|
||||
D3D12ResetCommandAllocator(d3d12->queue.allocator);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user