Merge branch 'linux'

This commit is contained in:
DrChat
2017-12-16 17:15:49 -06:00
108 changed files with 3154 additions and 1103 deletions

View File

@@ -782,7 +782,9 @@ GL4CommandProcessor::UpdateStatus GL4CommandProcessor::UpdateRenderTargets() {
GLuint color_targets[4] = {kAnyTarget, kAnyTarget, kAnyTarget, kAnyTarget};
if (enable_mode == ModeControl::kColorDepth) {
uint32_t color_info[4] = {
regs.rb_color_info, regs.rb_color1_info, regs.rb_color2_info,
regs.rb_color_info,
regs.rb_color1_info,
regs.rb_color2_info,
regs.rb_color3_info,
};
// A2XX_RB_COLOR_MASK_WRITE_* == D3DRS_COLORWRITEENABLE
@@ -1099,7 +1101,9 @@ GL4CommandProcessor::UpdateStatus GL4CommandProcessor::UpdateRasterizerState(
}
static const GLenum kFillModes[3] = {
GL_POINT, GL_LINE, GL_FILL,
GL_POINT,
GL_LINE,
GL_FILL,
};
bool poly_mode = ((regs.pa_su_sc_mode_cntl >> 3) & 0x3) != 0;
if (poly_mode) {
@@ -1590,7 +1594,8 @@ bool GL4CommandProcessor::IssueCopy() {
if (copy_src_select <= 3 || color_clear_enabled) {
// Source from a color target.
uint32_t color_info[4] = {
regs[XE_GPU_REG_RB_COLOR_INFO].u32, regs[XE_GPU_REG_RB_COLOR1_INFO].u32,
regs[XE_GPU_REG_RB_COLOR_INFO].u32,
regs[XE_GPU_REG_RB_COLOR1_INFO].u32,
regs[XE_GPU_REG_RB_COLOR2_INFO].u32,
regs[XE_GPU_REG_RB_COLOR3_INFO].u32,
};

View File

@@ -184,4 +184,4 @@ GL4Shader* GL4ShaderCache::FindCachedShader(ShaderType shader_type,
} // namespace gl4
} // namespace gpu
} // namespace xe
} // namespace xe

View File

@@ -11,8 +11,10 @@
#define XENIA_GPU_GL4_SHADER_CACHE_H_
#include <cstdint>
#include <cstring>
#include <memory>
#include <unordered_map>
#include <vector>
#include "xenia/gpu/xenos.h"
@@ -57,4 +59,4 @@ class GL4ShaderCache {
} // namespace gpu
} // namespace xe
#endif // XENIA_GPU_GL4_SHADER_CACHE_H_
#endif // XENIA_GPU_GL4_SHADER_CACHE_H_

View File

@@ -940,8 +940,9 @@ bool TextureCache::UploadTexture2D(GLuint texture,
texture_info.size_2d.logical_height);
y++, output_base_offset += host_info.size_2d.output_pitch) {
auto input_base_offset = TextureInfo::TiledOffset2DOuter(
offset_y + y, (texture_info.size_2d.input_width /
texture_info.format_info()->block_width),
offset_y + y,
(texture_info.size_2d.input_width /
texture_info.format_info()->block_width),
bpp);
for (uint32_t x = 0, output_offset = output_base_offset;
x < texture_info.size_2d.block_width;
@@ -1048,8 +1049,9 @@ bool TextureCache::UploadTextureCube(GLuint texture,
y < texture_info.size_cube.block_height;
y++, output_base_offset += host_info.size_cube.output_pitch) {
auto input_base_offset = TextureInfo::TiledOffset2DOuter(
offset_y + y, (texture_info.size_cube.input_width /
texture_info.format_info()->block_width),
offset_y + y,
(texture_info.size_cube.input_width /
texture_info.format_info()->block_width),
bpp);
for (uint32_t x = 0, output_offset = output_base_offset;
x < texture_info.size_cube.block_width;

View File

@@ -159,8 +159,8 @@ uint32_t GraphicsSystem::ReadRegister(uint32_t addr) {
case 0x1951: // ? vblank pending?
return 1;
case 0x1961: // AVIVO_D1MODE_VIEWPORT_SIZE
// Screen res - 1280x720
// [width(0x0FFF), height(0x0FFF)]
// Screen res - 1280x720
// [width(0x0FFF), height(0x0FFF)]
return 0x050002D0;
default:
if (!register_file_.GetRegisterInfo(r)) {

View File

@@ -23,7 +23,8 @@ const RegisterInfo* RegisterFile::GetRegisterInfo(uint32_t index) {
#define XE_GPU_REGISTER(index, type, name) \
case index: { \
static const RegisterInfo reg_info = { \
RegisterInfo::Type::type, #name, \
RegisterInfo::Type::type, \
#name, \
}; \
return &reg_info; \
}

View File

@@ -356,7 +356,10 @@ void ParsedVertexFetchInstruction::Disassemble(StringBuffer* out) const {
void ParsedTextureFetchInstruction::Disassemble(StringBuffer* out) const {
static const char* kTextureFilterNames[] = {
"point", "linear", "BASEMAP", "keep",
"point",
"linear",
"BASEMAP",
"keep",
};
static const char* kAnisoFilterNames[] = {
"disabled", "max1to1", "max2to1", "max4to1",

View File

@@ -2,7 +2,7 @@
******************************************************************************
* Xenia : Xbox 360 Emulator Research Project *
******************************************************************************
* Copyright 2016 Ben Vanik. All rights reserved. *
* Copyright 2017 Ben Vanik. All rights reserved. *
* Released under the BSD license - see LICENSE in the root for more details. *
******************************************************************************
*/
@@ -13,6 +13,7 @@
#include <cfloat>
#include <cstring>
#include <vector>
#include "xenia/base/logging.h"
#include "xenia/gpu/spirv/passes/control_flow_analysis_pass.h"
@@ -337,8 +338,7 @@ void SpirvShaderTranslator::StartTranslation() {
registers_ptr_,
std::vector<Id>({b.makeUintConstant(0)}));
auto r0 = b.createLoad(r0_ptr);
r0 = b.createCompositeInsert(vertex_idx, r0, vec4_float_type_,
std::vector<uint32_t>({0}));
r0 = b.createCompositeInsert(vertex_idx, r0, vec4_float_type_, 0);
b.createStore(r0, r0_ptr);
} else {
// Pixel inputs from vertex shader.

View File

@@ -950,9 +950,8 @@ void TraceViewer::DrawVertexFetcher(Shader* shader,
}
}
ImGui::Columns(1);
ImGui::SetCursorPosY(ImGui::GetCursorPosY() +
(vertex_count - display_end) *
ImGui::GetTextLineHeight());
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + (vertex_count - display_end) *
ImGui::GetTextLineHeight());
ImGui::PopStyleVar();
ImGui::EndChild();
}
@@ -971,10 +970,14 @@ static const char* kStencilFuncNames[] = {
"Decrement and Clamp",
};
static const char* kIndexFormatNames[] = {
"uint16", "uint32",
"uint16",
"uint32",
};
static const char* kEndiannessNames[] = {
"unspecified endianness", "8-in-16", "8-in-32", "16-in-32",
"unspecified endianness",
"8-in-16",
"8-in-32",
"16-in-32",
};
static const char* kColorFormatNames[] = {
/* 0 */ "k_8_8_8_8",
@@ -995,7 +998,8 @@ static const char* kColorFormatNames[] = {
/* 15 */ "k_32_32_FLOAT",
};
static const char* kDepthFormatNames[] = {
"kD24S8", "kD24FS8",
"kD24S8",
"kD24FS8",
};
void ProgressBar(float frac, float width, float height = 0,
@@ -1185,7 +1189,9 @@ void TraceViewer::DrawStateUI() {
uint32_t surface_pitch = surface_info & 0x3FFF;
auto surface_msaa = (surface_info >> 16) & 0x3;
static const char* kMsaaNames[] = {
"1X", "2X", "4X",
"1X",
"2X",
"4X",
};
ImGui::BulletText("Surface Pitch: %d", surface_pitch);
ImGui::BulletText("Surface HI-Z Pitch: %d", surface_hiz);
@@ -1270,7 +1276,9 @@ void TraceViewer::DrawStateUI() {
ImGui::BulletText("Front-face: counter-clockwise");
}
static const char* kFillModeNames[3] = {
"point", "line", "fill",
"point",
"line",
"fill",
};
bool poly_mode = ((pa_su_sc_mode_cntl >> 3) & 0x3) != 0;
if (poly_mode) {

View File

@@ -72,7 +72,9 @@ void TraceWriter::WritePrimaryBufferStart(uint32_t base_ptr, uint32_t count) {
return;
}
PrimaryBufferStartCommand cmd = {
TraceCommandType::kPrimaryBufferStart, base_ptr, 0,
TraceCommandType::kPrimaryBufferStart,
base_ptr,
0,
};
fwrite(&cmd, 1, sizeof(cmd), file_);
}
@@ -92,7 +94,9 @@ void TraceWriter::WriteIndirectBufferStart(uint32_t base_ptr, uint32_t count) {
return;
}
IndirectBufferStartCommand cmd = {
TraceCommandType::kIndirectBufferStart, base_ptr, 0,
TraceCommandType::kIndirectBufferStart,
base_ptr,
0,
};
fwrite(&cmd, 1, sizeof(cmd), file_);
}
@@ -112,7 +116,9 @@ void TraceWriter::WritePacketStart(uint32_t base_ptr, uint32_t count) {
return;
}
PacketStartCommand cmd = {
TraceCommandType::kPacketStart, base_ptr, count,
TraceCommandType::kPacketStart,
base_ptr,
count,
};
fwrite(&cmd, 1, sizeof(cmd), file_);
fwrite(membase_ + base_ptr, 4, count, file_);
@@ -220,7 +226,8 @@ void TraceWriter::WriteEvent(EventCommand::Type event_type) {
return;
}
EventCommand cmd = {
TraceCommandType::kEvent, event_type,
TraceCommandType::kEvent,
event_type,
};
fwrite(&cmd, 1, sizeof(cmd), file_);
}

View File

@@ -1206,7 +1206,9 @@ PipelineCache::UpdateStatus PipelineCache::UpdateRasterizationState(
// Vulkan only supports both matching.
assert_true(front_poly_mode == back_poly_mode);
static const VkPolygonMode kFillModes[3] = {
VK_POLYGON_MODE_POINT, VK_POLYGON_MODE_LINE, VK_POLYGON_MODE_FILL,
VK_POLYGON_MODE_POINT,
VK_POLYGON_MODE_LINE,
VK_POLYGON_MODE_FILL,
};
state_info.polygonMode = kFillModes[front_poly_mode];
} else {

View File

@@ -223,7 +223,9 @@ CachedTileView::CachedTileView(ui::vulkan::VulkanDevice* device,
image_view_info.format = image_info.format;
// TODO(benvanik): manipulate? may not be able to when attached.
image_view_info.components = {
VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_G, VK_COMPONENT_SWIZZLE_B,
VK_COMPONENT_SWIZZLE_R,
VK_COMPONENT_SWIZZLE_G,
VK_COMPONENT_SWIZZLE_B,
VK_COMPONENT_SWIZZLE_A,
};
image_view_info.subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1};
@@ -766,7 +768,9 @@ bool RenderCache::ParseConfiguration(RenderConfiguration* config) {
// Color attachment configuration.
if (config->mode_control == ModeControl::kColorDepth) {
reg::RB_COLOR_INFO color_info[4] = {
regs.rb_color_info, regs.rb_color1_info, regs.rb_color2_info,
regs.rb_color_info,
regs.rb_color1_info,
regs.rb_color2_info,
regs.rb_color3_info,
};
for (int i = 0; i < 4; ++i) {
@@ -783,6 +787,9 @@ bool RenderCache::ParseConfiguration(RenderConfiguration* config) {
case ColorRenderTargetFormat::k_2_10_10_10_FLOAT_unknown:
config->color[i].format = ColorRenderTargetFormat::k_2_10_10_10_FLOAT;
break;
default:
// The rest are good
break;
}
}
} else {
@@ -863,7 +870,7 @@ bool RenderCache::ConfigureRenderPass(VkCommandBuffer command_buffer,
color_key.edram_format = static_cast<uint16_t>(config->color[i].format);
target_color_attachments[i] =
FindOrCreateTileView(command_buffer, color_key);
if (!target_color_attachments) {
if (!target_color_attachments[i]) {
XELOGE("Failed to get tile view for color attachment");
return false;
}
@@ -926,6 +933,9 @@ CachedTileView* RenderCache::FindTileView(uint32_t base, uint32_t pitch,
case ColorRenderTargetFormat::k_2_10_10_10_FLOAT_unknown:
format = uint32_t(ColorRenderTargetFormat::k_2_10_10_10_FLOAT);
break;
default:
// Other types as-is.
break;
}
}
@@ -1165,6 +1175,9 @@ void RenderCache::BlitToImage(VkCommandBuffer command_buffer,
case ColorRenderTargetFormat::k_2_10_10_10_FLOAT_unknown:
format = uint32_t(ColorRenderTargetFormat::k_2_10_10_10_FLOAT);
break;
default:
// Rest are OK
break;
}
}
@@ -1278,6 +1291,9 @@ void RenderCache::ClearEDRAMColor(VkCommandBuffer command_buffer,
case ColorRenderTargetFormat::k_2_10_10_10_FLOAT_unknown:
format = ColorRenderTargetFormat::k_2_10_10_10_FLOAT;
break;
default:
// Rest are OK
break;
}
uint32_t tile_width = num_samples == MsaaSamples::k4X ? 40 : 80;

View File

@@ -84,7 +84,7 @@ class CachedTileView {
}
VkExtent2D GetSize() const {
return {key.tile_width * 80ul, key.tile_height * 16ul};
return {key.tile_width * 80u, key.tile_height * 16u};
}
private:

View File

@@ -1116,8 +1116,10 @@ void TextureCache::WritebackTexture(Texture* texture) {
auto command_buffer = wb_command_pool_->AcquireEntry();
VkCommandBufferBeginInfo begin_info = {
VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, nullptr,
VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT, nullptr,
VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO,
nullptr,
VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT,
nullptr,
};
vkBeginCommandBuffer(command_buffer, &begin_info);

View File

@@ -122,7 +122,9 @@ bool VulkanCommandProcessor::SetupContext() {
}
VkEventCreateInfo info = {
VK_STRUCTURE_TYPE_EVENT_CREATE_INFO, nullptr, 0,
VK_STRUCTURE_TYPE_EVENT_CREATE_INFO,
nullptr,
0,
};
status = vkCreateEvent(*device_, &info, nullptr,
@@ -469,7 +471,8 @@ void VulkanCommandProcessor::PerformSwap(uint32_t frontbuffer_ptr,
nullptr, 1, &barrier);
VkRect2D src_rect = {
{0, 0}, {frontbuffer_width, frontbuffer_height},
{0, 0},
{frontbuffer_width, frontbuffer_height},
};
blitter_->BlitTexture2D(
copy_commands, current_batch_fence_,
@@ -1032,7 +1035,8 @@ bool VulkanCommandProcessor::IssueCopy() {
if (is_color_source) {
// Source from a color target.
uint32_t color_info[4] = {
regs[XE_GPU_REG_RB_COLOR_INFO].u32, regs[XE_GPU_REG_RB_COLOR1_INFO].u32,
regs[XE_GPU_REG_RB_COLOR_INFO].u32,
regs[XE_GPU_REG_RB_COLOR1_INFO].u32,
regs[XE_GPU_REG_RB_COLOR2_INFO].u32,
regs[XE_GPU_REG_RB_COLOR3_INFO].u32,
};
@@ -1142,11 +1146,11 @@ bool VulkanCommandProcessor::IssueCopy() {
VkFilter filter = is_color_source ? VK_FILTER_LINEAR : VK_FILTER_NEAREST;
switch (copy_command) {
case CopyCommand::kRaw:
/*
render_cache_->RawCopyToImage(command_buffer, edram_base,
texture->image, texture->image_layout, is_color_source, resolve_offset,
resolve_extent); break;
*/
/*
render_cache_->RawCopyToImage(command_buffer, edram_base,
texture->image, texture->image_layout, is_color_source, resolve_offset,
resolve_extent); break;
*/
case CopyCommand::kConvert: {
/*

View File

@@ -27,8 +27,8 @@ namespace xe {
namespace gpu {
namespace vulkan {
using xe::ui::vulkan::CheckResult;
using xe::ui::RawImage;
using xe::ui::vulkan::CheckResult;
VulkanGraphicsSystem::VulkanGraphicsSystem() {}
VulkanGraphicsSystem::~VulkanGraphicsSystem() = default;
@@ -50,7 +50,8 @@ X_STATUS VulkanGraphicsSystem::Setup(cpu::Processor* processor,
// Create our own command pool we can use for captures.
VkCommandPoolCreateInfo create_info = {
VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO, nullptr,
VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO,
nullptr,
VK_COMMAND_POOL_CREATE_TRANSIENT_BIT |
VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT,
device_->queue_family_index(),
@@ -93,8 +94,10 @@ std::unique_ptr<RawImage> VulkanGraphicsSystem::Capture() {
}
VkCommandBufferBeginInfo begin_info = {
VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, nullptr,
VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT, nullptr,
VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO,
nullptr,
VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT,
nullptr,
};
vkBeginCommandBuffer(cmd, &begin_info);