Merge branch 'master' of https://github.com/xenia-project/xenia into canary_experimental
This commit is contained in:
@@ -2272,7 +2272,7 @@ bool D3D12CommandProcessor::IssueDraw(xenos::PrimitiveType primitive_type,
|
||||
UpdateSystemConstantValues(
|
||||
memexport_used, primitive_polygonal,
|
||||
primitive_processing_result.line_loop_closing_index,
|
||||
primitive_processing_result.host_index_endian, viewport_info,
|
||||
primitive_processing_result.host_shader_index_endian, viewport_info,
|
||||
used_texture_mask, normalized_depth_control, normalized_color_mask);
|
||||
|
||||
// Update constant buffers, descriptors and root parameters.
|
||||
@@ -2517,7 +2517,7 @@ bool D3D12CommandProcessor::IssueDraw(xenos::PrimitiveType primitive_type,
|
||||
}
|
||||
ID3D12Resource* scratch_index_buffer = nullptr;
|
||||
switch (primitive_processing_result.index_buffer_type) {
|
||||
case PrimitiveProcessor::ProcessedIndexBufferType::kGuest: {
|
||||
case PrimitiveProcessor::ProcessedIndexBufferType::kGuestDMA: {
|
||||
if (memexport_used) {
|
||||
// If the shared memory is a UAV, it can't be used as an index buffer
|
||||
// (UAV is a read/write state, index buffer is a read-only state).
|
||||
@@ -2549,7 +2549,8 @@ bool D3D12CommandProcessor::IssueDraw(xenos::PrimitiveType primitive_type,
|
||||
primitive_processor_->GetConvertedIndexBufferGpuAddress(
|
||||
primitive_processing_result.host_index_buffer_handle);
|
||||
break;
|
||||
case PrimitiveProcessor::ProcessedIndexBufferType::kHostBuiltin:
|
||||
case PrimitiveProcessor::ProcessedIndexBufferType::kHostBuiltinForAuto:
|
||||
case PrimitiveProcessor::ProcessedIndexBufferType::kHostBuiltinForDMA:
|
||||
index_buffer_view.BufferLocation =
|
||||
primitive_processor_->GetBuiltinIndexBufferGpuAddress(
|
||||
primitive_processing_result.host_index_buffer_handle);
|
||||
@@ -3167,8 +3168,6 @@ void D3D12CommandProcessor::UpdateSystemConstantValues(
|
||||
const RegisterFile& regs = *register_file_;
|
||||
auto pa_cl_clip_cntl = regs.Get<reg::PA_CL_CLIP_CNTL>();
|
||||
auto pa_cl_vte_cntl = regs.Get<reg::PA_CL_VTE_CNTL>();
|
||||
auto pa_su_point_minmax = regs.Get<reg::PA_SU_POINT_MINMAX>();
|
||||
auto pa_su_point_size = regs.Get<reg::PA_SU_POINT_SIZE>();
|
||||
auto pa_su_sc_mode_cntl = regs.Get<reg::PA_SU_SC_MODE_CNTL>();
|
||||
float rb_alpha_ref = regs[XE_GPU_REG_RB_ALPHA_REF].f32;
|
||||
auto rb_colorcontrol = regs.Get<reg::RB_COLORCONTROL>();
|
||||
@@ -3372,43 +3371,47 @@ void D3D12CommandProcessor::UpdateSystemConstantValues(
|
||||
}
|
||||
|
||||
// Point size.
|
||||
float point_vertex_diameter_min =
|
||||
float(pa_su_point_minmax.min_size) * (2.0f / 16.0f);
|
||||
float point_vertex_diameter_max =
|
||||
float(pa_su_point_minmax.max_size) * (2.0f / 16.0f);
|
||||
float point_constant_diameter_x =
|
||||
float(pa_su_point_size.width) * (2.0f / 16.0f);
|
||||
float point_constant_diameter_y =
|
||||
float(pa_su_point_size.height) * (2.0f / 16.0f);
|
||||
dirty |=
|
||||
system_constants_.point_vertex_diameter_min != point_vertex_diameter_min;
|
||||
dirty |=
|
||||
system_constants_.point_vertex_diameter_max != point_vertex_diameter_max;
|
||||
dirty |=
|
||||
system_constants_.point_constant_diameter[0] != point_constant_diameter_x;
|
||||
dirty |=
|
||||
system_constants_.point_constant_diameter[1] != point_constant_diameter_y;
|
||||
system_constants_.point_vertex_diameter_min = point_vertex_diameter_min;
|
||||
system_constants_.point_vertex_diameter_max = point_vertex_diameter_max;
|
||||
system_constants_.point_constant_diameter[0] = point_constant_diameter_x;
|
||||
system_constants_.point_constant_diameter[1] = point_constant_diameter_y;
|
||||
// 2 because 1 in the NDC is half of the viewport's axis, 0.5 for diameter to
|
||||
// radius conversion to avoid multiplying the per-vertex diameter by an
|
||||
// additional constant in the shader.
|
||||
float point_screen_diameter_to_ndc_radius_x =
|
||||
(/* 0.5f * 2.0f * */ float(draw_resolution_scale_x)) /
|
||||
std::max(viewport_info.xy_extent[0], uint32_t(1));
|
||||
float point_screen_diameter_to_ndc_radius_y =
|
||||
(/* 0.5f * 2.0f * */ float(draw_resolution_scale_y)) /
|
||||
std::max(viewport_info.xy_extent[1], uint32_t(1));
|
||||
dirty |= system_constants_.point_screen_diameter_to_ndc_radius[0] !=
|
||||
point_screen_diameter_to_ndc_radius_x;
|
||||
dirty |= system_constants_.point_screen_diameter_to_ndc_radius[1] !=
|
||||
point_screen_diameter_to_ndc_radius_y;
|
||||
system_constants_.point_screen_diameter_to_ndc_radius[0] =
|
||||
point_screen_diameter_to_ndc_radius_x;
|
||||
system_constants_.point_screen_diameter_to_ndc_radius[1] =
|
||||
point_screen_diameter_to_ndc_radius_y;
|
||||
if (vgt_draw_initiator.prim_type == xenos::PrimitiveType::kPointList) {
|
||||
auto pa_su_point_minmax = regs.Get<reg::PA_SU_POINT_MINMAX>();
|
||||
auto pa_su_point_size = regs.Get<reg::PA_SU_POINT_SIZE>();
|
||||
float point_vertex_diameter_min =
|
||||
float(pa_su_point_minmax.min_size) * (2.0f / 16.0f);
|
||||
float point_vertex_diameter_max =
|
||||
float(pa_su_point_minmax.max_size) * (2.0f / 16.0f);
|
||||
float point_constant_diameter_x =
|
||||
float(pa_su_point_size.width) * (2.0f / 16.0f);
|
||||
float point_constant_diameter_y =
|
||||
float(pa_su_point_size.height) * (2.0f / 16.0f);
|
||||
dirty |= system_constants_.point_vertex_diameter_min !=
|
||||
point_vertex_diameter_min;
|
||||
dirty |= system_constants_.point_vertex_diameter_max !=
|
||||
point_vertex_diameter_max;
|
||||
dirty |= system_constants_.point_constant_diameter[0] !=
|
||||
point_constant_diameter_x;
|
||||
dirty |= system_constants_.point_constant_diameter[1] !=
|
||||
point_constant_diameter_y;
|
||||
system_constants_.point_vertex_diameter_min = point_vertex_diameter_min;
|
||||
system_constants_.point_vertex_diameter_max = point_vertex_diameter_max;
|
||||
system_constants_.point_constant_diameter[0] = point_constant_diameter_x;
|
||||
system_constants_.point_constant_diameter[1] = point_constant_diameter_y;
|
||||
// 2 because 1 in the NDC is half of the viewport's axis, 0.5 for diameter
|
||||
// to radius conversion to avoid multiplying the per-vertex diameter by an
|
||||
// additional constant in the shader.
|
||||
float point_screen_diameter_to_ndc_radius_x =
|
||||
(/* 0.5f * 2.0f * */ float(draw_resolution_scale_x)) /
|
||||
std::max(viewport_info.xy_extent[0], uint32_t(1));
|
||||
float point_screen_diameter_to_ndc_radius_y =
|
||||
(/* 0.5f * 2.0f * */ float(draw_resolution_scale_y)) /
|
||||
std::max(viewport_info.xy_extent[1], uint32_t(1));
|
||||
dirty |= system_constants_.point_screen_diameter_to_ndc_radius[0] !=
|
||||
point_screen_diameter_to_ndc_radius_x;
|
||||
dirty |= system_constants_.point_screen_diameter_to_ndc_radius[1] !=
|
||||
point_screen_diameter_to_ndc_radius_y;
|
||||
system_constants_.point_screen_diameter_to_ndc_radius[0] =
|
||||
point_screen_diameter_to_ndc_radius_x;
|
||||
system_constants_.point_screen_diameter_to_ndc_radius[1] =
|
||||
point_screen_diameter_to_ndc_radius_y;
|
||||
}
|
||||
|
||||
// Texture signedness / gamma.
|
||||
bool gamma_render_target_as_srgb =
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace d3d12 {
|
||||
D3D12PrimitiveProcessor::~D3D12PrimitiveProcessor() { Shutdown(true); }
|
||||
|
||||
bool D3D12PrimitiveProcessor::Initialize() {
|
||||
if (!InitializeCommon(true, false, false, true)) {
|
||||
if (!InitializeCommon(true, false, false, true, true, true)) {
|
||||
Shutdown();
|
||||
return false;
|
||||
}
|
||||
@@ -83,9 +83,9 @@ void D3D12PrimitiveProcessor::EndFrame() {
|
||||
frame_index_buffers_.clear();
|
||||
}
|
||||
|
||||
bool D3D12PrimitiveProcessor::InitializeBuiltin16BitIndexBuffer(
|
||||
uint32_t index_count, std::function<void(uint16_t*)> fill_callback) {
|
||||
assert_not_zero(index_count);
|
||||
bool D3D12PrimitiveProcessor::InitializeBuiltinIndexBuffer(
|
||||
size_t size_bytes, std::function<void(void*)> fill_callback) {
|
||||
assert_not_zero(size_bytes);
|
||||
assert_null(builtin_index_buffer_);
|
||||
assert_null(builtin_index_buffer_upload_);
|
||||
|
||||
@@ -94,9 +94,8 @@ bool D3D12PrimitiveProcessor::InitializeBuiltin16BitIndexBuffer(
|
||||
ID3D12Device* device = provider.GetDevice();
|
||||
|
||||
D3D12_RESOURCE_DESC resource_desc;
|
||||
ui::d3d12::util::FillBufferResourceDesc(
|
||||
resource_desc, UINT64(sizeof(uint16_t) * index_count),
|
||||
D3D12_RESOURCE_FLAG_NONE);
|
||||
ui::d3d12::util::FillBufferResourceDesc(resource_desc, UINT64(size_bytes),
|
||||
D3D12_RESOURCE_FLAG_NONE);
|
||||
Microsoft::WRL::ComPtr<ID3D12Resource> draw_resource;
|
||||
if (FAILED(device->CreateCommittedResource(
|
||||
&ui::d3d12::util::kHeapPropertiesDefault,
|
||||
@@ -105,8 +104,8 @@ bool D3D12PrimitiveProcessor::InitializeBuiltin16BitIndexBuffer(
|
||||
IID_PPV_ARGS(&draw_resource)))) {
|
||||
XELOGE(
|
||||
"D3D12 primitive processor: Failed to create the built-in index "
|
||||
"buffer GPU resource with {} 16-bit indices",
|
||||
index_count);
|
||||
"buffer GPU resource with {} bytes",
|
||||
size_bytes);
|
||||
return false;
|
||||
}
|
||||
Microsoft::WRL::ComPtr<ID3D12Resource> upload_resource;
|
||||
@@ -117,8 +116,8 @@ bool D3D12PrimitiveProcessor::InitializeBuiltin16BitIndexBuffer(
|
||||
IID_PPV_ARGS(&upload_resource)))) {
|
||||
XELOGE(
|
||||
"D3D12 primitive processor: Failed to create the built-in index "
|
||||
"buffer upload resource with {} 16-bit indices",
|
||||
index_count);
|
||||
"buffer upload resource with {} bytes",
|
||||
size_bytes);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -127,8 +126,8 @@ bool D3D12PrimitiveProcessor::InitializeBuiltin16BitIndexBuffer(
|
||||
if (FAILED(upload_resource->Map(0, &upload_read_range, &mapping))) {
|
||||
XELOGE(
|
||||
"D3D12 primitive processor: Failed to map the built-in index buffer "
|
||||
"upload resource with {} 16-bit indices",
|
||||
index_count);
|
||||
"upload resource with {} bytes",
|
||||
size_bytes);
|
||||
return false;
|
||||
}
|
||||
fill_callback(reinterpret_cast<uint16_t*>(mapping));
|
||||
|
||||
@@ -56,9 +56,8 @@ class D3D12PrimitiveProcessor final : public PrimitiveProcessor {
|
||||
}
|
||||
|
||||
protected:
|
||||
bool InitializeBuiltin16BitIndexBuffer(
|
||||
uint32_t index_count,
|
||||
std::function<void(uint16_t*)> fill_callback) override;
|
||||
bool InitializeBuiltinIndexBuffer(
|
||||
size_t size_bytes, std::function<void(void*)> fill_callback) override;
|
||||
|
||||
void* RequestHostConvertedIndexBufferForCurrentFrame(
|
||||
xenos::IndexFormat format, uint32_t index_count, bool coalign_for_simd,
|
||||
|
||||
Reference in New Issue
Block a user