mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-24 05:49:58 +00:00
Implement DrawUP for D3D11
This is so we can do simple drawing without buffer management through thin3d on all backends.
This commit is contained in:
parent
d6664f20e0
commit
d4d92e39ff
@ -38,6 +38,7 @@ class D3D11Pipeline;
|
||||
class D3D11BlendState;
|
||||
class D3D11DepthStencilState;
|
||||
class D3D11SamplerState;
|
||||
class D3D11Buffer;
|
||||
class D3D11RasterState;
|
||||
class D3D11Framebuffer;
|
||||
|
||||
@ -252,6 +253,7 @@ private:
|
||||
|
||||
// Temporaries
|
||||
ID3D11Texture2D *packTexture_ = nullptr;
|
||||
Buffer *upBuffer_ = nullptr;
|
||||
|
||||
// System info
|
||||
D3D_FEATURE_LEVEL featureLevel_;
|
||||
@ -338,9 +340,14 @@ D3D11DrawContext::D3D11DrawContext(ID3D11Device *device, ID3D11DeviceContext *de
|
||||
_assert_(SUCCEEDED(hr));
|
||||
|
||||
shaderLanguageDesc_.Init(HLSL_D3D11);
|
||||
|
||||
const size_t UP_MAX_BYTES = 65536 * 24;
|
||||
|
||||
upBuffer_ = CreateBuffer(UP_MAX_BYTES, BufferUsageFlag::DYNAMIC | BufferUsageFlag::VERTEXDATA);
|
||||
}
|
||||
|
||||
D3D11DrawContext::~D3D11DrawContext() {
|
||||
upBuffer_->Release();
|
||||
packTexture_->Release();
|
||||
|
||||
// Release references.
|
||||
@ -756,9 +763,6 @@ public:
|
||||
shaderModule->Release();
|
||||
}
|
||||
}
|
||||
bool RequiresBuffer() override {
|
||||
return true;
|
||||
}
|
||||
|
||||
AutoRef<D3D11InputLayout> input;
|
||||
ID3D11InputLayout *il = nullptr;
|
||||
@ -1248,7 +1252,13 @@ void D3D11DrawContext::DrawIndexed(int indexCount, int offset) {
|
||||
|
||||
void D3D11DrawContext::DrawUP(const void *vdata, int vertexCount) {
|
||||
ApplyCurrentState();
|
||||
// TODO: Upload the data then draw..
|
||||
|
||||
int byteSize = vertexCount * curPipeline_->input->strides[0];
|
||||
|
||||
UpdateBuffer(upBuffer_, (const uint8_t *)vdata, 0, byteSize, Draw::UPDATE_DISCARD);
|
||||
BindVertexBuffers(0, 1, &upBuffer_, nullptr);
|
||||
int offset = 0;
|
||||
Draw(vertexCount, offset);
|
||||
}
|
||||
|
||||
uint32_t D3D11DrawContext::GetDataFormatSupport(DataFormat fmt) const {
|
||||
|
@ -272,9 +272,6 @@ public:
|
||||
D3D9Pipeline() {}
|
||||
~D3D9Pipeline() {
|
||||
}
|
||||
bool RequiresBuffer() override {
|
||||
return false;
|
||||
}
|
||||
|
||||
D3D9ShaderModule *vshader;
|
||||
D3D9ShaderModule *pshader;
|
||||
|
@ -261,9 +261,6 @@ public:
|
||||
~OpenGLInputLayout();
|
||||
|
||||
void Compile(const InputLayoutDesc &desc);
|
||||
bool RequiresBuffer() {
|
||||
return false;
|
||||
}
|
||||
|
||||
GLRInputLayout *inputLayout_ = nullptr;
|
||||
int stride = 0;
|
||||
@ -284,10 +281,6 @@ public:
|
||||
|
||||
bool LinkShaders();
|
||||
|
||||
bool RequiresBuffer() override {
|
||||
return inputLayout && inputLayout->RequiresBuffer();
|
||||
}
|
||||
|
||||
GLuint prim = 0;
|
||||
std::vector<OpenGLShaderModule *> shaders;
|
||||
AutoRef<OpenGLInputLayout> inputLayout;
|
||||
|
@ -271,9 +271,6 @@ public:
|
||||
int GetUBOSize() const {
|
||||
return uboSize_;
|
||||
}
|
||||
bool RequiresBuffer() override {
|
||||
return false;
|
||||
}
|
||||
|
||||
VkPipeline backbufferPipeline = VK_NULL_HANDLE;
|
||||
VkPipeline framebufferPipeline = VK_NULL_HANDLE;
|
||||
|
@ -450,7 +450,6 @@ public:
|
||||
class Pipeline : public RefCountedObject {
|
||||
public:
|
||||
virtual ~Pipeline() {}
|
||||
virtual bool RequiresBuffer() = 0;
|
||||
};
|
||||
|
||||
class RasterState : public RefCountedObject {};
|
||||
|
@ -32,12 +32,6 @@ void DrawBuffer::Init(Draw::DrawContext *t3d, Draw::Pipeline *pipeline) {
|
||||
|
||||
draw_ = t3d;
|
||||
inited_ = true;
|
||||
|
||||
if (pipeline->RequiresBuffer()) {
|
||||
vbuf_ = draw_->CreateBuffer(MAX_VERTS * sizeof(Vertex), BufferUsageFlag::DYNAMIC | BufferUsageFlag::VERTEXDATA);
|
||||
} else {
|
||||
vbuf_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
Draw::InputLayout *DrawBuffer::CreateInputLayout(Draw::DrawContext *t3d) {
|
||||
@ -57,10 +51,6 @@ Draw::InputLayout *DrawBuffer::CreateInputLayout(Draw::DrawContext *t3d) {
|
||||
}
|
||||
|
||||
void DrawBuffer::Shutdown() {
|
||||
if (vbuf_) {
|
||||
vbuf_->Release();
|
||||
vbuf_ = nullptr;
|
||||
}
|
||||
inited_ = false;
|
||||
alphaStack_.clear();
|
||||
drawMatrixStack_.clear();
|
||||
@ -90,14 +80,7 @@ void DrawBuffer::Flush(bool set_blend_state) {
|
||||
ub.tint = tint_;
|
||||
ub.saturation = saturation_;
|
||||
draw_->UpdateDynamicUniformBuffer(&ub, sizeof(ub));
|
||||
if (vbuf_) {
|
||||
draw_->UpdateBuffer(vbuf_, (const uint8_t *)verts_, 0, sizeof(Vertex) * count_, Draw::UPDATE_DISCARD);
|
||||
draw_->BindVertexBuffers(0, 1, &vbuf_, nullptr);
|
||||
int offset = 0;
|
||||
draw_->Draw(count_, offset);
|
||||
} else {
|
||||
draw_->DrawUP((const void *)verts_, count_);
|
||||
}
|
||||
draw_->DrawUP((const void *)verts_, count_);
|
||||
count_ = 0;
|
||||
}
|
||||
|
||||
|
@ -199,7 +199,6 @@ private:
|
||||
std::vector<float> alphaStack_;
|
||||
|
||||
Draw::DrawContext *draw_ = nullptr;
|
||||
Draw::Buffer *vbuf_ = nullptr;
|
||||
Draw::Pipeline *pipeline_ = nullptr;
|
||||
|
||||
Vertex *verts_;
|
||||
|
Loading…
Reference in New Issue
Block a user