mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-29 23:33:00 +00:00
Remove the reserved vbo_shadowdata so only hw_vertexbuffer still needs it
This commit is contained in:
parent
2c9a1cbab7
commit
c43cef96d1
8 changed files with 32 additions and 80 deletions
|
@ -48,37 +48,6 @@
|
|||
|
||||
FFlatVertexBuffer::FFlatVertexBuffer(DFrameBuffer* fb, int width, int height, int pipelineNbr) : fb(fb), mPipelineNbr(pipelineNbr)
|
||||
{
|
||||
vbo_shadowdata.Resize(NUM_RESERVED);
|
||||
|
||||
// the first quad is reserved for handling coordinates through uniforms.
|
||||
vbo_shadowdata[0].Set(0, 0, 0, 0, 0);
|
||||
vbo_shadowdata[1].Set(1, 0, 0, 0, 0);
|
||||
vbo_shadowdata[2].Set(2, 0, 0, 0, 0);
|
||||
vbo_shadowdata[3].Set(3, 0, 0, 0, 0);
|
||||
|
||||
// and the second one for the fullscreen quad used for blend overlays.
|
||||
vbo_shadowdata[4].Set(0, 0, 0, 0, 0);
|
||||
vbo_shadowdata[5].Set(0, (float)height, 0, 0, 1);
|
||||
vbo_shadowdata[6].Set((float)width, 0, 0, 1, 0);
|
||||
vbo_shadowdata[7].Set((float)width, (float)height, 0, 1, 1);
|
||||
|
||||
// and this is for the postprocessing copy operation
|
||||
vbo_shadowdata[8].Set(-1.0f, -1.0f, 0, 0.0f, 0.0f);
|
||||
vbo_shadowdata[9].Set(3.0f, -1.0f, 0, 2.f, 0.0f);
|
||||
vbo_shadowdata[10].Set(-1.0f, 3.0f, 0, 0.0f, 2.f);
|
||||
vbo_shadowdata[11].Set(3.0f, 3.0f, 0, 2.f, 2.f); // Note: not used anymore
|
||||
|
||||
// The next two are the stencil caps.
|
||||
vbo_shadowdata[12].Set(-32767.0f, 32767.0f, -32767.0f, 0, 0);
|
||||
vbo_shadowdata[13].Set(-32767.0f, 32767.0f, 32767.0f, 0, 0);
|
||||
vbo_shadowdata[14].Set(32767.0f, 32767.0f, 32767.0f, 0, 0);
|
||||
vbo_shadowdata[15].Set(32767.0f, 32767.0f, -32767.0f, 0, 0);
|
||||
|
||||
vbo_shadowdata[16].Set(-32767.0f, -32767.0f, -32767.0f, 0, 0);
|
||||
vbo_shadowdata[17].Set(-32767.0f, -32767.0f, 32767.0f, 0, 0);
|
||||
vbo_shadowdata[18].Set(32767.0f, -32767.0f, 32767.0f, 0, 0);
|
||||
vbo_shadowdata[19].Set(32767.0f, -32767.0f, -32767.0f, 0, 0);
|
||||
|
||||
mIndexBuffer = fb->CreateIndexBuffer();
|
||||
int data[4] = {};
|
||||
mIndexBuffer->SetData(4, data, BufferUsageType::Static); // On Vulkan this may not be empty, so set some dummy defaults to avoid crashes.
|
||||
|
@ -99,9 +68,7 @@ FFlatVertexBuffer::FFlatVertexBuffer(DFrameBuffer* fb, int width, int height, in
|
|||
|
||||
mVertexBuffer = mVertexBufferPipeline[mPipelinePos];
|
||||
|
||||
mIndex = mCurIndex = NUM_RESERVED;
|
||||
mNumReserved = NUM_RESERVED;
|
||||
Copy(0, NUM_RESERVED);
|
||||
mIndex = mCurIndex = 0;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
@ -128,21 +95,6 @@ FFlatVertexBuffer::~FFlatVertexBuffer()
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
void FFlatVertexBuffer::OutputResized(int width, int height)
|
||||
{
|
||||
vbo_shadowdata[4].Set(0, 0, 0, 0, 0);
|
||||
vbo_shadowdata[5].Set(0, (float)height, 0, 0, 1);
|
||||
vbo_shadowdata[6].Set((float)width, 0, 0, 1, 0);
|
||||
vbo_shadowdata[7].Set((float)width, (float)height, 0, 1, 1);
|
||||
Copy(4, 4);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
std::pair<FFlatVertex *, unsigned int> FFlatVertexBuffer::AllocVertices(unsigned int count)
|
||||
{
|
||||
FFlatVertex *p = GetBuffer();
|
||||
|
@ -169,7 +121,7 @@ void FFlatVertexBuffer::Copy(int start, int count)
|
|||
{
|
||||
mVertexBuffer = mVertexBufferPipeline[n];
|
||||
Map();
|
||||
memcpy(GetBuffer(start), &vbo_shadowdata[0], count * sizeof(FFlatVertex));
|
||||
memcpy(GetBuffer(start), vbo_shadowdata.Data(), count * sizeof(FFlatVertex));
|
||||
Unmap();
|
||||
mVertexBuffer->Upload(start * sizeof(FFlatVertex), count * sizeof(FFlatVertex));
|
||||
}
|
||||
|
|
|
@ -73,7 +73,6 @@ public:
|
|||
|
||||
unsigned int mIndex;
|
||||
std::atomic<unsigned int> mCurIndex;
|
||||
unsigned int mNumReserved;
|
||||
|
||||
unsigned int mMapStart;
|
||||
|
||||
|
@ -81,21 +80,9 @@ public:
|
|||
static const unsigned int BUFFER_SIZE_TO_USE = BUFFER_SIZE-500;
|
||||
|
||||
public:
|
||||
enum
|
||||
{
|
||||
QUAD_INDEX = 0,
|
||||
FULLSCREEN_INDEX = 4,
|
||||
PRESENT_INDEX = 8,
|
||||
STENCILTOP_INDEX = 12,
|
||||
STENCILBOTTOM_INDEX = 16,
|
||||
|
||||
NUM_RESERVED = 20
|
||||
};
|
||||
|
||||
FFlatVertexBuffer(DFrameBuffer* fb, int width, int height, int pipelineNbr = 1);
|
||||
~FFlatVertexBuffer();
|
||||
|
||||
void OutputResized(int width, int height);
|
||||
std::pair<IBuffer*, IBuffer*> GetBufferObjects() const
|
||||
{
|
||||
return std::make_pair(mVertexBuffer, mIndexBuffer);
|
||||
|
|
|
@ -103,7 +103,6 @@ void DFrameBuffer::Update()
|
|||
{
|
||||
SetVirtualSize(clientWidth, clientHeight);
|
||||
V_OutputResized(clientWidth, clientHeight);
|
||||
mVertexData->OutputResized(clientWidth, clientHeight);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -366,9 +366,6 @@ void VkPPRenderPassSetup::CreatePipeline(const VkPPRenderPassKey& key)
|
|||
builder.AddVertexShader(key.Shader->VertexShader.get());
|
||||
builder.AddFragmentShader(key.Shader->FragmentShader.get());
|
||||
|
||||
builder.AddVertexBufferBinding(0, sizeof(FFlatVertex));
|
||||
builder.AddVertexAttribute(0, 0, VK_FORMAT_R32G32B32_SFLOAT, offsetof(FFlatVertex, x));
|
||||
builder.AddVertexAttribute(1, 0, VK_FORMAT_R32G32_SFLOAT, offsetof(FFlatVertex, u));
|
||||
builder.AddDynamicState(VK_DYNAMIC_STATE_VIEWPORT);
|
||||
builder.AddDynamicState(VK_DYNAMIC_STATE_SCISSOR);
|
||||
// Note: the actual values are ignored since we use dynamic viewport+scissor states
|
||||
|
|
|
@ -122,18 +122,14 @@ void VkPPRenderState::RenderScreenQuad(VkPPRenderPassSetup *passSetup, VulkanDes
|
|||
.AddClearColor(0.0f, 0.0f, 0.0f, 1.0f)
|
||||
.Execute(cmdbuffer);
|
||||
|
||||
VkBuffer vertexBuffers[] = { static_cast<VkHardwareVertexBuffer*>(screen->mVertexData->GetBufferObjects().first)->mBuffer->buffer };
|
||||
VkDeviceSize offsets[] = { 0 };
|
||||
|
||||
cmdbuffer->bindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, passSetup->Pipeline.get());
|
||||
cmdbuffer->bindDescriptorSet(VK_PIPELINE_BIND_POINT_GRAPHICS, passSetup->PipelineLayout.get(), 0, descriptorSet);
|
||||
cmdbuffer->bindVertexBuffers(0, 1, vertexBuffers, offsets);
|
||||
cmdbuffer->setViewport(0, 1, &viewport);
|
||||
cmdbuffer->setScissor(0, 1, &scissor);
|
||||
if (stencilTest)
|
||||
cmdbuffer->setStencilReference(VK_STENCIL_FRONT_AND_BACK, screen->stencilValue);
|
||||
if (pushConstantsSize > 0)
|
||||
cmdbuffer->pushConstants(passSetup->PipelineLayout.get(), VK_SHADER_STAGE_FRAGMENT_BIT, 0, pushConstantsSize, pushConstants);
|
||||
cmdbuffer->draw(3, 1, FFlatVertexBuffer::PRESENT_INDEX, 0);
|
||||
cmdbuffer->draw(3, 1, 0, 0);
|
||||
cmdbuffer->endRenderPass();
|
||||
}
|
||||
|
|
|
@ -51,10 +51,21 @@ VkRenderState::VkRenderState(VulkanRenderDevice* fb) : fb(fb), mStreamBufferWrit
|
|||
|
||||
void VkRenderState::ClearScreen()
|
||||
{
|
||||
Set2DViewpoint(SCREENWIDTH, SCREENHEIGHT);
|
||||
int width = fb->GetWidth();
|
||||
int height = fb->GetHeight();
|
||||
|
||||
auto vertices = AllocVertices(4);
|
||||
FFlatVertex* v = vertices.first;
|
||||
v[0].Set(0, 0, 0, 0, 0);
|
||||
v[1].Set(0, (float)height, 0, 0, 1);
|
||||
v[2].Set((float)width, 0, 0, 1, 0);
|
||||
v[3].Set((float)width, (float)height, 0, 1, 1);
|
||||
|
||||
Set2DViewpoint(width, height);
|
||||
SetColor(0, 0, 0);
|
||||
Apply(DT_TriangleStrip);
|
||||
mCommandBuffer->draw(4, 1, FFlatVertexBuffer::FULLSCREEN_INDEX, 0);
|
||||
|
||||
mCommandBuffer->draw(4, 1, vertices.second, 0);
|
||||
}
|
||||
|
||||
void VkRenderState::Draw(int dt, int index, int count, bool apply)
|
||||
|
|
|
@ -441,7 +441,7 @@ static void UpdatePlaneVertices(FFlatVertexBuffer *fvb, sector_t* sec, int plane
|
|||
|
||||
static void CreateVertices(FFlatVertexBuffer* fvb, TArray<sector_t>& sectors)
|
||||
{
|
||||
fvb->vbo_shadowdata.Resize(FFlatVertexBuffer::NUM_RESERVED);
|
||||
fvb->vbo_shadowdata.Clear();
|
||||
CreateIndexedFlatVertices(fvb, sectors);
|
||||
}
|
||||
|
||||
|
@ -489,7 +489,7 @@ void CheckUpdate(FFlatVertexBuffer* fvb, sector_t* sector)
|
|||
|
||||
void CreateVBO(FFlatVertexBuffer* fvb, TArray<sector_t>& sectors)
|
||||
{
|
||||
fvb->vbo_shadowdata.Resize(fvb->mNumReserved);
|
||||
fvb->vbo_shadowdata.Clear();
|
||||
CreateVertices(fvb, sectors);
|
||||
fvb->mCurIndex = fvb->mIndex = fvb->vbo_shadowdata.Size();
|
||||
fvb->Copy(0, fvb->mIndex);
|
||||
|
|
|
@ -1,10 +1,20 @@
|
|||
|
||||
layout(location = 0) in vec4 PositionInProjection;
|
||||
layout(location = 1) in vec2 UV;
|
||||
layout(location = 0) out vec2 TexCoord;
|
||||
|
||||
vec2 positions[3] = vec2[](
|
||||
vec2(-1.0, -1.0),
|
||||
vec2( 3.0, -1.0),
|
||||
vec2(-1.0, 3.0)
|
||||
);
|
||||
|
||||
vec2 uvs[3] = vec2[](
|
||||
vec2(0.0, 0.0),
|
||||
vec2(2.0, 0.0),
|
||||
vec2(0.0, 2.0)
|
||||
);
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = PositionInProjection;
|
||||
TexCoord = UV;
|
||||
gl_Position = vec4(positions[gl_VertexIndex], 0.0, 1.0);
|
||||
TexCoord = uvs[gl_VertexIndex];
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue