Files
ppsspp/GPU/D3D11/D3D11Util.h
T
Henrik Rydgård de0dc2d7d4 Remove the leftover geometry shader scaffolding
Nothing has generated or used a geometry shader since the GS paths were removed
- GeometryShaderGenerator is gone, and ShaderWriter's BeginGSMain/EndGSMain had
no callers at all. Removes ShaderStage::Geometry and everything hanging off it:
the GS preambles and GSMain helpers in ShaderWriter, the stage mappings in all
three thin3d backends, the D3D11 geometry shader plumbing (curGS_, the pipeline
and module members, gs_4_0 compilation), CreateGeometryShaderD3D11, the unused
PipelineFlags::USES_GEOMETRY_SHADER and PipelineManagerVulkan's
UsesGeometryShader().

Also stop enabling the Vulkan geometryShader device feature, since we no longer
have any use for it.

Kept on purpose: the device feature is still listed in the feature dumps (like
other capabilities we don't use), and the Vulkan shader cache header keeps its
now-always-zero geometry shader count so the on-disk format stays compatible.
2026-09-03 11:24:03 -06:00

85 lines
3.0 KiB
C++

// Copyright (c) 2017- PPSSPP Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0 or later versions.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official git repository and contact information can be found at
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
#pragma once
#include <cstdint>
#include <vector>
#include <d3d11.h>
#include <wrl/client.h>
class PushBufferD3D11 {
public:
PushBufferD3D11(ID3D11Device *device, size_t size, D3D11_BIND_FLAG bindFlags) : size_(size) {
D3D11_BUFFER_DESC desc{};
desc.BindFlags = bindFlags;
desc.ByteWidth = (UINT)size;
desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
desc.Usage = D3D11_USAGE_DYNAMIC;
device->CreateBuffer(&desc, nullptr, &buffer_);
}
PushBufferD3D11(PushBufferD3D11 &) = delete;
~PushBufferD3D11() {
}
ID3D11Buffer *Buf() const {
return buffer_.Get();
}
// Should be done each frame
void Reset() {
pos_ = 0;
nextMapDiscard_ = true;
}
uint8_t *BeginPush(ID3D11DeviceContext *context, UINT *offset, size_t size, int align = 16) {
D3D11_MAPPED_SUBRESOURCE map;
pos_ = (pos_ + align - 1) & ~(align - 1);
if (pos_ + size > size_) {
// Wrap! Note that with this method, since we return the same buffer as before, you have to do the draw immediately after,
// can't defer like in Vulkan. We instead let the driver handle the invalidation etc.
pos_ = 0;
nextMapDiscard_ = true;
}
context->Map(buffer_.Get(), 0, nextMapDiscard_ ? D3D11_MAP_WRITE_DISCARD : D3D11_MAP_WRITE_NO_OVERWRITE, 0, &map);
nextMapDiscard_ = false;
*offset = (UINT)pos_;
uint8_t *retval = (uint8_t *)map.pData + pos_;
pos_ += size;
return retval;
}
void EndPush(ID3D11DeviceContext *context) {
context->Unmap(buffer_.Get(), 0);
}
private:
Microsoft::WRL::ComPtr<ID3D11Buffer> buffer_;
size_t pos_ = 0;
size_t size_;
bool nextMapDiscard_ = false;
};
std::vector<uint8_t> CompileShaderToBytecodeD3D11(const char *code, size_t codeSize, const char *target, UINT flags, std::string *errorMessage = nullptr);
HRESULT CreateVertexShaderD3D11(ID3D11Device *device, const char *code, size_t codeSize, std::vector<uint8_t> *byteCodeOut, D3D_FEATURE_LEVEL featureLevel, UINT flags, ID3D11VertexShader **);
HRESULT CreatePixelShaderD3D11(ID3D11Device *device, const char *code, size_t codeSize, D3D_FEATURE_LEVEL featureLevel, UINT flags, ID3D11PixelShader **);
HRESULT CreateComputeShaderD3D11(ID3D11Device *device, const char *code, size_t codeSize, D3D_FEATURE_LEVEL featureLevel, UINT flags, ID3D11ComputeShader **);
#define ASSERT_SUCCESS(x) \
if (!SUCCEEDED((x))) \
Crash();