Adding a bunch of profiling tracers.
This commit is contained in:
@@ -34,6 +34,8 @@ D3D11GeometryShader::~D3D11GeometryShader() {
|
||||
}
|
||||
|
||||
int D3D11GeometryShader::Prepare(D3D11VertexShader* vertex_shader) {
|
||||
SCOPE_profile_cpu_f("gpu");
|
||||
|
||||
if (handle_) {
|
||||
return 0;
|
||||
}
|
||||
@@ -74,6 +76,8 @@ int D3D11GeometryShader::Prepare(D3D11VertexShader* vertex_shader) {
|
||||
}
|
||||
|
||||
ID3D10Blob* D3D11GeometryShader::Compile(const char* shader_source) {
|
||||
SCOPE_profile_cpu_f("gpu");
|
||||
|
||||
// TODO(benvanik): pick shared runtime mode defines.
|
||||
D3D10_SHADER_MACRO defines[] = {
|
||||
"TEST_DEFINE", "1",
|
||||
@@ -161,6 +165,7 @@ D3D11PointSpriteGeometryShader::~D3D11PointSpriteGeometryShader() {
|
||||
|
||||
int D3D11PointSpriteGeometryShader::Generate(D3D11VertexShader* vertex_shader,
|
||||
alloy::StringBuffer* output) {
|
||||
SCOPE_profile_cpu_f("gpu");
|
||||
if (D3D11GeometryShader::Generate(vertex_shader, output)) {
|
||||
return 1;
|
||||
}
|
||||
@@ -215,6 +220,7 @@ D3D11RectListGeometryShader::~D3D11RectListGeometryShader() {
|
||||
|
||||
int D3D11RectListGeometryShader::Generate(D3D11VertexShader* vertex_shader,
|
||||
alloy::StringBuffer* output) {
|
||||
SCOPE_profile_cpu_f("gpu");
|
||||
if (D3D11GeometryShader::Generate(vertex_shader, output)) {
|
||||
return 1;
|
||||
}
|
||||
@@ -259,6 +265,7 @@ D3D11QuadListGeometryShader::~D3D11QuadListGeometryShader() {
|
||||
|
||||
int D3D11QuadListGeometryShader::Generate(D3D11VertexShader* vertex_shader,
|
||||
alloy::StringBuffer* output) {
|
||||
SCOPE_profile_cpu_f("gpu");
|
||||
if (D3D11GeometryShader::Generate(vertex_shader, output)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -190,6 +190,8 @@ void D3D11GraphicsDriver::SetShader(
|
||||
}
|
||||
|
||||
int D3D11GraphicsDriver::SetupDraw(XE_GPU_PRIMITIVE_TYPE prim_type) {
|
||||
SCOPE_profile_cpu_f("gpu");
|
||||
|
||||
RegisterFile& rf = register_file_;
|
||||
|
||||
// Ignore copies.
|
||||
@@ -296,6 +298,8 @@ void D3D11GraphicsDriver::DrawIndexBuffer(
|
||||
XE_GPU_PRIMITIVE_TYPE prim_type,
|
||||
bool index_32bit, uint32_t index_count,
|
||||
uint32_t index_base, uint32_t index_size, uint32_t endianness) {
|
||||
SCOPE_profile_cpu_f("gpu");
|
||||
|
||||
RegisterFile& rf = register_file_;
|
||||
|
||||
XETRACED3D("D3D11: draw indexed %d (%d indicies) from %.8X",
|
||||
@@ -321,6 +325,8 @@ void D3D11GraphicsDriver::DrawIndexBuffer(
|
||||
void D3D11GraphicsDriver::DrawIndexAuto(
|
||||
XE_GPU_PRIMITIVE_TYPE prim_type,
|
||||
uint32_t index_count) {
|
||||
SCOPE_profile_cpu_f("gpu");
|
||||
|
||||
RegisterFile& rf = register_file_;
|
||||
|
||||
XETRACED3D("D3D11: draw indexed %d (%d indicies)",
|
||||
@@ -346,6 +352,8 @@ int D3D11GraphicsDriver::RebuildRenderTargets(
|
||||
return 0;
|
||||
}
|
||||
|
||||
SCOPE_profile_cpu_f("gpu");
|
||||
|
||||
// Remove old versions.
|
||||
for (int n = 0; n < XECOUNT(render_targets_.color_buffers); n++) {
|
||||
auto& cb = render_targets_.color_buffers[n];
|
||||
@@ -426,6 +434,8 @@ int D3D11GraphicsDriver::RebuildRenderTargets(
|
||||
}
|
||||
|
||||
int D3D11GraphicsDriver::UpdateState(uint32_t state_overrides) {
|
||||
SCOPE_profile_cpu_f("gpu");
|
||||
|
||||
// Most information comes from here:
|
||||
// https://chromium.googlesource.com/chromiumos/third_party/mesa/+/6173cc19c45d92ef0b7bc6aa008aa89bb29abbda/src/gallium/drivers/freedreno/freedreno_zsa.c
|
||||
// http://cgit.freedesktop.org/mesa/mesa/diff/?id=aac7f06ad843eaa696363e8e9c7781ca30cb4914
|
||||
@@ -768,6 +778,8 @@ int D3D11GraphicsDriver::UpdateState(uint32_t state_overrides) {
|
||||
}
|
||||
|
||||
int D3D11GraphicsDriver::UpdateConstantBuffers() {
|
||||
SCOPE_profile_cpu_f("gpu");
|
||||
|
||||
RegisterFile& rf = register_file_;
|
||||
|
||||
D3D11_MAPPED_SUBRESOURCE res;
|
||||
@@ -799,6 +811,8 @@ int D3D11GraphicsDriver::UpdateConstantBuffers() {
|
||||
}
|
||||
|
||||
int D3D11GraphicsDriver::BindShaders() {
|
||||
SCOPE_profile_cpu_f("gpu");
|
||||
|
||||
RegisterFile& rf = register_file_;
|
||||
xe_gpu_program_cntl_t program_cntl;
|
||||
program_cntl.dword_0 = rf.values[XE_GPU_REG_SQ_PROGRAM_CNTL].u32;
|
||||
@@ -892,6 +906,8 @@ int D3D11GraphicsDriver::BindShaders() {
|
||||
}
|
||||
|
||||
int D3D11GraphicsDriver::PrepareFetchers() {
|
||||
SCOPE_profile_cpu_f("gpu");
|
||||
|
||||
// Input assembly.
|
||||
XEASSERTNOTNULL(state_.vertex_shader);
|
||||
auto vtx_inputs = state_.vertex_shader->GetVertexBufferInputs();
|
||||
@@ -934,6 +950,8 @@ int D3D11GraphicsDriver::PrepareFetchers() {
|
||||
}
|
||||
|
||||
int D3D11GraphicsDriver::PrepareVertexBuffer(Shader::vtx_buffer_desc_t& desc) {
|
||||
SCOPE_profile_cpu_f("gpu");
|
||||
|
||||
RegisterFile& rf = register_file_;
|
||||
int r = XE_GPU_REG_SHADER_CONSTANT_FETCH_00_0 + (desc.fetch_slot / 3) * 6;
|
||||
xe_gpu_fetch_group_t* group = (xe_gpu_fetch_group_t*)&rf.values[r];
|
||||
@@ -1009,6 +1027,8 @@ int D3D11GraphicsDriver::PrepareVertexBuffer(Shader::vtx_buffer_desc_t& desc) {
|
||||
}
|
||||
|
||||
int D3D11GraphicsDriver::PrepareTextureFetchers() {
|
||||
SCOPE_profile_cpu_f("gpu");
|
||||
|
||||
RegisterFile& rf = register_file_;
|
||||
|
||||
for (int n = 0; n < XECOUNT(state_.texture_fetchers); n++) {
|
||||
@@ -1275,6 +1295,8 @@ int D3D11GraphicsDriver::FetchTexture1D(
|
||||
xe_gpu_texture_fetch_t& fetch,
|
||||
TextureInfo& info,
|
||||
ID3D11Resource** out_texture) {
|
||||
SCOPE_profile_cpu_f("gpu");
|
||||
|
||||
uint32_t address = (fetch.address << 12) + address_translation_;
|
||||
|
||||
uint32_t width = 1 + fetch.size_1d.width;
|
||||
@@ -1299,6 +1321,8 @@ int D3D11GraphicsDriver::FetchTexture1D(
|
||||
}
|
||||
|
||||
XEFORCEINLINE void TextureSwap(uint8_t* dest, const uint8_t* src, uint32_t pitch, XE_GPU_ENDIAN endianness) {
|
||||
SCOPE_profile_cpu_f("gpu");
|
||||
|
||||
switch (endianness) {
|
||||
case XE_GPU_ENDIAN_8IN16:
|
||||
for (uint32_t i = 0; i < pitch; i += 2, src += 2, dest += 2) {
|
||||
@@ -1344,6 +1368,8 @@ int D3D11GraphicsDriver::FetchTexture2D(
|
||||
xe_gpu_texture_fetch_t& fetch,
|
||||
TextureInfo& info,
|
||||
ID3D11Resource** out_texture) {
|
||||
SCOPE_profile_cpu_f("gpu");
|
||||
|
||||
XEASSERTTRUE(fetch.dimension == 1);
|
||||
|
||||
uint32_t address = (fetch.address << 12) + address_translation_;
|
||||
@@ -1448,6 +1474,8 @@ int D3D11GraphicsDriver::FetchTexture3D(
|
||||
xe_gpu_texture_fetch_t& fetch,
|
||||
TextureInfo& info,
|
||||
ID3D11Resource** out_texture) {
|
||||
SCOPE_profile_cpu_f("gpu");
|
||||
|
||||
XELOGE("D3D11: FetchTexture2D not yet implemented");
|
||||
XEASSERTALWAYS();
|
||||
return 1;
|
||||
@@ -1470,6 +1498,8 @@ int D3D11GraphicsDriver::FetchTextureCube(
|
||||
xe_gpu_texture_fetch_t& fetch,
|
||||
TextureInfo& info,
|
||||
ID3D11Resource** out_texture) {
|
||||
SCOPE_profile_cpu_f("gpu");
|
||||
|
||||
XELOGE("D3D11: FetchTextureCube not yet implemented");
|
||||
XEASSERTALWAYS();
|
||||
return 1;
|
||||
@@ -1477,6 +1507,7 @@ int D3D11GraphicsDriver::FetchTextureCube(
|
||||
|
||||
int D3D11GraphicsDriver::PrepareTextureSampler(
|
||||
xenos::XE_GPU_SHADER_TYPE shader_type, Shader::tex_buffer_desc_t& desc) {
|
||||
SCOPE_profile_cpu_f("gpu");
|
||||
|
||||
auto& fetcher = state_.texture_fetchers[desc.fetch_slot];
|
||||
auto& info = fetcher.info;
|
||||
@@ -1588,6 +1619,8 @@ int D3D11GraphicsDriver::PrepareTextureSampler(
|
||||
int D3D11GraphicsDriver::PrepareIndexBuffer(
|
||||
bool index_32bit, uint32_t index_count,
|
||||
uint32_t index_base, uint32_t index_size, uint32_t endianness) {
|
||||
SCOPE_profile_cpu_f("gpu");
|
||||
|
||||
RegisterFile& rf = register_file_;
|
||||
|
||||
uint32_t address = index_base + address_translation_;
|
||||
@@ -1634,6 +1667,8 @@ int D3D11GraphicsDriver::PrepareIndexBuffer(
|
||||
}
|
||||
|
||||
int D3D11GraphicsDriver::Resolve() {
|
||||
SCOPE_profile_cpu_f("gpu");
|
||||
|
||||
// No clue how this is supposed to work yet.
|
||||
ID3D11Texture2D* back_buffer = 0;
|
||||
swap_chain_->GetBuffer(0, __uuidof(ID3D11Texture2D),
|
||||
|
||||
@@ -29,6 +29,7 @@ void __stdcall D3D11GraphicsSystemVsyncCallback(
|
||||
thread_name_set = true;
|
||||
Profiler::ThreadEnter("VsyncTimer");
|
||||
}
|
||||
SCOPE_profile_cpu_f("gpu");
|
||||
|
||||
gs->MarkVblank();
|
||||
gs->DispatchInterruptCallback(0);
|
||||
@@ -151,6 +152,8 @@ void D3D11GraphicsSystem::Initialize() {
|
||||
}
|
||||
|
||||
void D3D11GraphicsSystem::Pump() {
|
||||
SCOPE_profile_cpu_f("gpu");
|
||||
|
||||
if (swap_pending_) {
|
||||
swap_pending_ = false;
|
||||
|
||||
|
||||
@@ -145,6 +145,8 @@ void D3D11Shader::set_translated_src(char* value) {
|
||||
}
|
||||
|
||||
ID3D10Blob* D3D11Shader::Compile(const char* shader_source) {
|
||||
SCOPE_profile_cpu_f("gpu");
|
||||
|
||||
// TODO(benvanik): pick shared runtime mode defines.
|
||||
D3D10_SHADER_MACRO defines[] = {
|
||||
"TEST_DEFINE", "1",
|
||||
@@ -256,6 +258,7 @@ D3D11VertexShader::~D3D11VertexShader() {
|
||||
}
|
||||
|
||||
int D3D11VertexShader::Prepare(xe_gpu_program_cntl_t* program_cntl) {
|
||||
SCOPE_profile_cpu_f("gpu");
|
||||
if (handle_) {
|
||||
return 0;
|
||||
}
|
||||
@@ -411,6 +414,8 @@ int D3D11VertexShader::Prepare(xe_gpu_program_cntl_t* program_cntl) {
|
||||
}
|
||||
|
||||
const char* D3D11VertexShader::Translate(xe_gpu_program_cntl_t* program_cntl) {
|
||||
SCOPE_profile_cpu_f("gpu");
|
||||
|
||||
Output* output = new Output();
|
||||
xe_gpu_translate_ctx_t ctx;
|
||||
ctx.output = output;
|
||||
@@ -599,6 +604,7 @@ D3D11PixelShader::~D3D11PixelShader() {
|
||||
|
||||
int D3D11PixelShader::Prepare(xe_gpu_program_cntl_t* program_cntl,
|
||||
D3D11VertexShader* input_shader) {
|
||||
SCOPE_profile_cpu_f("gpu");
|
||||
if (handle_) {
|
||||
return 0;
|
||||
}
|
||||
@@ -641,6 +647,7 @@ int D3D11PixelShader::Prepare(xe_gpu_program_cntl_t* program_cntl,
|
||||
|
||||
const char* D3D11PixelShader::Translate(
|
||||
xe_gpu_program_cntl_t* program_cntl, D3D11VertexShader* input_shader) {
|
||||
SCOPE_profile_cpu_f("gpu");
|
||||
Output* output = new Output();
|
||||
xe_gpu_translate_ctx_t ctx;
|
||||
ctx.output = output;
|
||||
|
||||
@@ -31,6 +31,7 @@ Shader* D3D11ShaderCache::CreateCore(
|
||||
xenos::XE_GPU_SHADER_TYPE type,
|
||||
const uint8_t* src_ptr, size_t length,
|
||||
uint64_t hash) {
|
||||
SCOPE_profile_cpu_f("gpu");
|
||||
switch (type) {
|
||||
case XE_GPU_SHADER_TYPE_VERTEX:
|
||||
return new D3D11VertexShader(
|
||||
|
||||
@@ -114,6 +114,8 @@ int D3D11Window::Initialize(const char* title, uint32_t width, uint32_t height)
|
||||
}
|
||||
|
||||
void D3D11Window::Swap() {
|
||||
SCOPE_profile_cpu_f("gpu");
|
||||
|
||||
// Present profiler.
|
||||
context_->OMSetRenderTargets(1, &render_target_view_, NULL);
|
||||
Profiler::Present();
|
||||
|
||||
@@ -125,6 +125,8 @@ void RingBufferWorker::Pump() {
|
||||
|
||||
void RingBufferWorker::ExecutePrimaryBuffer(
|
||||
uint32_t start_index, uint32_t end_index) {
|
||||
SCOPE_profile_cpu_f("gpu");
|
||||
|
||||
// Adjust pointer base.
|
||||
uint32_t ptr = primary_buffer_ptr_ + start_index * 4;
|
||||
ptr = (primary_buffer_ptr_ & ~0x1FFFFFFF) | (ptr & 0x1FFFFFFF);
|
||||
|
||||
@@ -55,6 +55,8 @@ Shader* ShaderCache::Find(
|
||||
Shader* ShaderCache::FindOrCreate(
|
||||
XE_GPU_SHADER_TYPE type,
|
||||
const uint8_t* src_ptr, size_t length) {
|
||||
SCOPE_profile_cpu_f("gpu");
|
||||
|
||||
uint64_t hash = Hash(src_ptr, length);
|
||||
unordered_map<uint64_t, Shader*>::iterator it = map_.find(hash);
|
||||
if (it != map_.end()) {
|
||||
|
||||
Reference in New Issue
Block a user