Finishing unique_ptr'ing and fixing file memory management (for now).
This commit is contained in:
parent
c59d053404
commit
08b0226a16
|
@ -94,7 +94,7 @@ void* X64CodeCache::PlaceCode(void* machine_code, size_t code_size,
|
|||
lock_.unlock();
|
||||
|
||||
// Copy code.
|
||||
xe_copy_struct(final_address, machine_code, code_size);
|
||||
memcpy(final_address, machine_code, code_size);
|
||||
|
||||
// This isn't needed on x64 (probably), but is convention.
|
||||
FlushInstructionCache(GetCurrentProcess(), final_address, alloc_size);
|
||||
|
@ -109,7 +109,7 @@ X64CodeChunk::X64CodeChunk(size_t chunk_size)
|
|||
fn_table_capacity =
|
||||
static_cast<uint32_t>(poly::round_up(capacity / ESTIMATED_FN_SIZE, 16));
|
||||
size_t table_size = fn_table_capacity * sizeof(RUNTIME_FUNCTION);
|
||||
fn_table = (RUNTIME_FUNCTION*)xe_malloc(table_size);
|
||||
fn_table = (RUNTIME_FUNCTION*)malloc(table_size);
|
||||
fn_table_count = 0;
|
||||
fn_table_handle = 0;
|
||||
RtlAddGrowableFunctionTable(&fn_table_handle, fn_table, fn_table_count,
|
||||
|
@ -198,8 +198,7 @@ void X64CodeChunk::AddTableEntry(uint8_t* code, size_t code_size,
|
|||
RtlDeleteGrowableFunctionTable(fn_table_handle);
|
||||
size_t old_size = fn_table_capacity * sizeof(RUNTIME_FUNCTION);
|
||||
size_t new_size = old_size * 2;
|
||||
auto new_table =
|
||||
(RUNTIME_FUNCTION*)xe_realloc(fn_table, old_size, new_size);
|
||||
auto new_table = (RUNTIME_FUNCTION*)realloc(fn_table, new_size);
|
||||
assert_not_null(new_table);
|
||||
if (!new_table) {
|
||||
return;
|
||||
|
|
|
@ -95,6 +95,9 @@ class Debugger {
|
|||
void FindBreakpoints(uint64_t address,
|
||||
std::vector<Breakpoint*>& out_breakpoints);
|
||||
|
||||
// TODO(benvanik): utility functions for modification (make function ignored,
|
||||
// etc).
|
||||
|
||||
void OnThreadCreated(ThreadState* thread_state);
|
||||
void OnThreadDestroyed(ThreadState* thread_state);
|
||||
void OnFunctionDefined(FunctionInfo* symbol_info, Function* function);
|
||||
|
|
|
@ -22,7 +22,7 @@ std::unique_ptr<AudioSystem> xe::apu::CreateNop(Emulator* emulator) {
|
|||
|
||||
#if XE_PLATFORM_WIN32
|
||||
#include <xenia/apu/xaudio2/xaudio2_apu.h>
|
||||
AudioSystem* xe::apu::CreateXAudio2(Emulator* emulator) {
|
||||
std::unique_ptr<AudioSystem> xe::apu::CreateXAudio2(Emulator* emulator) {
|
||||
return xe::apu::xaudio2::Create(emulator);
|
||||
}
|
||||
#endif // WIN32
|
||||
|
|
|
@ -9,11 +9,7 @@
|
|||
|
||||
#include <xenia/core/run_loop.h>
|
||||
|
||||
|
||||
typedef struct xe_run_loop {
|
||||
xe_ref_t ref;
|
||||
} xe_run_loop_t;
|
||||
|
||||
typedef struct xe_run_loop { xe_ref_t ref; } xe_run_loop_t;
|
||||
|
||||
#define WM_XE_RUN_LOOP_QUIT (WM_APP + 0x100)
|
||||
#define WM_XE_RUN_LOOP_CALL (WM_APP + 0x101)
|
||||
|
@ -23,15 +19,13 @@ typedef struct xe_run_loop_call {
|
|||
void* data;
|
||||
} xe_run_loop_call_t;
|
||||
|
||||
|
||||
xe_run_loop_ref xe_run_loop_create() {
|
||||
xe_run_loop_ref run_loop = (xe_run_loop_ref)xe_calloc(sizeof(xe_run_loop_t));
|
||||
xe_run_loop_ref run_loop = (xe_run_loop_ref)calloc(1, sizeof(xe_run_loop_t));
|
||||
xe_ref_init((xe_ref)run_loop);
|
||||
return run_loop;
|
||||
}
|
||||
|
||||
void xe_run_loop_dealloc(xe_run_loop_ref run_loop) {
|
||||
}
|
||||
void xe_run_loop_dealloc(xe_run_loop_ref run_loop) {}
|
||||
|
||||
xe_run_loop_ref xe_run_loop_retain(xe_run_loop_ref run_loop) {
|
||||
xe_ref_retain((xe_ref)run_loop);
|
||||
|
@ -52,7 +46,7 @@ int xe_run_loop_pump(xe_run_loop_ref run_loop) {
|
|||
if (msg.wParam == (WPARAM)run_loop) {
|
||||
xe_run_loop_call_t* call = (xe_run_loop_call_t*)msg.lParam;
|
||||
call->callback(call->data);
|
||||
xe_free(call);
|
||||
free(call);
|
||||
}
|
||||
break;
|
||||
case WM_XE_RUN_LOOP_QUIT:
|
||||
|
@ -70,10 +64,10 @@ void xe_run_loop_quit(xe_run_loop_ref run_loop) {
|
|||
PostMessage(NULL, WM_XE_RUN_LOOP_QUIT, (WPARAM)run_loop, 0);
|
||||
}
|
||||
|
||||
void xe_run_loop_call(xe_run_loop_ref run_loop,
|
||||
xe_run_loop_callback callback, void* data) {
|
||||
void xe_run_loop_call(xe_run_loop_ref run_loop, xe_run_loop_callback callback,
|
||||
void* data) {
|
||||
xe_run_loop_call_t* call =
|
||||
(xe_run_loop_call_t*)xe_calloc(sizeof(xe_run_loop_call_t));
|
||||
(xe_run_loop_call_t*)calloc(1, sizeof(xe_run_loop_call_t));
|
||||
call->callback = callback;
|
||||
call->data = data;
|
||||
PostMessage(NULL, WM_XE_RUN_LOOP_CALL, (WPARAM)run_loop, (LPARAM)call);
|
||||
|
|
|
@ -16,10 +16,8 @@
|
|||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
|
||||
|
||||
// TODO(benvanik): win32 calls
|
||||
|
||||
|
||||
void xe_socket_init() {
|
||||
WSADATA wsa_data;
|
||||
int result = WSAStartup(MAKEWORD(2, 2), &wsa_data);
|
||||
|
@ -41,11 +39,7 @@ void xe_socket_close(socket_t socket) {
|
|||
struct linger so_linger;
|
||||
so_linger.l_onoff = TRUE;
|
||||
so_linger.l_linger = 30;
|
||||
setsockopt(
|
||||
socket,
|
||||
SOL_SOCKET,
|
||||
SO_LINGER,
|
||||
(const char*)&so_linger,
|
||||
setsockopt(socket, SOL_SOCKET, SO_LINGER, (const char*)&so_linger,
|
||||
sizeof so_linger);
|
||||
shutdown(socket, SD_SEND);
|
||||
closesocket(socket);
|
||||
|
@ -57,20 +51,20 @@ void xe_socket_set_keepalive(socket_t socket, bool value) {
|
|||
alive.keepalivetime = 7200000;
|
||||
alive.keepaliveinterval = 6000;
|
||||
DWORD bytes_returned;
|
||||
WSAIoctl(socket, SIO_KEEPALIVE_VALS, &alive, sizeof(alive),
|
||||
NULL, 0, &bytes_returned, NULL, NULL);
|
||||
WSAIoctl(socket, SIO_KEEPALIVE_VALS, &alive, sizeof(alive), NULL, 0,
|
||||
&bytes_returned, NULL, NULL);
|
||||
}
|
||||
|
||||
void xe_socket_set_reuseaddr(socket_t socket, bool value) {
|
||||
int opt_value = value ? 1 : 0;
|
||||
setsockopt(socket, SOL_SOCKET, SO_REUSEADDR,
|
||||
(const char*)&opt_value, sizeof(opt_value));
|
||||
setsockopt(socket, SOL_SOCKET, SO_REUSEADDR, (const char*)&opt_value,
|
||||
sizeof(opt_value));
|
||||
}
|
||||
|
||||
void xe_socket_set_nodelay(socket_t socket, bool value) {
|
||||
int opt_value = value ? 1 : 0;
|
||||
setsockopt(socket, IPPROTO_TCP, TCP_NODELAY,
|
||||
(const char*)&opt_value, sizeof(opt_value));
|
||||
setsockopt(socket, IPPROTO_TCP, TCP_NODELAY, (const char*)&opt_value,
|
||||
sizeof(opt_value));
|
||||
}
|
||||
|
||||
void xe_socket_set_nonblock(socket_t socket, bool value) {
|
||||
|
@ -113,8 +107,8 @@ int xe_socket_listen(socket_t socket) {
|
|||
int xe_socket_accept(socket_t socket, xe_socket_connection_t* out_client_info) {
|
||||
struct sockaddr_in client_addr;
|
||||
int client_count = sizeof(client_addr);
|
||||
socket_t client_socket_id = accept(
|
||||
socket, (struct sockaddr*)&client_addr, &client_count);
|
||||
socket_t client_socket_id =
|
||||
accept(socket, (struct sockaddr*)&client_addr, &client_count);
|
||||
if (client_socket_id == INVALID_SOCKET) {
|
||||
return 1;
|
||||
}
|
||||
|
@ -122,8 +116,8 @@ int xe_socket_accept(socket_t socket, xe_socket_connection_t* out_client_info) {
|
|||
out_client_info->socket = client_socket_id;
|
||||
|
||||
int client_ip = client_addr.sin_addr.s_addr;
|
||||
inet_ntop(AF_INET, &client_ip,
|
||||
out_client_info->addr, poly::countof(out_client_info->addr));
|
||||
inet_ntop(AF_INET, &client_ip, out_client_info->addr,
|
||||
poly::countof(out_client_info->addr));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -188,8 +182,8 @@ int Win32SocketPair(socket_t sockets[2]) {
|
|||
sockaddr client_name;
|
||||
int client_name_len = sizeof(client_name);
|
||||
r = getsockname(client, &client_name, &client_name_len);
|
||||
const char *pc = (const char*)&client_name;
|
||||
const char *pn = (const char*)&listener_name;
|
||||
const char* pc = (const char*)&client_name;
|
||||
const char* pn = (const char*)&listener_name;
|
||||
for (size_t n = 0; n < sizeof(client_name); n++) {
|
||||
if (pc[n] != pn[n]) {
|
||||
closesocket(listener);
|
||||
|
@ -208,19 +202,19 @@ int Win32SocketPair(socket_t sockets[2]) {
|
|||
}
|
||||
|
||||
xe_socket_loop_t* xe_socket_loop_create(socket_t socket) {
|
||||
xe_socket_loop_t* loop = (xe_socket_loop_t*)xe_calloc(
|
||||
sizeof(xe_socket_loop_t));
|
||||
xe_socket_loop_t* loop =
|
||||
(xe_socket_loop_t*)calloc(1, sizeof(xe_socket_loop_t));
|
||||
|
||||
loop->socket = socket;
|
||||
|
||||
socket_t notify_ids[2] = { 0, 0 };
|
||||
socket_t notify_ids[2] = {0, 0};
|
||||
for (int retry = 0; retry < 5; retry++) {
|
||||
if (!Win32SocketPair(notify_ids)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!notify_ids[0]) {
|
||||
xe_free(loop);
|
||||
free(loop);
|
||||
return NULL;
|
||||
}
|
||||
loop->notify_rd_id = notify_ids[0];
|
||||
|
@ -237,11 +231,11 @@ xe_socket_loop_t* xe_socket_loop_create(socket_t socket) {
|
|||
void xe_socket_loop_destroy(xe_socket_loop_t* loop) {
|
||||
closesocket(loop->notify_rd_id);
|
||||
closesocket(loop->notify_wr_id);
|
||||
xe_free(loop);
|
||||
free(loop);
|
||||
}
|
||||
|
||||
int xe_socket_loop_poll(xe_socket_loop_t* loop,
|
||||
bool check_read, bool check_write) {
|
||||
int xe_socket_loop_poll(xe_socket_loop_t* loop, bool check_read,
|
||||
bool check_write) {
|
||||
// Prep events object.
|
||||
loop->events[0].events = 0;
|
||||
if (check_read) {
|
||||
|
|
|
@ -33,7 +33,7 @@ using namespace xe::kernel::fs;
|
|||
using namespace xe::ui;
|
||||
|
||||
Emulator::Emulator(const std::wstring& command_line)
|
||||
: command_line_(command_line) {}
|
||||
: command_line_(command_line), main_window_(nullptr) {}
|
||||
|
||||
Emulator::~Emulator() {
|
||||
// Note that we delete things in the reverse order they were initialized.
|
||||
|
@ -134,8 +134,8 @@ X_STATUS Emulator::Setup() {
|
|||
kernel_state_ = std::make_unique<KernelState>(this);
|
||||
|
||||
// HLE kernel modules.
|
||||
xboxkrnl_ = std::make_unique<XboxkrnlModule>(this, kernel_state_);
|
||||
xam_ = std::make_unique<XamModule>(this, kernel_state_);
|
||||
xboxkrnl_ = std::make_unique<XboxkrnlModule>(this, kernel_state_.get());
|
||||
xam_ = std::make_unique<XamModule>(this, kernel_state_.get());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ class AudioSystem;
|
|||
} // namespace apu
|
||||
namespace cpu {
|
||||
class Processor;
|
||||
class XenonThreadState;
|
||||
} // namespace cpu
|
||||
namespace gpu {
|
||||
class GraphicsSystem;
|
||||
|
|
|
@ -34,7 +34,7 @@ D3D11IndexBufferResource::~D3D11IndexBufferResource() {
|
|||
|
||||
int D3D11IndexBufferResource::CreateHandle() {
|
||||
D3D11_BUFFER_DESC buffer_desc;
|
||||
xe_zero_struct(&buffer_desc, sizeof(buffer_desc));
|
||||
memset(&buffer_desc, 0, sizeof(buffer_desc));
|
||||
buffer_desc.ByteWidth = static_cast<UINT>(memory_range_.length);
|
||||
buffer_desc.Usage = D3D11_USAGE_DYNAMIC;
|
||||
buffer_desc.BindFlags = D3D11_BIND_INDEX_BUFFER;
|
||||
|
@ -100,7 +100,7 @@ D3D11VertexBufferResource::~D3D11VertexBufferResource() {
|
|||
|
||||
int D3D11VertexBufferResource::CreateHandle() {
|
||||
D3D11_BUFFER_DESC buffer_desc;
|
||||
xe_zero_struct(&buffer_desc, sizeof(buffer_desc));
|
||||
memset(&buffer_desc, 0, sizeof(buffer_desc));
|
||||
buffer_desc.ByteWidth = static_cast<UINT>(memory_range_.length);
|
||||
buffer_desc.Usage = D3D11_USAGE_DYNAMIC;
|
||||
buffer_desc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
|
||||
|
|
|
@ -59,9 +59,8 @@ int D3D11GeometryShader::Prepare(D3D11VertexShaderResource* vertex_shader) {
|
|||
return 1;
|
||||
}
|
||||
byte_code_length = shader_blob->GetBufferSize();
|
||||
byte_code = xe_malloc(byte_code_length);
|
||||
xe_copy_struct(
|
||||
byte_code, shader_blob->GetBufferPointer(), byte_code_length);
|
||||
byte_code = malloc(byte_code_length);
|
||||
memcpy(byte_code, shader_blob->GetBufferPointer(), byte_code_length);
|
||||
SafeRelease(shader_blob);
|
||||
|
||||
// Create shader.
|
||||
|
@ -71,7 +70,7 @@ int D3D11GeometryShader::Prepare(D3D11VertexShaderResource* vertex_shader) {
|
|||
&handle_);
|
||||
if (FAILED(hr)) {
|
||||
XELOGE("D3D11: failed to create geometry shader");
|
||||
xe_free(byte_code);
|
||||
free(byte_code);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,13 +39,12 @@ D3D11GraphicsDriver::D3D11GraphicsDriver(
|
|||
|
||||
resource_cache_ = new D3D11ResourceCache(memory, device_, context_);
|
||||
|
||||
xe_zero_struct(&state_, sizeof(state_));
|
||||
memset(&state_, 0, sizeof(state_));
|
||||
|
||||
xe_zero_struct(&render_targets_, sizeof(render_targets_));
|
||||
memset(&render_targets_, 0, sizeof(render_targets_));
|
||||
|
||||
HRESULT hr;
|
||||
D3D11_BUFFER_DESC buffer_desc;
|
||||
xe_zero_struct(&buffer_desc, sizeof(buffer_desc));
|
||||
D3D11_BUFFER_DESC buffer_desc = {0};
|
||||
buffer_desc.Usage = D3D11_USAGE_DYNAMIC;
|
||||
buffer_desc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
|
||||
buffer_desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
|
||||
|
@ -100,8 +99,7 @@ int D3D11GraphicsDriver::Initialize() {
|
|||
|
||||
void D3D11GraphicsDriver::InitializeInvalidTexture() {
|
||||
// TODO(benvanik): pattern?
|
||||
D3D11_TEXTURE2D_DESC texture_desc;
|
||||
xe_zero_struct(&texture_desc, sizeof(texture_desc));
|
||||
D3D11_TEXTURE2D_DESC texture_desc = {0};
|
||||
texture_desc.Width = 4;
|
||||
texture_desc.Height = 4;
|
||||
texture_desc.MipLevels = 1;
|
||||
|
@ -131,8 +129,7 @@ void D3D11GraphicsDriver::InitializeInvalidTexture() {
|
|||
return;
|
||||
}
|
||||
|
||||
D3D11_SHADER_RESOURCE_VIEW_DESC texture_view_desc;
|
||||
xe_zero_struct(&texture_view_desc, sizeof(texture_view_desc));
|
||||
D3D11_SHADER_RESOURCE_VIEW_DESC texture_view_desc = {};
|
||||
texture_view_desc.Format = texture_desc.Format;
|
||||
texture_view_desc.ViewDimension = D3D10_SRV_DIMENSION_TEXTURE2D;
|
||||
texture_view_desc.Texture2D.MipLevels = 1;
|
||||
|
@ -141,8 +138,7 @@ void D3D11GraphicsDriver::InitializeInvalidTexture() {
|
|||
texture, &texture_view_desc, &invalid_texture_view_);
|
||||
SafeRelease(texture);
|
||||
|
||||
D3D11_SAMPLER_DESC sampler_desc;
|
||||
xe_zero_struct(&sampler_desc, sizeof(sampler_desc));
|
||||
D3D11_SAMPLER_DESC sampler_desc = {};
|
||||
sampler_desc.Filter;
|
||||
sampler_desc.AddressU = D3D11_TEXTURE_ADDRESS_CLAMP;
|
||||
sampler_desc.AddressV = D3D11_TEXTURE_ADDRESS_CLAMP;
|
||||
|
@ -396,8 +392,7 @@ int D3D11GraphicsDriver::SetupRasterizerState(const DrawCommand& command) {
|
|||
ID3D11RasterizerState* rasterizer_state = nullptr;
|
||||
auto it = rasterizer_state_cache_.find(key);
|
||||
if (it == rasterizer_state_cache_.end()) {
|
||||
D3D11_RASTERIZER_DESC rasterizer_desc;
|
||||
xe_zero_struct(&rasterizer_desc, sizeof(rasterizer_desc));
|
||||
D3D11_RASTERIZER_DESC rasterizer_desc = {};
|
||||
rasterizer_desc.FillMode = D3D11_FILL_SOLID; // D3D11_FILL_WIREFRAME;
|
||||
switch (mode_control & 0x3) {
|
||||
case 0:
|
||||
|
@ -480,8 +475,7 @@ int D3D11GraphicsDriver::SetupBlendState(const DrawCommand& command) {
|
|||
ID3D11BlendState* blend_state = nullptr;
|
||||
auto it = blend_state_cache_.find(key);
|
||||
if (it == blend_state_cache_.end()) {
|
||||
D3D11_BLEND_DESC blend_desc;
|
||||
xe_zero_struct(&blend_desc, sizeof(blend_desc));
|
||||
D3D11_BLEND_DESC blend_desc = {0};
|
||||
//blend_desc.AlphaToCoverageEnable = false;
|
||||
// ?
|
||||
blend_desc.IndependentBlendEnable = true;
|
||||
|
@ -557,8 +551,7 @@ int D3D11GraphicsDriver::SetupDepthStencilState(const DrawCommand& command) {
|
|||
ID3D11DepthStencilState* depth_stencil_state = nullptr;
|
||||
auto it = depth_stencil_state_cache_.find(key);
|
||||
if (it == depth_stencil_state_cache_.end()) {
|
||||
D3D11_DEPTH_STENCIL_DESC depth_stencil_desc;
|
||||
xe_zero_struct(&depth_stencil_desc, sizeof(depth_stencil_desc));
|
||||
D3D11_DEPTH_STENCIL_DESC depth_stencil_desc = {0};
|
||||
// A2XX_RB_DEPTHCONTROL_BACKFACE_ENABLE
|
||||
// ?
|
||||
// A2XX_RB_DEPTHCONTROL_Z_ENABLE
|
||||
|
@ -846,8 +839,7 @@ int D3D11GraphicsDriver::RebuildRenderTargets(uint32_t width,
|
|||
|
||||
for (int n = 0; n < poly::countof(render_targets_.color_buffers); n++) {
|
||||
auto& cb = render_targets_.color_buffers[n];
|
||||
D3D11_TEXTURE2D_DESC color_buffer_desc;
|
||||
xe_zero_struct(&color_buffer_desc, sizeof(color_buffer_desc));
|
||||
D3D11_TEXTURE2D_DESC color_buffer_desc = {};
|
||||
color_buffer_desc.Width = width;
|
||||
color_buffer_desc.Height = height;
|
||||
color_buffer_desc.MipLevels = 1;
|
||||
|
@ -865,7 +857,7 @@ int D3D11GraphicsDriver::RebuildRenderTargets(uint32_t width,
|
|||
&color_buffer_desc, NULL, &cb.buffer);
|
||||
|
||||
D3D11_RENDER_TARGET_VIEW_DESC render_target_view_desc;
|
||||
xe_zero_struct(&render_target_view_desc, sizeof(render_target_view_desc));
|
||||
memset(&render_target_view_desc, 0, sizeof(render_target_view_desc));
|
||||
render_target_view_desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||
render_target_view_desc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
|
||||
// render_target_view_desc.Buffer ?
|
||||
|
@ -875,8 +867,7 @@ int D3D11GraphicsDriver::RebuildRenderTargets(uint32_t width,
|
|||
&cb.color_view_8888);
|
||||
}
|
||||
|
||||
D3D11_TEXTURE2D_DESC depth_stencil_desc;
|
||||
xe_zero_struct(&depth_stencil_desc, sizeof(depth_stencil_desc));
|
||||
D3D11_TEXTURE2D_DESC depth_stencil_desc = {};
|
||||
depth_stencil_desc.Width = width;
|
||||
depth_stencil_desc.Height = height;
|
||||
depth_stencil_desc.MipLevels = 1;
|
||||
|
@ -891,8 +882,7 @@ int D3D11GraphicsDriver::RebuildRenderTargets(uint32_t width,
|
|||
device_->CreateTexture2D(
|
||||
&depth_stencil_desc, NULL, &render_targets_.depth_buffer);
|
||||
|
||||
D3D11_DEPTH_STENCIL_VIEW_DESC depth_stencil_view_desc;
|
||||
xe_zero_struct(&depth_stencil_view_desc, sizeof(depth_stencil_view_desc));
|
||||
D3D11_DEPTH_STENCIL_VIEW_DESC depth_stencil_view_desc = {};
|
||||
depth_stencil_view_desc.Format = DXGI_FORMAT_D24_UNORM_S8_UINT;
|
||||
depth_stencil_view_desc.ViewDimension = D3D11_DSV_DIMENSION_TEXTURE2D;
|
||||
depth_stencil_view_desc.Flags = 0;
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace d3d11 {
|
|||
class D3D11Window;
|
||||
|
||||
|
||||
GraphicsSystem* Create(Emulator* emulator);
|
||||
std::unique_ptr<GraphicsSystem> Create(Emulator* emulator);
|
||||
|
||||
|
||||
class D3D11GraphicsSystem : public GraphicsSystem {
|
||||
|
|
|
@ -175,8 +175,7 @@ bool D3D11ProfilerDisplay::SetupState() {
|
|||
HRESULT hr;
|
||||
auto device = window_->device();
|
||||
|
||||
D3D11_BLEND_DESC blend_desc;
|
||||
xe_zero_struct(&blend_desc, sizeof(blend_desc));
|
||||
D3D11_BLEND_DESC blend_desc = {0};
|
||||
blend_desc.RenderTarget[0].BlendEnable = true;
|
||||
blend_desc.RenderTarget[0].BlendOp = D3D11_BLEND_OP_ADD;
|
||||
blend_desc.RenderTarget[0].BlendOpAlpha = D3D11_BLEND_OP_ADD;
|
||||
|
@ -188,8 +187,7 @@ bool D3D11ProfilerDisplay::SetupState() {
|
|||
hr = device->CreateBlendState(&blend_desc, &blend_state_);
|
||||
assert_true(SUCCEEDED(hr));
|
||||
|
||||
D3D11_DEPTH_STENCIL_DESC depth_stencil_desc;
|
||||
xe_zero_struct(&depth_stencil_desc, sizeof(depth_stencil_desc));
|
||||
D3D11_DEPTH_STENCIL_DESC depth_stencil_desc = {0};
|
||||
depth_stencil_desc.DepthEnable = false;
|
||||
depth_stencil_desc.StencilEnable = false;
|
||||
depth_stencil_desc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ZERO;
|
||||
|
@ -371,8 +369,7 @@ bool D3D11ProfilerDisplay::SetupFont() {
|
|||
return false;
|
||||
}
|
||||
|
||||
D3D11_SHADER_RESOURCE_VIEW_DESC texture_view_desc;
|
||||
xe_zero_struct(&texture_view_desc, sizeof(texture_view_desc));
|
||||
D3D11_SHADER_RESOURCE_VIEW_DESC texture_view_desc = {};
|
||||
texture_view_desc.Format = texture_desc.Format;
|
||||
texture_view_desc.ViewDimension = D3D10_SRV_DIMENSION_TEXTURE2D;
|
||||
texture_view_desc.Texture2D.MipLevels = 1;
|
||||
|
@ -385,8 +382,7 @@ bool D3D11ProfilerDisplay::SetupFont() {
|
|||
return false;
|
||||
}
|
||||
|
||||
D3D11_SAMPLER_DESC sampler_desc;
|
||||
xe_zero_struct(&sampler_desc, sizeof(sampler_desc));
|
||||
D3D11_SAMPLER_DESC sampler_desc = {};
|
||||
sampler_desc.Filter = D3D11_ENCODE_BASIC_FILTER(
|
||||
D3D11_FILTER_TYPE_POINT, D3D11_FILTER_TYPE_POINT,
|
||||
D3D11_FILTER_TYPE_POINT, false);
|
||||
|
|
|
@ -35,8 +35,7 @@ int D3D11SamplerStateResource::Prepare() {
|
|||
return 0;
|
||||
}
|
||||
|
||||
D3D11_SAMPLER_DESC sampler_desc;
|
||||
xe_zero_struct(&sampler_desc, sizeof(sampler_desc));
|
||||
D3D11_SAMPLER_DESC sampler_desc = {};
|
||||
// MIN, MAG, MIP
|
||||
static const D3D11_FILTER filter_matrix[2][2][3] = {
|
||||
{
|
||||
|
|
|
@ -97,7 +97,7 @@ D3D11VertexShaderResource::D3D11VertexShaderResource(
|
|||
handle_(nullptr),
|
||||
input_layout_(nullptr),
|
||||
translated_src_(nullptr) {
|
||||
xe_zero_struct(geometry_shaders_, sizeof(geometry_shaders_));
|
||||
memset(geometry_shaders_, 0, sizeof(geometry_shaders_));
|
||||
}
|
||||
|
||||
D3D11VertexShaderResource::~D3D11VertexShaderResource() {
|
||||
|
@ -106,7 +106,7 @@ D3D11VertexShaderResource::~D3D11VertexShaderResource() {
|
|||
for (int i = 0; i < poly::countof(geometry_shaders_); ++i) {
|
||||
delete geometry_shaders_[i];
|
||||
}
|
||||
xe_free(translated_src_);
|
||||
free(translated_src_);
|
||||
}
|
||||
|
||||
int D3D11VertexShaderResource::Prepare(
|
||||
|
@ -135,25 +135,22 @@ int D3D11VertexShaderResource::Prepare(
|
|||
return 1;
|
||||
}
|
||||
byte_code_length = shader_blob->GetBufferSize();
|
||||
byte_code = xe_malloc(byte_code_length);
|
||||
xe_copy_struct(
|
||||
byte_code, shader_blob->GetBufferPointer(), byte_code_length);
|
||||
byte_code = malloc(byte_code_length);
|
||||
memcpy(byte_code, shader_blob->GetBufferPointer(), byte_code_length);
|
||||
SafeRelease(shader_blob);
|
||||
|
||||
// Create shader.
|
||||
HRESULT hr = resource_cache_->device()->CreateVertexShader(
|
||||
byte_code, byte_code_length,
|
||||
nullptr,
|
||||
&handle_);
|
||||
byte_code, byte_code_length, nullptr, &handle_);
|
||||
if (FAILED(hr)) {
|
||||
XELOGE("D3D11: failed to create vertex shader");
|
||||
xe_free(byte_code);
|
||||
free(byte_code);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Create input layout.
|
||||
ret = CreateInputLayout(byte_code, byte_code_length);
|
||||
xe_free(byte_code);
|
||||
free(byte_code);
|
||||
if (ret) {
|
||||
return 1;
|
||||
}
|
||||
|
@ -174,8 +171,7 @@ int D3D11VertexShaderResource::CreateInputLayout(const void* byte_code,
|
|||
return 0;
|
||||
}
|
||||
|
||||
D3D11_INPUT_ELEMENT_DESC* element_descs =
|
||||
(D3D11_INPUT_ELEMENT_DESC*)xe_alloca(
|
||||
D3D11_INPUT_ELEMENT_DESC* element_descs = (D3D11_INPUT_ELEMENT_DESC*)alloca(
|
||||
sizeof(D3D11_INPUT_ELEMENT_DESC) * element_count);
|
||||
uint32_t el_index = 0;
|
||||
for (uint32_t n = 0; n < inputs.count; n++) {
|
||||
|
@ -327,7 +323,7 @@ D3D11PixelShaderResource::D3D11PixelShaderResource(
|
|||
|
||||
D3D11PixelShaderResource::~D3D11PixelShaderResource() {
|
||||
SafeRelease(handle_);
|
||||
xe_free(translated_src_);
|
||||
free(translated_src_);
|
||||
}
|
||||
|
||||
int D3D11PixelShaderResource::Prepare(const xe_gpu_program_cntl_t& program_cntl,
|
||||
|
@ -358,9 +354,8 @@ int D3D11PixelShaderResource::Prepare(const xe_gpu_program_cntl_t& program_cntl,
|
|||
return 1;
|
||||
}
|
||||
byte_code_length = shader_blob->GetBufferSize();
|
||||
byte_code = xe_malloc(byte_code_length);
|
||||
xe_copy_struct(
|
||||
byte_code, shader_blob->GetBufferPointer(), byte_code_length);
|
||||
byte_code = malloc(byte_code_length);
|
||||
memcpy(byte_code, shader_blob->GetBufferPointer(), byte_code_length);
|
||||
SafeRelease(shader_blob);
|
||||
|
||||
// Create shader.
|
||||
|
@ -370,11 +365,11 @@ int D3D11PixelShaderResource::Prepare(const xe_gpu_program_cntl_t& program_cntl,
|
|||
&handle_);
|
||||
if (FAILED(hr)) {
|
||||
XELOGE("D3D11: failed to create pixel shader");
|
||||
xe_free(byte_code);
|
||||
free(byte_code);
|
||||
return 1;
|
||||
}
|
||||
|
||||
xe_free(byte_code);
|
||||
free(byte_code);
|
||||
is_prepared_ = true;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -37,8 +37,7 @@ D3D11TextureResource::~D3D11TextureResource() {
|
|||
int D3D11TextureResource::CreateHandle() {
|
||||
SCOPE_profile_cpu_f("gpu");
|
||||
|
||||
D3D11_SHADER_RESOURCE_VIEW_DESC srv_desc;
|
||||
xe_zero_struct(&srv_desc, sizeof(srv_desc));
|
||||
D3D11_SHADER_RESOURCE_VIEW_DESC srv_desc = {};
|
||||
// TODO(benvanik): this may need to be typed on the fetch instruction (float/int/etc?)
|
||||
srv_desc.Format = info_.format;
|
||||
|
||||
|
@ -94,8 +93,7 @@ int D3D11TextureResource::CreateHandle() {
|
|||
int D3D11TextureResource::CreateHandle1D() {
|
||||
uint32_t width = 1 + info_.size_1d.width;
|
||||
|
||||
D3D11_TEXTURE1D_DESC texture_desc;
|
||||
xe_zero_struct(&texture_desc, sizeof(texture_desc));
|
||||
D3D11_TEXTURE1D_DESC texture_desc = {};
|
||||
texture_desc.Width = width;
|
||||
texture_desc.MipLevels = 1;
|
||||
texture_desc.ArraySize = 1;
|
||||
|
@ -113,8 +111,7 @@ int D3D11TextureResource::CreateHandle1D() {
|
|||
}
|
||||
|
||||
int D3D11TextureResource::CreateHandle2D() {
|
||||
D3D11_TEXTURE2D_DESC texture_desc;
|
||||
xe_zero_struct(&texture_desc, sizeof(texture_desc));
|
||||
D3D11_TEXTURE2D_DESC texture_desc = {};
|
||||
texture_desc.Width = info_.size_2d.output_width;
|
||||
texture_desc.Height = info_.size_2d.output_height;
|
||||
texture_desc.MipLevels = 1;
|
||||
|
|
|
@ -57,8 +57,7 @@ int D3D11Window::Initialize(const std::wstring& title, uint32_t width,
|
|||
}
|
||||
|
||||
// Setup swap chain.
|
||||
DXGI_SWAP_CHAIN_DESC desc;
|
||||
xe_zero_struct(&desc, sizeof(desc));
|
||||
DXGI_SWAP_CHAIN_DESC desc = {};
|
||||
desc.OutputWindow = handle();
|
||||
desc.Windowed = TRUE;
|
||||
desc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL;
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include <xenia/hid/hid.h>
|
||||
#include <xenia/hid/hid-private.h>
|
||||
#include <xenia/hid/input_driver.h>
|
||||
|
||||
using namespace xe;
|
||||
using namespace xe::hid;
|
||||
|
|
|
@ -19,12 +19,7 @@ namespace hid {
|
|||
InputSystem::InputSystem(Emulator* emulator)
|
||||
: emulator_(emulator), memory_(emulator->memory()) {}
|
||||
|
||||
InputSystem::~InputSystem() {
|
||||
for (auto it = drivers_.begin(); it != drivers_.end(); ++it) {
|
||||
InputDriver* driver = *it;
|
||||
delete driver;
|
||||
}
|
||||
}
|
||||
InputSystem::~InputSystem() = default;
|
||||
|
||||
X_STATUS InputSystem::Setup() {
|
||||
processor_ = emulator_->processor();
|
||||
|
@ -32,14 +27,15 @@ X_STATUS InputSystem::Setup() {
|
|||
return X_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
void InputSystem::AddDriver(InputDriver* driver) { drivers_.push_back(driver); }
|
||||
void InputSystem::AddDriver(std::unique_ptr<InputDriver> driver) {
|
||||
drivers_.push_back(std::move(driver));
|
||||
}
|
||||
|
||||
X_RESULT InputSystem::GetCapabilities(uint32_t user_index, uint32_t flags,
|
||||
X_INPUT_CAPABILITIES* out_caps) {
|
||||
SCOPE_profile_cpu_f("hid");
|
||||
|
||||
for (auto it = drivers_.begin(); it != drivers_.end(); ++it) {
|
||||
InputDriver* driver = *it;
|
||||
for (auto& driver : drivers_) {
|
||||
if (XSUCCEEDED(driver->GetCapabilities(user_index, flags, out_caps))) {
|
||||
return X_ERROR_SUCCESS;
|
||||
}
|
||||
|
@ -50,8 +46,7 @@ X_RESULT InputSystem::GetCapabilities(uint32_t user_index, uint32_t flags,
|
|||
X_RESULT InputSystem::GetState(uint32_t user_index, X_INPUT_STATE* out_state) {
|
||||
SCOPE_profile_cpu_f("hid");
|
||||
|
||||
for (auto it = drivers_.begin(); it != drivers_.end(); ++it) {
|
||||
InputDriver* driver = *it;
|
||||
for (auto& driver : drivers_) {
|
||||
if (driver->GetState(user_index, out_state) == X_ERROR_SUCCESS) {
|
||||
return X_ERROR_SUCCESS;
|
||||
}
|
||||
|
@ -63,8 +58,7 @@ X_RESULT InputSystem::SetState(uint32_t user_index,
|
|||
X_INPUT_VIBRATION* vibration) {
|
||||
SCOPE_profile_cpu_f("hid");
|
||||
|
||||
for (auto it = drivers_.begin(); it != drivers_.end(); ++it) {
|
||||
InputDriver* driver = *it;
|
||||
for (auto& driver : drivers_) {
|
||||
if (XSUCCEEDED(driver->SetState(user_index, vibration))) {
|
||||
return X_ERROR_SUCCESS;
|
||||
}
|
||||
|
@ -76,8 +70,7 @@ X_RESULT InputSystem::GetKeystroke(uint32_t user_index, uint32_t flags,
|
|||
X_INPUT_KEYSTROKE* out_keystroke) {
|
||||
SCOPE_profile_cpu_f("hid");
|
||||
|
||||
for (auto it = drivers_.begin(); it != drivers_.end(); ++it) {
|
||||
InputDriver* driver = *it;
|
||||
for (auto& driver : drivers_) {
|
||||
if (XSUCCEEDED(driver->GetKeystroke(user_index, flags, out_keystroke))) {
|
||||
return X_ERROR_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#ifndef XENIA_HID_INPUT_SYSTEM_H_
|
||||
#define XENIA_HID_INPUT_SYSTEM_H_
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include <xenia/core.h>
|
||||
|
@ -32,7 +33,7 @@ class InputSystem {
|
|||
|
||||
X_STATUS Setup();
|
||||
|
||||
void AddDriver(InputDriver* driver);
|
||||
void AddDriver(std::unique_ptr<InputDriver> driver);
|
||||
|
||||
X_RESULT GetCapabilities(uint32_t user_index, uint32_t flags,
|
||||
X_INPUT_CAPABILITIES* out_caps);
|
||||
|
@ -46,7 +47,7 @@ class InputSystem {
|
|||
Memory* memory_;
|
||||
cpu::Processor* processor_;
|
||||
|
||||
std::vector<InputDriver*> drivers_;
|
||||
std::vector<std::unique_ptr<InputDriver>> drivers_;
|
||||
};
|
||||
|
||||
} // namespace hid
|
||||
|
|
|
@ -23,7 +23,7 @@ DiscImageFile::DiscImageFile(KernelState* kernel_state, Mode mode,
|
|||
DiscImageEntry* entry)
|
||||
: XFile(kernel_state, mode), entry_(entry) {}
|
||||
|
||||
DiscImageFile::~DiscImageFile() {}
|
||||
DiscImageFile::~DiscImageFile() { delete entry_; }
|
||||
|
||||
const std::string& DiscImageFile::path() const { return entry_->path(); }
|
||||
|
||||
|
|
|
@ -22,7 +22,10 @@ HostPathFile::HostPathFile(KernelState* kernel_state, Mode mode,
|
|||
file_handle_(file_handle),
|
||||
XFile(kernel_state, mode) {}
|
||||
|
||||
HostPathFile::~HostPathFile() { CloseHandle(file_handle_); }
|
||||
HostPathFile::~HostPathFile() {
|
||||
CloseHandle(file_handle_);
|
||||
delete entry_;
|
||||
}
|
||||
|
||||
const std::string& HostPathFile::path() const { return entry_->path(); }
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ STFSContainerFile::STFSContainerFile(KernelState* kernel_state, Mode mode,
|
|||
STFSContainerEntry* entry)
|
||||
: entry_(entry), XFile(kernel_state, mode) {}
|
||||
|
||||
STFSContainerFile::~STFSContainerFile() {}
|
||||
STFSContainerFile::~STFSContainerFile() { delete entry_; }
|
||||
|
||||
const std::string& STFSContainerFile::path() const { return entry_->path(); }
|
||||
|
||||
|
|
|
@ -176,6 +176,16 @@ std::unique_ptr<Entry> FileSystem::ResolvePath(const std::string& path) {
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
X_STATUS FileSystem::Open(std::unique_ptr<Entry> entry,
|
||||
KernelState* kernel_state, Mode mode, bool async,
|
||||
XFile** out_file) {
|
||||
auto result = entry->Open(kernel_state, mode, async, out_file);
|
||||
if (XSUCCEEDED(result)) {
|
||||
entry.release();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace fs
|
||||
} // namespace kernel
|
||||
} // namespace xe
|
||||
|
|
|
@ -52,6 +52,8 @@ class FileSystem {
|
|||
int DeleteSymbolicLink(const std::string& path);
|
||||
|
||||
std::unique_ptr<Entry> ResolvePath(const std::string& path);
|
||||
X_STATUS Open(std::unique_ptr<Entry> entry, KernelState* kernel_state,
|
||||
Mode mode, bool async, XFile** out_file);
|
||||
|
||||
private:
|
||||
std::vector<Device*> devices_;
|
||||
|
|
|
@ -62,7 +62,8 @@ X_STATUS XUserModule::LoadFromFile(const char* path) {
|
|||
std::vector<uint8_t> buffer(file_info.file_length);
|
||||
|
||||
// Open file for reading.
|
||||
result = fs_entry->Open(kernel_state(), fs::Mode::READ, false, &file);
|
||||
result = kernel_state()->file_system()->Open(
|
||||
std::move(fs_entry), kernel_state(), fs::Mode::READ, false, &file);
|
||||
XEEXPECTZERO(result);
|
||||
|
||||
// Read entire file into memory.
|
||||
|
|
|
@ -105,7 +105,7 @@ SHIM_CALL NtCreateFile_shim(PPCContext* ppc_state, KernelState* state) {
|
|||
XFile* file = NULL;
|
||||
if (entry && entry->type() == Entry::Type::FILE) {
|
||||
// Open the file.
|
||||
result = entry->Open(state, mode,
|
||||
result = fs->Open(std::move(entry), state, mode,
|
||||
false, // TODO(benvanik): pick async mode, if needed.
|
||||
&file);
|
||||
} else {
|
||||
|
@ -173,7 +173,7 @@ SHIM_CALL NtOpenFile_shim(PPCContext* ppc_state, KernelState* state) {
|
|||
XFile* file = NULL;
|
||||
if (entry && entry->type() == Entry::Type::FILE) {
|
||||
// Open the file.
|
||||
result = entry->Open(state, mode,
|
||||
result = fs->Open(std::move(entry), state, mode,
|
||||
false, // TODO(benvanik): pick async mode, if needed.
|
||||
&file);
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue