Skip to content

Commit

Permalink
success adding gpu shader
Browse files Browse the repository at this point in the history
  • Loading branch information
duchuule committed Sep 23, 2015
1 parent 94ab1ac commit a629f07
Show file tree
Hide file tree
Showing 15 changed files with 15,240 additions and 35 deletions.
4 changes: 2 additions & 2 deletions DXSpriteBatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ namespace Engine

this->QueueSprite(info);

this->FlushBatch();
//this->FlushBatch();
}

void DXSpriteBatch::Draw(const Rectangle &target, const Rectangle *source, ID3D11ShaderResourceView *textureSRV, ID3D11Texture2D *texture, float depth, Color &color)
Expand Down Expand Up @@ -445,7 +445,7 @@ namespace Engine
return;
}

sort_heap(this->queuedSprites.begin(), this->queuedSprites.end(), this->heapSort);
//sort_heap(this->queuedSprites.begin(), this->queuedSprites.end(), this->heapSort);

this->FlushBatch();

Expand Down
10 changes: 9 additions & 1 deletion EmulatorRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,10 @@ namespace VBA10

void EmulatorRenderer::CreateDeviceDependentResources()
{
//intialize the shader loader
this->shaderManager = new ShaderManager(m_deviceResources->GetD3DDevice());
this->shaderManager->LoadShader(0);

//this does not seem neccessary
m_deviceResources->GetD3DDevice()->GetImmediateContext2(m_deviceResources->GetD3DDeviceContextAddress());

Expand Down Expand Up @@ -734,7 +738,7 @@ namespace VBA10


this->dxSpriteBatch->Begin(x, EmulatorSettings::Current->LinearFilterEnabled);

this->dxSpriteBatch->SetCustomPixelShader(this->shaderManager->GetCurrentShader());
Engine::Rectangle sourceRect(source.left, source.top, source.right - source.left, source.bottom - source.top);
Engine::Rectangle targetRect(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top);

Expand All @@ -743,6 +747,10 @@ namespace VBA10
//else
//this->dxSpriteBatch->Draw(targetRect, &sourceRect, this->bufferSRVBig.Get(), this->bufferBig.Get(), white);


this->dxSpriteBatch->End();

this->dxSpriteBatch->Begin(x, true);
//divider
Color dividerColor(86.0f / 255, 105.0f / 255, 108.0f / 255, 1.0f);
if (this->height > this->width)
Expand Down
3 changes: 2 additions & 1 deletion EmulatorRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "Emulator.h"
#include "VirtualControllerInput.h"
#include "DXSpriteBatch.h"
#include "Filter\ShaderManager.h"

#include "..\Common\DeviceResources.h"
#include "..\Common\StepTimer.h"
Expand Down Expand Up @@ -35,7 +36,7 @@ namespace VBA10
private:
// Cached pointer to device resources.
std::shared_ptr<DX::DeviceResources> m_deviceResources;

ShaderManager* shaderManager;

HANDLE waitEvent;

Expand Down
32 changes: 32 additions & 0 deletions Filter/ShaderManager.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#include "ShaderManager.h"
#include "xBR5_PS.h"

using namespace VBA10;
using namespace Microsoft::WRL;

ShaderManager *ShaderManager::instance = nullptr;

ShaderManager::ShaderManager(ID3D11Device1 *device):device(device)
{
ShaderManager::instance = this;
}

ShaderManager *ShaderManager::GetInstance()
{
return ShaderManager::instance;
}

void ShaderManager::LoadShader(int selection)
{
HRESULT test;
if (FAILED(test = this->device->CreatePixelShader(
XBR5_PS,
sizeof(XBR5_PS),
NULL,
&this->ps)))
{

}


}
26 changes: 26 additions & 0 deletions Filter/ShaderManager.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#pragma once

#include <d3d11_1.h>
#include <collection.h>




namespace VBA10
{
class ShaderManager
{
public:


ShaderManager(ID3D11Device1 *device);
static ShaderManager *GetInstance();

ID3D11PixelShader* GetCurrentShader() {return this->ps.Get();};
void LoadShader(int selection);
private:
Microsoft::WRL::ComPtr<ID3D11Device1> device;
Microsoft::WRL::ComPtr<ID3D11PixelShader> ps;
static ShaderManager *instance;
};
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit a629f07

Please sign in to comment.