- implement PrecacheMaterial

This commit is contained in:
Magnus Norddahl 2019-03-17 22:41:02 +01:00
parent bf85ad4b6a
commit ec7a874a61
4 changed files with 27 additions and 0 deletions

View file

@ -604,6 +604,18 @@ void VulkanFrameBuffer::CleanForRestart()
swdrawer.reset();
}
void VulkanFrameBuffer::PrecacheMaterial(FMaterial *mat, int translation)
{
auto tex = mat->tex;
if (tex->isSWCanvas()) return;
// Textures that are already scaled in the texture lump will not get replaced by hires textures.
int flags = mat->isExpanded() ? CTF_Expand : (gl_texture_usehires && !tex->isScaled()) ? CTF_CheckHires : 0;
auto base = static_cast<VkHardwareTexture*>(mat->GetLayer(0, translation));
base->Precache(mat, translation, flags);
}
IHardwareTexture *VulkanFrameBuffer::CreateHardwareTexture()
{
return new VkHardwareTexture();

View file

@ -69,6 +69,7 @@ public:
void InitializeState() override;
void CleanForRestart() override;
void PrecacheMaterial(FMaterial *mat, int translation) override;
void UpdatePalette() override;
uint32_t GetCaps() override;
void WriteSavePic(player_t *player, FileWriter *file, int width, int height) override;

View file

@ -79,6 +79,18 @@ void VkHardwareTexture::ResetDescriptors()
mDescriptorSets.clear();
}
void VkHardwareTexture::Precache(FMaterial *mat, int translation, int flags)
{
int numLayers = mat->GetLayers();
GetImageView(mat->tex, translation, flags);
for (int i = 1; i < numLayers; i++)
{
FTexture *layer;
auto systex = static_cast<VkHardwareTexture*>(mat->GetLayer(i, 0, &layer));
systex->GetImageView(layer, 0, mat->isExpanded() ? CTF_Expand : 0);
}
}
VulkanDescriptorSet *VkHardwareTexture::GetDescriptorSet(const FMaterialState &state)
{
FMaterial *mat = state.mMaterial;

View file

@ -26,6 +26,8 @@ public:
void Reset();
void ResetDescriptors();
void Precache(FMaterial *mat, int translation, int flags);
VulkanDescriptorSet *GetDescriptorSet(const FMaterialState &state);
// Software renderer stuff