Skip to content

Commit

Permalink
[#17] : Added breakdown timer
Browse files Browse the repository at this point in the history
  • Loading branch information
ange-yaghi committed Jul 8, 2020
1 parent f27013b commit 69de1ed
Show file tree
Hide file tree
Showing 33 changed files with 348 additions and 119 deletions.
4 changes: 3 additions & 1 deletion engines/basic/src/delta_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ ysError dbasic::DeltaEngine::CreateGameWindow(const char *title, void *instance,

// Create the game window
YDS_NESTED_ERROR_CALL(m_windowSystem->NewWindow(&m_gameWindow));
YDS_NESTED_ERROR_CALL(m_gameWindow->InitializeWindow(nullptr, title, ysWindow::WindowStyle::WINDOWED, 0, 0, 1920, 1080, mainMonitor));
YDS_NESTED_ERROR_CALL(m_gameWindow->InitializeWindow(nullptr, title, ysWindow::WindowStyle::Windowed, 0, 0, 1920, 1080, mainMonitor));
m_gameWindow->AttachEventHandler(&m_windowHandler);

// Create the graphics device
Expand All @@ -140,6 +140,8 @@ ysError dbasic::DeltaEngine::CreateGameWindow(const char *title, void *instance,
// Main render target
YDS_NESTED_ERROR_CALL(m_device->CreateOnScreenRenderTarget(&m_mainRenderTarget, m_renderingContext, depthBuffer));

m_mainRenderTarget->SetDebugName("MAIN_RENDER_TARGET");

// Initialize Geometry
YDS_NESTED_ERROR_CALL(InitializeGeometry());

Expand Down
6 changes: 3 additions & 3 deletions engines/basic/src/window_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ dbasic::WindowHandler::~WindowHandler() {
}

void dbasic::WindowHandler::OnResizeWindow(int width, int height) {
m_engine->SetWindowSize(width, height);
m_device->UpdateRenderingContext(m_context);
m_engine->GetConsole()->ResetScreenPosition();
//m_engine->SetWindowSize(width, height);
//m_device->UpdateRenderingContext(m_context);
//m_engine->GetConsole()->ResetScreenPosition();
}

void dbasic::WindowHandler::Initialize(ysDevice *device, ysRenderingContext *context, DeltaEngine *engine) {
Expand Down
4 changes: 0 additions & 4 deletions include/yds_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,12 @@ class ysObject : public ysDynamicArrayElement {
//#define RaiseError(condition, format, ...) ((void)0)
//#endif

void SetDebugName(const char *debugName);
const char *GetDebugName() const { return m_debugName; }
const char *GetTypeID() const { return m_typeID; }

protected:
const char *m_debugName;
const char *m_typeID;
};


// TEMP
#include "yds_error_system.h"

Expand Down
27 changes: 27 additions & 0 deletions include/yds_breakdown_timer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#ifndef YDS_BREAKDOWN_TIMER_H
#define YDS_BREAKDOWN_TIMER_H

#include "yds_base.h"

#include "yds_expanding_array.h"
#include "yds_breakdown_timer_channel.h"

class ysBreakdownTimer : public ysObject {
public:
ysBreakdownTimer();
~ysBreakdownTimer();

int GetChannelCount() const { return m_channels.GetNumObjects(); }

void StartFrame();
void StartMeasurement(const std::string &timerChannelName);
void EndMasurement(const std::string &timerChannelName);

protected:
ysBreakdownTimerChannel *FindChannel(const std::string &s);

ysExpandingArray<ysBreakdownTimerChannel, 4> m_channels;
ysExpandingArray<std::string, 4> m_executionOrder;
};

#endif /* YDS_BREAKDOWN_TIMER_H */
33 changes: 33 additions & 0 deletions include/yds_breakdown_timer_channel.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#ifndef YDS_BREAKDOWN_TIMER_CHANNEL_H
#define YDS_BREAKDOWN_TIMER_CHANNEL_H

#include "yds_base.h"

#include <string>

class ysBreakdownTimerChannel : public ysObject {
public:
ysBreakdownTimerChannel();
~ysBreakdownTimerChannel();

void Initialize(int bufferSize);
void Reset();
void Destroy();

void SetName(const std::string &name) { m_name = name; }
std::string GetName() const { return m_name; }

int GetEntryCount() const { return m_entryCount; }

void RecordSample(float s);
float GetSample(int i) const;

protected:
std::string m_name;
float *m_sampleBuffer;
int m_bufferSize;
int m_currentBufferOffset;
int m_entryCount;
};

#endif /* YDS_BREAKDOWN_TIMER_CHANNEL_H */
6 changes: 6 additions & 0 deletions include/yds_context_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#include "yds_base.h"

#include <string>

class ysContextObject : public ysObject {
public:
enum class DeviceAPI {
Expand All @@ -21,8 +23,12 @@ class ysContextObject : public ysObject {

bool CheckCompatibility(ysContextObject *object) const { return (object) ? object->m_api == m_api : true; }

virtual void SetDebugName(const std::string &debugName) { m_debugName = debugName; }
std::string GetDebugName() const { return m_debugName; }

private:
DeviceAPI m_api;
std::string m_debugName;
};

#endif /* YDS_CONTEXT_OBJECT_H */
11 changes: 4 additions & 7 deletions include/yds_d3d11_gpu_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,17 @@
#include "yds_gpu_buffer.h"
#include <d3d11.h>

class ysD3D11GPUBuffer : public ysGPUBuffer
{

class ysD3D11GPUBuffer : public ysGPUBuffer {
friend class ysD3D11Device;

public:

ysD3D11GPUBuffer();
virtual ~ysD3D11GPUBuffer();

protected:
virtual void SetDebugName(const std::string &debugName);

protected:
ID3D11Buffer *m_buffer;

};

#endif
#endif /* YDS_D3D11_GPU_BUFFER_H */
10 changes: 4 additions & 6 deletions include/yds_d3d11_input_layout.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,18 @@

#include <D3D11.h>

class ysD3D11InputLayout : public ysInputLayout
{

class ysD3D11InputLayout : public ysInputLayout {
friend class ysD3D11Device;

public:

ysD3D11InputLayout();
virtual ~ysD3D11InputLayout();

protected:
virtual void SetDebugName(const std::string &debugName);

protected:
ID3D11InputLayout *m_layout;

};

#endif
#endif /* YDS_D3D11_INPUT_LAYOUT_H */
2 changes: 2 additions & 0 deletions include/yds_d3d11_render_target.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class ysD3D11RenderTarget : public ysRenderTarget {
ysD3D11RenderTarget();
virtual ~ysD3D11RenderTarget();

virtual void SetDebugName(const std::string &debugName);

protected:
ID3D11ShaderResourceView *m_resourceView;
ID3D11RenderTargetView *m_renderTargetView;
Expand Down
16 changes: 5 additions & 11 deletions include/yds_d3d11_shader.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,23 @@

#include <d3d11.h>

class ysD3D11Shader : public ysShader
{

class ysD3D11Shader : public ysShader {
friend class ysD3D11Device;

public:

ysD3D11Shader();
virtual ~ysD3D11Shader();

protected:
virtual void SetDebugName(const std::string &debugName);

protected:
ID3D10Blob *m_shaderBlob;

union
{

union {
ID3D11VertexShader * m_vertexShader;
ID3D11PixelShader * m_pixelShader;
ID3D11GeometryShader * m_geometryShader;

};

};

#endif
#endif /* YDS_D3D11_SHADER_H */
11 changes: 4 additions & 7 deletions include/yds_d3d11_texture.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,18 @@

#include <D3D11.h>

class ysD3D11Texture : public ysTexture
{

class ysD3D11Texture : public ysTexture {
friend class ysD3D11Device;

public:

ysD3D11Texture();
~ysD3D11Texture();

protected:
virtual void SetDebugName(const std::string &debugName);

protected:
ID3D11ShaderResourceView *m_resourceView;
ID3D11RenderTargetView *m_renderTargetView;

};

#endif
#endif /* YDS_D3D11_TEXTURE_H */
10 changes: 10 additions & 0 deletions include/yds_d3d11_utilities.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#ifndef YDS_D3D11_UTILITIES_H
#define YDS_D3D11_UTILITIES_H

#include <string>

struct ID3D11DeviceChild;

void D3D11SetDebugName(ID3D11DeviceChild *object, const std::string &name);

#endif /* YDS_D3D11_UTILITIES_H */
2 changes: 2 additions & 0 deletions include/yds_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ class ysDevice : public ysContextObject {
// Initialize texture slots
ysError InitializeTextureSlots(int maxSlots);

/* Debug */

// TEMP
virtual void Draw(int numFaces, int indexOffset, int vertexOffset) { (void)numFaces; (void)indexOffset; (void)vertexOffset; }

Expand Down
14 changes: 3 additions & 11 deletions include/yds_time_tag_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,21 @@

#include "yds_expanding_array.h"

class ysTimeTagData
{

class ysTimeTagData {
public:

struct TimeTag
{

struct TimeTag {
char Name[64];
int Frame;

};

public:

ysTimeTagData();
~ysTimeTagData();

void Clear();

int m_timeTagCount;
ysExpandingArray<TimeTag, 1> m_timeTags;

};

#endif
#endif /* YDS_TIME_TAG_DATA_H */
27 changes: 17 additions & 10 deletions include/yds_window.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@ class ysWindow : public ysWindowSystemObject {
static const int MAX_NAME_LENGTH = 256;

enum class WindowState {
VISIBLE,
HIDDEN,
MAXIMIZED,
MINIMIZED,
CLOSED,
Visible,
Hidden,
Maximized,
Minimized,
Closed,
Unknown
};

enum class WindowStyle {
WINDOWED,
FULLSCREEN,
POPUP,
Windowed,
Fullscreen,
Popup,
Unknown
};

Expand All @@ -36,8 +36,8 @@ class ysWindow : public ysWindowSystemObject {
virtual ysError InitializeWindow(ysWindow *parent, const char *title, WindowStyle style, int x, int y, int width, int height, ysMonitor *monitor);
virtual ysError InitializeWindow(ysWindow *parent, const char *title, WindowStyle style, ysMonitor *monitor);

virtual void Close() { SetState(WindowState::CLOSED); }
virtual void SetState(WindowState state = WindowState::VISIBLE) { m_windowState = state; }
virtual void Close() { SetState(WindowState::Closed); }
virtual void SetState(WindowState state = WindowState::Visible) { m_windowState = state; }

void RestoreWindow();

Expand All @@ -59,6 +59,10 @@ class ysWindow : public ysWindowSystemObject {
virtual void SetLocation(int x, int y);
virtual void SetTitle(const char *title);

virtual void StartResizing() { m_resizing = true; }
virtual void EndResizing() { m_resizing = false; }
bool IsResizing() const { return m_resizing; }

virtual bool SetWindowStyle(WindowStyle style);

void AttachEventHandler(ysWindowEventHandler *handler);
Expand Down Expand Up @@ -122,6 +126,9 @@ class ysWindow : public ysWindowSystemObject {
// Window Active
bool m_active;

// Status flag indicating whether the window is resizing
bool m_resizing;

protected:
// Event handler
ysWindowEventHandler *m_eventHandler;
Expand Down
2 changes: 1 addition & 1 deletion include/yds_windows_window.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class ysWindowsWindow : public ysWindow {

virtual void Close();
virtual void SetTitle(const char *title);
virtual void SetState(WindowState state = WindowState::VISIBLE);
virtual void SetState(WindowState state = WindowState::Visible);

virtual void AL_SetSize(int width, int height);
virtual void AL_SetLocation(int x, int y);
Expand Down
2 changes: 2 additions & 0 deletions project/delta-core/delta-core.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
<ClInclude Include="..\..\include\yds_d3d11_shader.h" />
<ClInclude Include="..\..\include\yds_d3d11_shader_program.h" />
<ClInclude Include="..\..\include\yds_d3d11_texture.h" />
<ClInclude Include="..\..\include\yds_d3d11_utilities.h" />
<ClInclude Include="..\..\include\yds_depth_buffer.h" />
<ClInclude Include="..\..\include\yds_device.h" />
<ClInclude Include="..\..\include\yds_ds8_audio_buffer.h" />
Expand Down Expand Up @@ -166,6 +167,7 @@
<ClCompile Include="..\..\src\yds_d3d11_shader.cpp" />
<ClCompile Include="..\..\src\yds_d3d11_shader_program.cpp" />
<ClCompile Include="..\..\src\yds_d3d11_texture.cpp" />
<ClCompile Include="..\..\src\yds_d3d11_utilities.cpp" />
<ClCompile Include="..\..\src\yds_depth_buffer.cpp" />
<ClCompile Include="..\..\src\yds_device.cpp" />
<ClCompile Include="..\..\src\yds_ds8_audio_buffer.cpp" />
Expand Down
Loading

0 comments on commit 69de1ed

Please sign in to comment.