mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Vulkan hw tess: Don't reuse the same dynamic texture for multiple draws, not safe.
This commit is contained in:
parent
9f77d48719
commit
5d6a830288
2 changed files with 25 additions and 17 deletions
|
@ -582,8 +582,8 @@ VkDescriptorSet DrawEngineVulkan::GetOrCreateDescriptorSet(VkImageView imageView
|
|||
VkSampler sampler = ((TessellationDataTransferVulkan *)tessDataTransfer)->GetSampler();
|
||||
for (int i = 0; i < 3; i++) {
|
||||
VulkanTexture *texture = ((TessellationDataTransferVulkan *)tessDataTransfer)->GetTexture(i);
|
||||
VkImageView imageView = texture->GetImageView();
|
||||
if (i == 0 || imageView) {
|
||||
if (texture) {
|
||||
VkImageView imageView = texture->GetImageView();
|
||||
tess_tex[i].imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
|
||||
tess_tex[i].imageView = imageView;
|
||||
tess_tex[i].sampler = sampler;
|
||||
|
@ -1084,6 +1084,17 @@ void DrawEngineVulkan::UpdateUBOs(FrameData *frame) {
|
|||
}
|
||||
}
|
||||
|
||||
DrawEngineVulkan::TessellationDataTransferVulkan::TessellationDataTransferVulkan(VulkanContext *vulkan, Draw::DrawContext *draw)
|
||||
: TessellationDataTransfer(), vulkan_(vulkan), draw_(draw) {
|
||||
CreateSampler();
|
||||
}
|
||||
|
||||
DrawEngineVulkan::TessellationDataTransferVulkan::~TessellationDataTransferVulkan() {
|
||||
for (int i = 0; i < 3; i++)
|
||||
delete data_tex[i];
|
||||
vulkan_->Delete().QueueDeleteSampler(sampler);
|
||||
}
|
||||
|
||||
void DrawEngineVulkan::TessellationDataTransferVulkan::PrepareBuffers(float *&pos, float *&tex, float *&col, int size, bool hasColor, bool hasTexCoords) {
|
||||
int rowPitch;
|
||||
ILOG("INIT : Prep tess");
|
||||
|
@ -1093,6 +1104,8 @@ void DrawEngineVulkan::TessellationDataTransferVulkan::PrepareBuffers(float *&po
|
|||
if (prevSize < size) {
|
||||
prevSize = size;
|
||||
|
||||
delete data_tex[0];
|
||||
data_tex[0] = new VulkanTexture(vulkan_, nullptr); // TODO: Should really use an allocator.
|
||||
data_tex[0]->CreateDirect(cmd, size, 1, 1, VK_FORMAT_R32G32B32A32_SFLOAT, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
|
||||
}
|
||||
pos = (float *)data_tex[0]->Lock(0, &rowPitch);
|
||||
|
@ -1102,6 +1115,8 @@ void DrawEngineVulkan::TessellationDataTransferVulkan::PrepareBuffers(float *&po
|
|||
if (prevSizeTex < size) {
|
||||
prevSizeTex = size;
|
||||
|
||||
delete data_tex[1];
|
||||
data_tex[1] = new VulkanTexture(vulkan_, nullptr); // TODO: Should really use an allocator.
|
||||
data_tex[1]->CreateDirect(cmd, size, 1, 1, VK_FORMAT_R32G32B32A32_SFLOAT, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
|
||||
}
|
||||
tex = (float *)data_tex[1]->Lock(0, &rowPitch);
|
||||
|
@ -1112,6 +1127,8 @@ void DrawEngineVulkan::TessellationDataTransferVulkan::PrepareBuffers(float *&po
|
|||
if (prevSizeCol < sizeColor) {
|
||||
prevSizeCol = sizeColor;
|
||||
|
||||
delete data_tex[2];
|
||||
data_tex[2] = new VulkanTexture(vulkan_, nullptr); // TODO: Should really use an allocator.
|
||||
data_tex[2]->CreateDirect(cmd, sizeColor, 1, 1, VK_FORMAT_R32G32B32A32_SFLOAT, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
|
||||
}
|
||||
col = (float *)data_tex[2]->Lock(0, &rowPitch);
|
||||
|
|
|
@ -264,25 +264,16 @@ private:
|
|||
private:
|
||||
VulkanContext *vulkan_;
|
||||
Draw::DrawContext *draw_;
|
||||
VulkanTexture *data_tex[3];
|
||||
VkSampler sampler;
|
||||
VulkanTexture *data_tex[3]{};
|
||||
VkSampler sampler = VK_NULL_HANDLE;
|
||||
public:
|
||||
TessellationDataTransferVulkan(VulkanContext *vulkan, Draw::DrawContext *draw)
|
||||
: TessellationDataTransfer(), vulkan_(vulkan), draw_(draw), data_tex(), sampler() {
|
||||
for (int i = 0; i < 3; i++)
|
||||
data_tex[i] = new VulkanTexture(vulkan_);
|
||||
|
||||
CreateSampler();
|
||||
}
|
||||
~TessellationDataTransferVulkan() {
|
||||
for (int i = 0; i < 3; i++)
|
||||
delete data_tex[i];
|
||||
|
||||
vulkan_->Delete().QueueDeleteSampler(sampler);
|
||||
}
|
||||
TessellationDataTransferVulkan(VulkanContext *vulkan, Draw::DrawContext *draw);
|
||||
~TessellationDataTransferVulkan();
|
||||
void SendDataToShader(const float *pos, const float *tex, const float *col, int size, bool hasColor, bool hasTexCoords) override;
|
||||
void PrepareBuffers(float *&pos, float *&tex, float *&col, int size, bool hasColor, bool hasTexCoords) override;
|
||||
|
||||
VulkanTexture *GetTexture(int i) const { return data_tex[i]; }
|
||||
|
||||
VkSampler GetSampler() const { return sampler; }
|
||||
void CreateSampler() {
|
||||
VkSamplerCreateInfo samp = { VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO };
|
||||
|
|
Loading…
Add table
Reference in a new issue