XECOUNT to countof.
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
|
||||
#include <xenia/gpu/d3d11/d3d11_geometry_shader.h>
|
||||
|
||||
#include <poly/math.h>
|
||||
#include <xenia/core/hash.h>
|
||||
#include <xenia/gpu/gpu-private.h>
|
||||
#include <xenia/gpu/d3d11/d3d11_shader_resource.h>
|
||||
@@ -98,7 +99,7 @@ ID3D10Blob* D3D11GeometryShader::Compile(const char* shader_source) {
|
||||
}
|
||||
uint64_t hash = hash64(shader_source, strlen(shader_source)); // ?
|
||||
char file_name[poly::max_path];
|
||||
xesnprintfa(file_name, XECOUNT(file_name),
|
||||
xesnprintfa(file_name, poly::countof(file_name),
|
||||
"%s/gen_%.16llX.gs",
|
||||
base_path,
|
||||
hash);
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include <xenia/gpu/d3d11/d3d11_graphics_driver.h>
|
||||
|
||||
#include <poly/math.h>
|
||||
#include <xenia/core/hash.h>
|
||||
#include <xenia/gpu/gpu-private.h>
|
||||
#include <xenia/gpu/buffer_resource.h>
|
||||
@@ -249,7 +250,7 @@ int D3D11GraphicsDriver::UpdateState(const DrawCommand& command) {
|
||||
register_file_[XE_GPU_REG_RB_COLOR3_INFO].u32,
|
||||
};
|
||||
ID3D11RenderTargetView* render_target_views[4] = { 0 };
|
||||
for (int n = 0; n < XECOUNT(color_info); n++) {
|
||||
for (int n = 0; n < poly::countof(color_info); n++) {
|
||||
auto cb = render_targets_.color_buffers[n];
|
||||
uint32_t color_format = (color_info[n] >> 16) & 0xF;
|
||||
switch (color_format) {
|
||||
@@ -484,7 +485,7 @@ int D3D11GraphicsDriver::SetupBlendState(const DrawCommand& command) {
|
||||
//blend_desc.AlphaToCoverageEnable = false;
|
||||
// ?
|
||||
blend_desc.IndependentBlendEnable = true;
|
||||
for (int n = 0; n < XECOUNT(blend_control); n++) {
|
||||
for (int n = 0; n < poly::countof(blend_control); n++) {
|
||||
// A2XX_RB_BLEND_CONTROL_COLOR_SRCBLEND
|
||||
blend_desc.RenderTarget[n].SrcBlend = blend_map[(blend_control[n] & 0x0000001F) >> 0];
|
||||
// A2XX_RB_BLEND_CONTROL_COLOR_DESTBLEND
|
||||
@@ -642,13 +643,14 @@ int D3D11GraphicsDriver::SetupShaders(const DrawCommand& command) {
|
||||
|
||||
// Set constant buffers.
|
||||
ID3D11Buffer* vs_constant_buffers[] = {
|
||||
state_.constant_buffers.float_constants,
|
||||
state_.constant_buffers.bool_constants,
|
||||
state_.constant_buffers.loop_constants,
|
||||
state_.constant_buffers.vs_consts,
|
||||
state_.constant_buffers.float_constants,
|
||||
state_.constant_buffers.bool_constants,
|
||||
state_.constant_buffers.loop_constants,
|
||||
state_.constant_buffers.vs_consts,
|
||||
};
|
||||
context_->VSSetConstantBuffers(0, XECOUNT(vs_constant_buffers),
|
||||
vs_constant_buffers);
|
||||
context_->VSSetConstantBuffers(
|
||||
0, static_cast<UINT>(poly::countof(vs_constant_buffers)),
|
||||
vs_constant_buffers);
|
||||
|
||||
// Setup input layout (as encoded in vertex shader).
|
||||
auto vs = static_cast<D3D11VertexShaderResource*>(command.vertex_shader);
|
||||
@@ -666,12 +668,13 @@ int D3D11GraphicsDriver::SetupShaders(const DrawCommand& command) {
|
||||
|
||||
// Set constant buffers.
|
||||
ID3D11Buffer* vs_constant_buffers[] = {
|
||||
state_.constant_buffers.float_constants,
|
||||
state_.constant_buffers.bool_constants,
|
||||
state_.constant_buffers.loop_constants,
|
||||
state_.constant_buffers.float_constants,
|
||||
state_.constant_buffers.bool_constants,
|
||||
state_.constant_buffers.loop_constants,
|
||||
};
|
||||
context_->PSSetConstantBuffers(0, XECOUNT(vs_constant_buffers),
|
||||
vs_constant_buffers);
|
||||
context_->PSSetConstantBuffers(
|
||||
0, static_cast<UINT>(poly::countof(vs_constant_buffers)),
|
||||
vs_constant_buffers);
|
||||
} else {
|
||||
context_->PSSetShader(nullptr, nullptr, 0);
|
||||
return 1;
|
||||
@@ -824,7 +827,7 @@ int D3D11GraphicsDriver::RebuildRenderTargets(uint32_t width,
|
||||
SCOPE_profile_cpu_f("gpu");
|
||||
|
||||
// Remove old versions.
|
||||
for (int n = 0; n < XECOUNT(render_targets_.color_buffers); n++) {
|
||||
for (int n = 0; n < poly::countof(render_targets_.color_buffers); n++) {
|
||||
auto& cb = render_targets_.color_buffers[n];
|
||||
SafeRelease(cb.buffer);
|
||||
SafeRelease(cb.color_view_8888);
|
||||
@@ -841,7 +844,7 @@ int D3D11GraphicsDriver::RebuildRenderTargets(uint32_t width,
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (int n = 0; n < XECOUNT(render_targets_.color_buffers); n++) {
|
||||
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));
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include <xenia/gpu/d3d11/d3d11_graphics_system.h>
|
||||
|
||||
#include <poly/math.h>
|
||||
#include <xenia/emulator.h>
|
||||
#include <xenia/gpu/gpu-private.h>
|
||||
#include <xenia/gpu/d3d11/d3d11_graphics_driver.h>
|
||||
@@ -89,7 +90,7 @@ void D3D11GraphicsSystem::Initialize() {
|
||||
0, // software driver HMODULE
|
||||
flags,
|
||||
feature_levels,
|
||||
XECOUNT(feature_levels),
|
||||
static_cast<UINT>(poly::countof(feature_levels)),
|
||||
D3D11_SDK_VERSION,
|
||||
&device_,
|
||||
&actual_feature_level,
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include <poly/math.h>
|
||||
#include <xenia/gpu/gpu-private.h>
|
||||
#include <xenia/gpu/d3d11/d3d11_window.h>
|
||||
|
||||
@@ -267,14 +268,23 @@ bool D3D11ProfilerDisplay::SetupShaders() {
|
||||
}
|
||||
|
||||
D3D11_INPUT_ELEMENT_DESC element_descs[] = {
|
||||
{ "POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0, },
|
||||
{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0, },
|
||||
{ "COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0, },
|
||||
{
|
||||
"POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0,
|
||||
D3D11_INPUT_PER_VERTEX_DATA, 0,
|
||||
},
|
||||
{
|
||||
"TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT,
|
||||
D3D11_INPUT_PER_VERTEX_DATA, 0,
|
||||
},
|
||||
{
|
||||
"COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, D3D11_APPEND_ALIGNED_ELEMENT,
|
||||
D3D11_INPUT_PER_VERTEX_DATA, 0,
|
||||
},
|
||||
};
|
||||
hr = device->CreateInputLayout(element_descs, (UINT)XECOUNT(element_descs),
|
||||
vs_code_blob->GetBufferPointer(),
|
||||
vs_code_blob->GetBufferSize(),
|
||||
&shader_layout_);
|
||||
hr = device->CreateInputLayout(
|
||||
element_descs, (UINT)poly::countof(element_descs),
|
||||
vs_code_blob->GetBufferPointer(), vs_code_blob->GetBufferSize(),
|
||||
&shader_layout_);
|
||||
if (FAILED(hr)) {
|
||||
XELOGE("Failed to create profiler input layout");
|
||||
return false;
|
||||
@@ -298,7 +308,7 @@ bool D3D11ProfilerDisplay::SetupFont() {
|
||||
auto device = window_->device();
|
||||
|
||||
// Setup font lookup table.
|
||||
for (uint32_t i = 0; i < XECOUNT(font_description_.char_offsets); ++i) {
|
||||
for (uint32_t i = 0; i < poly::countof(font_description_.char_offsets); ++i) {
|
||||
font_description_.char_offsets[i] = 206;
|
||||
}
|
||||
for (uint32_t i = 'A'; i <= 'Z'; ++i) {
|
||||
@@ -468,12 +478,14 @@ void D3D11ProfilerDisplay::Begin() {
|
||||
font_sampler_state_,
|
||||
nullptr,
|
||||
};
|
||||
context->PSSetSamplers(0, XECOUNT(ps_samplers), ps_samplers);
|
||||
ID3D11ShaderResourceView* ps_resources[D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT] = {
|
||||
font_texture_view_,
|
||||
nullptr,
|
||||
};
|
||||
context->PSSetShaderResources(0, XECOUNT(ps_resources), ps_resources);
|
||||
context->PSSetSamplers(0, static_cast<UINT>(poly::countof(ps_samplers)),
|
||||
ps_samplers);
|
||||
ID3D11ShaderResourceView*
|
||||
ps_resources[D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT] = {
|
||||
font_texture_view_, nullptr,
|
||||
};
|
||||
context->PSSetShaderResources(
|
||||
0, static_cast<UINT>(poly::countof(ps_resources)), ps_resources);
|
||||
context->IASetInputLayout(shader_layout_);
|
||||
}
|
||||
|
||||
@@ -483,19 +495,23 @@ void D3D11ProfilerDisplay::End() {
|
||||
|
||||
D3D11ProfilerDisplay::Vertex* D3D11ProfilerDisplay::AllocateVertices(
|
||||
D3D_PRIMITIVE_TOPOLOGY primitive, size_t count) {
|
||||
if (draw_state_.vertex_index + count > XECOUNT(draw_state_.vertex_buffer)) {
|
||||
if (draw_state_.vertex_index + count >
|
||||
poly::countof(draw_state_.vertex_buffer)) {
|
||||
Flush();
|
||||
}
|
||||
assert_true(draw_state_.vertex_index + count <= XECOUNT(draw_state_.vertex_buffer));
|
||||
assert_true(draw_state_.vertex_index + count <=
|
||||
poly::countof(draw_state_.vertex_buffer));
|
||||
|
||||
size_t head = draw_state_.vertex_index;
|
||||
draw_state_.vertex_index += count;
|
||||
|
||||
if (draw_state_.command_index &&
|
||||
draw_state_.commands[draw_state_.command_index - 1].primitive == primitive) {
|
||||
draw_state_.commands[draw_state_.command_index - 1].primitive ==
|
||||
primitive) {
|
||||
draw_state_.commands[draw_state_.command_index - 1].vertex_count += count;
|
||||
} else {
|
||||
assert_true(draw_state_.command_index < XECOUNT(draw_state_.commands));
|
||||
assert_true(draw_state_.command_index <
|
||||
poly::countof(draw_state_.commands));
|
||||
draw_state_.commands[draw_state_.command_index].primitive = primitive;
|
||||
draw_state_.commands[draw_state_.command_index].vertex_count = count;
|
||||
++draw_state_.command_index;
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include <xenia/gpu/d3d11/d3d11_shader_resource.h>
|
||||
|
||||
#include <poly/math.h>
|
||||
#include <xenia/core/hash.h>
|
||||
#include <xenia/gpu/gpu-private.h>
|
||||
#include <xenia/gpu/d3d11/d3d11_geometry_shader.h>
|
||||
@@ -49,7 +50,7 @@ ID3D10Blob* D3D11ShaderCompile(XE_GPU_SHADER_TYPE type,
|
||||
}
|
||||
size_t hash = hash64(disasm_source, strlen(disasm_source)); // ?
|
||||
char file_name[poly::max_path];
|
||||
xesnprintfa(file_name, XECOUNT(file_name),
|
||||
xesnprintfa(file_name, poly::countof(file_name),
|
||||
"%s/gen_%.16llX.%s",
|
||||
base_path,
|
||||
hash,
|
||||
@@ -105,7 +106,7 @@ D3D11VertexShaderResource::D3D11VertexShaderResource(
|
||||
D3D11VertexShaderResource::~D3D11VertexShaderResource() {
|
||||
SafeRelease(handle_);
|
||||
SafeRelease(input_layout_);
|
||||
for (int i = 0; i < XECOUNT(geometry_shaders_); ++i) {
|
||||
for (int i = 0; i < poly::countof(geometry_shaders_); ++i) {
|
||||
delete geometry_shaders_[i];
|
||||
}
|
||||
xe_free(translated_src_);
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
#include <xenia/gpu/graphics_system.h>
|
||||
|
||||
#include <poly/threading.h>
|
||||
#include <poly/poly.h>
|
||||
#include <xenia/emulator.h>
|
||||
#include <xenia/cpu/processor.h>
|
||||
#include <xenia/gpu/command_processor.h>
|
||||
@@ -199,5 +199,5 @@ void GraphicsSystem::DispatchInterruptCallback(
|
||||
}
|
||||
uint64_t args[] = { source, interrupt_callback_data_ };
|
||||
processor_->ExecuteInterrupt(
|
||||
cpu, interrupt_callback_, args, XECOUNT(args));
|
||||
cpu, interrupt_callback_, args, poly::countof(args));
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include <xenia/gpu/shader_resource.h>
|
||||
|
||||
#include <poly/math.h>
|
||||
#include <xenia/gpu/xenos/ucode_disassembler.h>
|
||||
|
||||
|
||||
@@ -188,7 +189,7 @@ void ShaderResource::GatherVertexFetch(const instr_fetch_vtx_t* vtx) {
|
||||
auto& desc = inputs.descs[n];
|
||||
auto& info = desc.info;
|
||||
if (desc.fetch_slot == fetch_slot) {
|
||||
assert_true(info.element_count <= XECOUNT(info.elements));
|
||||
assert_true(info.element_count <= poly::countof(info.elements));
|
||||
// It may not hold that all strides are equal, but I hope it does.
|
||||
assert_true(!vtx->stride || info.stride_words == vtx->stride);
|
||||
el = &info.elements[info.element_count++];
|
||||
@@ -197,7 +198,7 @@ void ShaderResource::GatherVertexFetch(const instr_fetch_vtx_t* vtx) {
|
||||
}
|
||||
if (!el) {
|
||||
assert_not_zero(vtx->stride);
|
||||
assert_true(inputs.count + 1 < XECOUNT(inputs.descs));
|
||||
assert_true(inputs.count + 1 < poly::countof(inputs.descs));
|
||||
auto& desc = inputs.descs[inputs.count++];
|
||||
desc.input_index = inputs.count - 1;
|
||||
desc.fetch_slot = fetch_slot;
|
||||
@@ -251,7 +252,7 @@ void ShaderResource::GatherVertexFetch(const instr_fetch_vtx_t* vtx) {
|
||||
void ShaderResource::GatherTextureFetch(const xenos::instr_fetch_tex_t* tex) {
|
||||
// TODO(benvanik): check dest_swiz to see if we are writing anything.
|
||||
|
||||
assert_true(sampler_inputs_.count + 1 < XECOUNT(sampler_inputs_.descs));
|
||||
assert_true(sampler_inputs_.count + 1 < poly::countof(sampler_inputs_.descs));
|
||||
auto& input = sampler_inputs_.descs[sampler_inputs_.count++];
|
||||
input.input_index = sampler_inputs_.count - 1;
|
||||
input.fetch_slot = tex->const_idx & 0xF; // ?
|
||||
|
||||
Reference in New Issue
Block a user