Adds renderer backend vertex formats and normalizes texture formats.
This was SVN commit r26588.
This commit is contained in:
parent
15ed402a12
commit
3399791677
@ -140,7 +140,7 @@ bool CFontManager::ReadFont(CFont* font, CStrIntern fontName)
|
||||
// Load glyph texture
|
||||
const VfsPath imageName(fontName.string() + ".png");
|
||||
CTextureProperties textureProps(path / imageName,
|
||||
font->m_HasRGB ? Renderer::Backend::Format::R8G8B8A8 : Renderer::Backend::Format::A8);
|
||||
font->m_HasRGB ? Renderer::Backend::Format::R8G8B8A8_UNORM : Renderer::Backend::Format::A8_UNORM);
|
||||
textureProps.SetIgnoreQuality(true);
|
||||
font->m_Texture = g_Renderer.GetTextureManager().CreateTexture(textureProps);
|
||||
|
||||
|
@ -233,7 +233,7 @@ void CLOSTexture::ConstructTexture(Renderer::Backend::GL::CDeviceCommandContext*
|
||||
Renderer::Backend::Sampler::AddressMode::CLAMP_TO_EDGE);
|
||||
|
||||
m_Texture = backendDevice->CreateTexture2D("LOSTexture",
|
||||
Renderer::Backend::Format::A8, textureSize, textureSize, defaultSamplerDesc);
|
||||
Renderer::Backend::Format::A8_UNORM, textureSize, textureSize, defaultSamplerDesc);
|
||||
|
||||
// Initialise texture with SoD color, for the areas we don't
|
||||
// overwrite with uploading later.
|
||||
@ -243,9 +243,9 @@ void CLOSTexture::ConstructTexture(Renderer::Backend::GL::CDeviceCommandContext*
|
||||
if (CRenderer::IsInitialised() && g_RenderingOptions.GetSmoothLOS())
|
||||
{
|
||||
m_SmoothTextures[0] = backendDevice->CreateTexture2D("LOSSmoothTexture0",
|
||||
Renderer::Backend::Format::A8, textureSize, textureSize, defaultSamplerDesc);
|
||||
Renderer::Backend::Format::A8_UNORM, textureSize, textureSize, defaultSamplerDesc);
|
||||
m_SmoothTextures[1] = backendDevice->CreateTexture2D("LOSSmoothTexture1",
|
||||
Renderer::Backend::Format::A8, textureSize, textureSize, defaultSamplerDesc);
|
||||
Renderer::Backend::Format::A8_UNORM, textureSize, textureSize, defaultSamplerDesc);
|
||||
|
||||
m_SmoothFramebuffers[0] = backendDevice->CreateFramebuffer("LOSSmoothFramebuffer0",
|
||||
m_SmoothTextures[0].get(), nullptr);
|
||||
@ -258,15 +258,15 @@ void CLOSTexture::ConstructTexture(Renderer::Backend::GL::CDeviceCommandContext*
|
||||
}
|
||||
|
||||
deviceCommandContext->UploadTexture(
|
||||
m_SmoothTextures[0].get(), Renderer::Backend::Format::A8,
|
||||
m_SmoothTextures[0].get(), Renderer::Backend::Format::A8_UNORM,
|
||||
texData.get(), textureSize * textureSize);
|
||||
deviceCommandContext->UploadTexture(
|
||||
m_SmoothTextures[1].get(), Renderer::Backend::Format::A8,
|
||||
m_SmoothTextures[1].get(), Renderer::Backend::Format::A8_UNORM,
|
||||
texData.get(), textureSize * textureSize);
|
||||
}
|
||||
|
||||
deviceCommandContext->UploadTexture(
|
||||
m_Texture.get(), Renderer::Backend::Format::A8,
|
||||
m_Texture.get(), Renderer::Backend::Format::A8_UNORM,
|
||||
texData.get(), textureSize * textureSize);
|
||||
|
||||
texData.reset();
|
||||
@ -334,15 +334,15 @@ void CLOSTexture::RecomputeTexture(Renderer::Backend::GL::CDeviceCommandContext*
|
||||
if (CRenderer::IsInitialised() && g_RenderingOptions.GetSmoothLOS() && recreated)
|
||||
{
|
||||
deviceCommandContext->UploadTextureRegion(
|
||||
m_SmoothTextures[0].get(), Renderer::Backend::Format::A8, losData.get(),
|
||||
m_SmoothTextures[0].get(), Renderer::Backend::Format::A8_UNORM, losData.get(),
|
||||
pitch * m_MapSize, 0, 0, pitch, m_MapSize);
|
||||
deviceCommandContext->UploadTextureRegion(
|
||||
m_SmoothTextures[1].get(), Renderer::Backend::Format::A8, losData.get(),
|
||||
m_SmoothTextures[1].get(), Renderer::Backend::Format::A8_UNORM, losData.get(),
|
||||
pitch * m_MapSize, 0, 0, pitch, m_MapSize);
|
||||
}
|
||||
|
||||
deviceCommandContext->UploadTextureRegion(
|
||||
m_Texture.get(), Renderer::Backend::Format::A8, losData.get(),
|
||||
m_Texture.get(), Renderer::Backend::Format::A8_UNORM, losData.get(),
|
||||
pitch * m_MapSize, 0, 0, pitch, m_MapSize);
|
||||
}
|
||||
|
||||
|
@ -237,7 +237,7 @@ void CMiniMapTexture::CreateTextures(
|
||||
|
||||
// Create terrain texture
|
||||
m_TerrainTexture = backendDevice->CreateTexture2D("MiniMapTerrainTexture",
|
||||
Renderer::Backend::Format::R8G8B8A8, textureSize, textureSize, defaultSamplerDesc);
|
||||
Renderer::Backend::Format::R8G8B8A8_UNORM, textureSize, textureSize, defaultSamplerDesc);
|
||||
|
||||
// Initialise texture with solid black, for the areas we don't
|
||||
// overwrite with uploading later.
|
||||
@ -245,14 +245,14 @@ void CMiniMapTexture::CreateTextures(
|
||||
for (size_t i = 0; i < textureSize * textureSize; ++i)
|
||||
texData[i] = 0xFF000000;
|
||||
deviceCommandContext->UploadTexture(
|
||||
m_TerrainTexture.get(), Renderer::Backend::Format::R8G8B8A8,
|
||||
m_TerrainTexture.get(), Renderer::Backend::Format::R8G8B8A8_UNORM,
|
||||
texData.get(), textureSize * textureSize * 4);
|
||||
texData.reset();
|
||||
|
||||
m_TerrainData = std::make_unique<u32[]>((m_MapSize - 1) * (m_MapSize - 1));
|
||||
|
||||
m_FinalTexture = backendDevice->CreateTexture2D("MiniMapFinalTexture",
|
||||
Renderer::Backend::Format::R8G8B8A8, FINAL_TEXTURE_SIZE, FINAL_TEXTURE_SIZE, defaultSamplerDesc);
|
||||
Renderer::Backend::Format::R8G8B8A8_UNORM, FINAL_TEXTURE_SIZE, FINAL_TEXTURE_SIZE, defaultSamplerDesc);
|
||||
|
||||
m_FinalTextureFramebuffer = backendDevice->CreateFramebuffer("MiniMapFinalFramebuffer",
|
||||
m_FinalTexture.get(), nullptr);
|
||||
@ -328,7 +328,7 @@ void CMiniMapTexture::RebuildTerrainTexture(
|
||||
|
||||
// Upload the texture
|
||||
deviceCommandContext->UploadTextureRegion(
|
||||
m_TerrainTexture.get(), Renderer::Backend::Format::R8G8B8A8,
|
||||
m_TerrainTexture.get(), Renderer::Backend::Format::R8G8B8A8_UNORM,
|
||||
m_TerrainData.get(), width * height * 4, 0, 0, width, height);
|
||||
}
|
||||
|
||||
|
@ -294,7 +294,7 @@ CTerrainTextureManager::LoadAlphaMap(const VfsPath& alphaMapType)
|
||||
#endif
|
||||
|
||||
result.m_CompositeAlphaMap = g_VideoMode.GetBackendDevice()->CreateTexture2D("CompositeAlphaMap",
|
||||
Renderer::Backend::Format::A8, totalWidth, totalHeight,
|
||||
Renderer::Backend::Format::A8_UNORM, totalWidth, totalHeight,
|
||||
Renderer::Backend::Sampler::MakeDefaultSampler(
|
||||
Renderer::Backend::Sampler::Filter::LINEAR,
|
||||
Renderer::Backend::Sampler::AddressMode::CLAMP_TO_EDGE));
|
||||
@ -317,7 +317,7 @@ void CTerrainTextureManager::UploadResourcesIfNeeded(
|
||||
// Upload the composite texture.
|
||||
Renderer::Backend::GL::CTexture* texture = alphaMap.m_CompositeAlphaMap.get();
|
||||
deviceCommandContext->UploadTexture(
|
||||
texture, Renderer::Backend::Format::A8, alphaMap.m_CompositeDataToUpload.get(),
|
||||
texture, Renderer::Backend::Format::A8_UNORM, alphaMap.m_CompositeDataToUpload.get(),
|
||||
texture->GetWidth() * texture->GetHeight());
|
||||
alphaMap.m_CompositeDataToUpload.reset();
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ void CTerritoryTexture::ConstructTexture(Renderer::Backend::GL::CDeviceCommandCo
|
||||
const uint32_t textureSize = round_up_to_pow2(static_cast<uint32_t>(m_MapSize));
|
||||
|
||||
m_Texture = deviceCommandContext->GetDevice()->CreateTexture2D("TerritoryTexture",
|
||||
Renderer::Backend::Format::R8G8B8A8, textureSize, textureSize,
|
||||
Renderer::Backend::Format::R8G8B8A8_UNORM, textureSize, textureSize,
|
||||
Renderer::Backend::Sampler::MakeDefaultSampler(
|
||||
Renderer::Backend::Sampler::Filter::LINEAR,
|
||||
Renderer::Backend::Sampler::AddressMode::CLAMP_TO_EDGE));
|
||||
@ -97,7 +97,7 @@ void CTerritoryTexture::ConstructTexture(Renderer::Backend::GL::CDeviceCommandCo
|
||||
std::unique_ptr<u8[]> texData = std::make_unique<u8[]>(textureSize * textureSize * 4);
|
||||
memset(texData.get(), 0x00, textureSize * textureSize * 4);
|
||||
deviceCommandContext->UploadTexture(
|
||||
m_Texture.get(), Renderer::Backend::Format::R8G8B8A8,
|
||||
m_Texture.get(), Renderer::Backend::Format::R8G8B8A8_UNORM,
|
||||
texData.get(), textureSize * textureSize * 4);
|
||||
texData.reset();
|
||||
|
||||
@ -152,7 +152,7 @@ void CTerritoryTexture::RecomputeTexture(Renderer::Backend::GL::CDeviceCommandCo
|
||||
GenerateBitmap(cmpTerritoryManager->GetTerritoryGrid(), bitmap.get(), m_MapSize, m_MapSize);
|
||||
|
||||
deviceCommandContext->UploadTextureRegion(
|
||||
m_Texture.get(), Renderer::Backend::Format::R8G8B8A8, bitmap.get(), m_MapSize * m_MapSize * 4,
|
||||
m_Texture.get(), Renderer::Backend::Format::R8G8B8A8_UNORM, bitmap.get(), m_MapSize * m_MapSize * 4,
|
||||
0, 0, m_MapSize, m_MapSize);
|
||||
}
|
||||
|
||||
|
@ -68,13 +68,13 @@ Renderer::Backend::Format ChooseFormatAndTransformTextureDataIfNeeded(Tex& textu
|
||||
switch (dxt)
|
||||
{
|
||||
case DXT1A:
|
||||
return Renderer::Backend::Format::BC1_RGBA;
|
||||
return Renderer::Backend::Format::BC1_RGBA_UNORM;
|
||||
case 1:
|
||||
return Renderer::Backend::Format::BC1_RGB;
|
||||
return Renderer::Backend::Format::BC1_RGB_UNORM;
|
||||
case 3:
|
||||
return Renderer::Backend::Format::BC2;
|
||||
return Renderer::Backend::Format::BC2_UNORM;
|
||||
case 5:
|
||||
return Renderer::Backend::Format::BC3;
|
||||
return Renderer::Backend::Format::BC3_UNORM;
|
||||
default:
|
||||
LOGERROR("Unknown DXT compression.");
|
||||
return Renderer::Backend::Format::UNDEFINED;
|
||||
@ -88,13 +88,13 @@ Renderer::Backend::Format ChooseFormatAndTransformTextureDataIfNeeded(Tex& textu
|
||||
{
|
||||
case 8:
|
||||
ENSURE(grey);
|
||||
return Renderer::Backend::Format::L8;
|
||||
return Renderer::Backend::Format::L8_UNORM;
|
||||
case 24:
|
||||
ENSURE(!alpha);
|
||||
return Renderer::Backend::Format::R8G8B8;
|
||||
return Renderer::Backend::Format::R8G8B8_UNORM;
|
||||
case 32:
|
||||
ENSURE(alpha);
|
||||
return Renderer::Backend::Format::R8G8B8A8;
|
||||
return Renderer::Backend::Format::R8G8B8A8_UNORM;
|
||||
default:
|
||||
LOGERROR("Unsupported BPP: %zu", textureData.m_Bpp);
|
||||
}
|
||||
@ -148,7 +148,7 @@ public:
|
||||
std::unique_ptr<Renderer::Backend::GL::CTexture> backendTexture =
|
||||
g_VideoMode.GetBackendDevice()->CreateTexture2D(
|
||||
textureName.str().c_str(),
|
||||
Renderer::Backend::Format::R8G8B8A8,
|
||||
Renderer::Backend::Format::R8G8B8A8_UNORM,
|
||||
1, 1, Renderer::Backend::Sampler::MakeDefaultSampler(
|
||||
Renderer::Backend::Sampler::Filter::LINEAR,
|
||||
Renderer::Backend::Sampler::AddressMode::REPEAT));
|
||||
@ -170,7 +170,7 @@ public:
|
||||
color32.A
|
||||
};
|
||||
deviceCommandContext->UploadTexture(GetTexture()->GetBackendTexture(),
|
||||
Renderer::Backend::Format::R8G8B8A8, data, std::size(data));
|
||||
Renderer::Backend::Format::R8G8B8A8_UNORM, data, std::size(data));
|
||||
}
|
||||
|
||||
private:
|
||||
@ -206,7 +206,7 @@ public:
|
||||
std::unique_ptr<Renderer::Backend::GL::CTexture> backendTexture =
|
||||
g_VideoMode.GetBackendDevice()->CreateTexture2D(
|
||||
textureName.str().c_str(),
|
||||
Renderer::Backend::Format::R8G8B8A8,
|
||||
Renderer::Backend::Format::R8G8B8A8_UNORM,
|
||||
WIDTH, 1, Renderer::Backend::Sampler::MakeDefaultSampler(
|
||||
Renderer::Backend::Sampler::Filter::LINEAR,
|
||||
Renderer::Backend::Sampler::AddressMode::CLAMP_TO_EDGE),
|
||||
@ -237,7 +237,7 @@ public:
|
||||
for (uint32_t level = 0; level < NUMBER_OF_LEVELS; ++level)
|
||||
{
|
||||
deviceCommandContext->UploadTexture(GetTexture()->GetBackendTexture(),
|
||||
Renderer::Backend::Format::R8G8B8A8, data.data(), (WIDTH >> level) * data[0].size(), level);
|
||||
Renderer::Backend::Format::R8G8B8A8_UNORM, data.data(), (WIDTH >> level) * data[0].size(), level);
|
||||
// Prepare data for the next level.
|
||||
const uint32_t nextLevelWidth = (WIDTH >> (level + 1));
|
||||
if (nextLevelWidth > 0)
|
||||
@ -318,10 +318,10 @@ public:
|
||||
|
||||
Renderer::Backend::GL::CDevice* backendDevice = g_VideoMode.GetBackendDevice();
|
||||
m_HasS3TC =
|
||||
backendDevice->IsFormatSupported(Renderer::Backend::Format::BC1_RGB) &&
|
||||
backendDevice->IsFormatSupported(Renderer::Backend::Format::BC1_RGBA) &&
|
||||
backendDevice->IsFormatSupported(Renderer::Backend::Format::BC2) &&
|
||||
backendDevice->IsFormatSupported(Renderer::Backend::Format::BC3);
|
||||
backendDevice->IsTextureFormatSupported(Renderer::Backend::Format::BC1_RGB_UNORM) &&
|
||||
backendDevice->IsTextureFormatSupported(Renderer::Backend::Format::BC1_RGBA_UNORM) &&
|
||||
backendDevice->IsTextureFormatSupported(Renderer::Backend::Format::BC2_UNORM) &&
|
||||
backendDevice->IsTextureFormatSupported(Renderer::Backend::Format::BC3_UNORM);
|
||||
}
|
||||
|
||||
~CTextureManagerImpl()
|
||||
@ -421,11 +421,11 @@ public:
|
||||
// TODO: it'd be good to remove the override hack and provide information
|
||||
// via XML.
|
||||
ENSURE((textureData.m_Flags & TEX_DXT) == 0);
|
||||
if (format == Renderer::Backend::Format::A8)
|
||||
if (format == Renderer::Backend::Format::A8_UNORM)
|
||||
{
|
||||
ENSURE(textureData.m_Bpp == 8 && (textureData.m_Flags & TEX_GREY));
|
||||
}
|
||||
else if (format == Renderer::Backend::Format::R8G8B8A8)
|
||||
else if (format == Renderer::Backend::Format::R8G8B8A8_UNORM)
|
||||
{
|
||||
ENSURE(textureData.m_Bpp == 32 && (textureData.m_Flags & TEX_ALPHA));
|
||||
}
|
||||
@ -935,11 +935,11 @@ bool CTexture::HasAlpha() const
|
||||
{
|
||||
const Renderer::Backend::Format format = GetBackendTexture()->GetFormat();
|
||||
return
|
||||
format == Renderer::Backend::Format::A8 ||
|
||||
format == Renderer::Backend::Format::R8G8B8A8 ||
|
||||
format == Renderer::Backend::Format::BC1_RGBA ||
|
||||
format == Renderer::Backend::Format::BC2 ||
|
||||
format == Renderer::Backend::Format::BC3;
|
||||
format == Renderer::Backend::Format::A8_UNORM ||
|
||||
format == Renderer::Backend::Format::R8G8B8A8_UNORM ||
|
||||
format == Renderer::Backend::Format::BC1_RGBA_UNORM ||
|
||||
format == Renderer::Backend::Format::BC2_UNORM ||
|
||||
format == Renderer::Backend::Format::BC3_UNORM;
|
||||
}
|
||||
|
||||
u32 CTexture::GetBaseColor() const
|
||||
|
@ -126,7 +126,7 @@ void CPostprocManager::RecreateBuffers()
|
||||
|
||||
#define GEN_BUFFER_RGBA(name, w, h) \
|
||||
name = backendDevice->CreateTexture2D( \
|
||||
"PostProc" #name, Renderer::Backend::Format::R8G8B8A8, w, h, \
|
||||
"PostProc" #name, Renderer::Backend::Format::R8G8B8A8_UNORM, w, h, \
|
||||
Renderer::Backend::Sampler::MakeDefaultSampler( \
|
||||
Renderer::Backend::Sampler::Filter::LINEAR, \
|
||||
Renderer::Backend::Sampler::AddressMode::CLAMP_TO_EDGE));
|
||||
@ -598,7 +598,7 @@ void CPostprocManager::CreateMultisampleBuffer()
|
||||
|
||||
m_MultisampleColorTex = backendDevice->CreateTexture("PostProcColorMS",
|
||||
Renderer::Backend::GL::CTexture::Type::TEXTURE_2D_MULTISAMPLE,
|
||||
Renderer::Backend::Format::R8G8B8A8, m_Width, m_Height,
|
||||
Renderer::Backend::Format::R8G8B8A8_UNORM, m_Width, m_Height,
|
||||
Renderer::Backend::Sampler::MakeDefaultSampler(
|
||||
Renderer::Backend::Sampler::Filter::LINEAR,
|
||||
Renderer::Backend::Sampler::AddressMode::CLAMP_TO_EDGE), 1, m_MultisampleCount);
|
||||
|
@ -531,7 +531,7 @@ void ShadowMapInternals::CreateTexture()
|
||||
if (g_RenderingOptions.GetShadowAlphaFix())
|
||||
{
|
||||
DummyTexture = backendDevice->CreateTexture2D("ShadowMapDummy",
|
||||
Renderer::Backend::Format::R8G8B8A8, Width, Height,
|
||||
Renderer::Backend::Format::R8G8B8A8_UNORM, Width, Height,
|
||||
Renderer::Backend::Sampler::MakeDefaultSampler(
|
||||
Renderer::Backend::Sampler::Filter::NEAREST,
|
||||
Renderer::Backend::Sampler::AddressMode::CLAMP_TO_EDGE));
|
||||
|
@ -116,7 +116,7 @@ void SkyManager::LoadAndUploadSkyTexturesIfNeeded(
|
||||
|
||||
m_SkyCubeMap = g_VideoMode.GetBackendDevice()->CreateTexture("SkyCubeMap",
|
||||
Renderer::Backend::GL::CTexture::Type::TEXTURE_CUBE,
|
||||
Renderer::Backend::Format::R8G8B8A8, textures[0].m_Width, textures[0].m_Height,
|
||||
Renderer::Backend::Format::R8G8B8A8_UNORM, textures[0].m_Width, textures[0].m_Height,
|
||||
Renderer::Backend::Sampler::MakeDefaultSampler(
|
||||
Renderer::Backend::Sampler::Filter::LINEAR,
|
||||
Renderer::Backend::Sampler::AddressMode::CLAMP_TO_EDGE), 1, 1);
|
||||
@ -147,13 +147,13 @@ void SkyManager::LoadAndUploadSkyTexturesIfNeeded(
|
||||
}
|
||||
|
||||
deviceCommandContext->UploadTexture(
|
||||
m_SkyCubeMap.get(), Renderer::Backend::Format::R8G8B8A8,
|
||||
m_SkyCubeMap.get(), Renderer::Backend::Format::R8G8B8A8_UNORM,
|
||||
&rotated[0], textures[i].m_DataSize, 0, i);
|
||||
}
|
||||
else
|
||||
{
|
||||
deviceCommandContext->UploadTexture(
|
||||
m_SkyCubeMap.get(), Renderer::Backend::Format::R8G8B8A8,
|
||||
m_SkyCubeMap.get(), Renderer::Backend::Format::R8G8B8A8_UNORM,
|
||||
data, textures[i].m_DataSize, 0, i);
|
||||
}
|
||||
}
|
||||
|
@ -330,7 +330,7 @@ void TerrainTextureOverlay::RenderAfterWater(
|
||||
if (!m_Texture || m_Texture->GetWidth() != requiredWidth || m_Texture->GetHeight() != requiredHeight)
|
||||
{
|
||||
m_Texture = deviceCommandContext->GetDevice()->CreateTexture2D("TerrainOverlayTexture",
|
||||
Renderer::Backend::Format::R8G8B8A8, requiredWidth, requiredHeight,
|
||||
Renderer::Backend::Format::R8G8B8A8_UNORM, requiredWidth, requiredHeight,
|
||||
Renderer::Backend::Sampler::MakeDefaultSampler(
|
||||
Renderer::Backend::Sampler::Filter::NEAREST,
|
||||
Renderer::Backend::Sampler::AddressMode::CLAMP_TO_EDGE));
|
||||
@ -340,7 +340,7 @@ void TerrainTextureOverlay::RenderAfterWater(
|
||||
BuildTextureRGBA(data, w, h);
|
||||
|
||||
deviceCommandContext->UploadTextureRegion(
|
||||
m_Texture.get(), Renderer::Backend::Format::R8G8B8A8, data, w * h * 4, 0, 0, w, h);
|
||||
m_Texture.get(), Renderer::Backend::Format::R8G8B8A8_UNORM, data, w * h * 4, 0, 0, w, h);
|
||||
|
||||
free(data);
|
||||
|
||||
|
@ -191,14 +191,14 @@ int WaterManager::LoadWaterTextures()
|
||||
|
||||
// Create reflection texture
|
||||
m_ReflectionTexture = backendDevice->CreateTexture2D("WaterReflectionTexture",
|
||||
Renderer::Backend::Format::R8G8B8A8, m_RefTextureSize, m_RefTextureSize,
|
||||
Renderer::Backend::Format::R8G8B8A8_UNORM, m_RefTextureSize, m_RefTextureSize,
|
||||
Renderer::Backend::Sampler::MakeDefaultSampler(
|
||||
Renderer::Backend::Sampler::Filter::LINEAR,
|
||||
Renderer::Backend::Sampler::AddressMode::MIRRORED_REPEAT));
|
||||
|
||||
// Create refraction texture
|
||||
m_RefractionTexture = backendDevice->CreateTexture2D("WaterRefractionTexture",
|
||||
Renderer::Backend::Format::R8G8B8A8, m_RefTextureSize, m_RefTextureSize,
|
||||
Renderer::Backend::Format::R8G8B8A8_UNORM, m_RefTextureSize, m_RefTextureSize,
|
||||
Renderer::Backend::Sampler::MakeDefaultSampler(
|
||||
Renderer::Backend::Sampler::Filter::LINEAR,
|
||||
Renderer::Backend::Sampler::AddressMode::MIRRORED_REPEAT));
|
||||
@ -256,7 +256,7 @@ void WaterManager::Resize()
|
||||
|
||||
// Create the Fancy Effects texture
|
||||
m_FancyTexture = backendDevice->CreateTexture2D("WaterFancyTexture",
|
||||
Renderer::Backend::Format::R8G8B8A8, g_Renderer.GetWidth(), g_Renderer.GetHeight(),
|
||||
Renderer::Backend::Format::R8G8B8A8_UNORM, g_Renderer.GetWidth(), g_Renderer.GetHeight(),
|
||||
Renderer::Backend::Sampler::MakeDefaultSampler(
|
||||
Renderer::Backend::Sampler::Filter::LINEAR,
|
||||
Renderer::Backend::Sampler::AddressMode::REPEAT));
|
||||
|
@ -27,21 +27,26 @@ namespace Backend
|
||||
enum class Format
|
||||
{
|
||||
UNDEFINED,
|
||||
R8G8B8,
|
||||
R8G8B8A8,
|
||||
R8G8B8_UNORM,
|
||||
R8G8B8A8_UNORM,
|
||||
|
||||
A8,
|
||||
L8,
|
||||
A8_UNORM,
|
||||
L8_UNORM,
|
||||
|
||||
R32_SFLOAT,
|
||||
R32G32_SFLOAT,
|
||||
R32G32B32_SFLOAT,
|
||||
R32G32B32A32_SFLOAT,
|
||||
|
||||
D16,
|
||||
D24,
|
||||
D24_S8,
|
||||
D32,
|
||||
|
||||
BC1_RGB,
|
||||
BC1_RGBA,
|
||||
BC2,
|
||||
BC3
|
||||
BC1_RGB_UNORM,
|
||||
BC1_RGBA_UNORM,
|
||||
BC2_UNORM,
|
||||
BC3_UNORM
|
||||
};
|
||||
|
||||
} // namespace Backend
|
||||
|
@ -834,7 +834,7 @@ void CDevice::Present()
|
||||
ONCE(LOGERROR("GL error %s (0x%04x) occurred", ogl_GetErrorName(err), err));
|
||||
}
|
||||
|
||||
bool CDevice::IsFormatSupported(const Format format) const
|
||||
bool CDevice::IsTextureFormatSupported(const Format format) const
|
||||
{
|
||||
bool supported = false;
|
||||
switch (format)
|
||||
@ -842,13 +842,19 @@ bool CDevice::IsFormatSupported(const Format format) const
|
||||
case Format::UNDEFINED:
|
||||
break;
|
||||
|
||||
case Format::R8G8B8: FALLTHROUGH;
|
||||
case Format::R8G8B8A8: FALLTHROUGH;
|
||||
case Format::A8: FALLTHROUGH;
|
||||
case Format::L8:
|
||||
case Format::R8G8B8_UNORM: FALLTHROUGH;
|
||||
case Format::R8G8B8A8_UNORM: FALLTHROUGH;
|
||||
case Format::A8_UNORM: FALLTHROUGH;
|
||||
case Format::L8_UNORM:
|
||||
supported = true;
|
||||
break;
|
||||
|
||||
case Format::R32_SFLOAT: FALLTHROUGH;
|
||||
case Format::R32G32_SFLOAT: FALLTHROUGH;
|
||||
case Format::R32G32B32_SFLOAT: FALLTHROUGH;
|
||||
case Format::R32G32B32A32_SFLOAT:
|
||||
break;
|
||||
|
||||
case Format::D16: FALLTHROUGH;
|
||||
case Format::D24: FALLTHROUGH;
|
||||
case Format::D32:
|
||||
@ -860,10 +866,10 @@ bool CDevice::IsFormatSupported(const Format format) const
|
||||
#endif
|
||||
break;
|
||||
|
||||
case Format::BC1_RGB: FALLTHROUGH;
|
||||
case Format::BC1_RGBA: FALLTHROUGH;
|
||||
case Format::BC2: FALLTHROUGH;
|
||||
case Format::BC3:
|
||||
case Format::BC1_RGB_UNORM: FALLTHROUGH;
|
||||
case Format::BC1_RGBA_UNORM: FALLTHROUGH;
|
||||
case Format::BC2_UNORM: FALLTHROUGH;
|
||||
case Format::BC3_UNORM:
|
||||
supported = m_Capabilities.S3TC;
|
||||
break;
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ public:
|
||||
|
||||
void Present();
|
||||
|
||||
bool IsFormatSupported(const Format format) const;
|
||||
bool IsTextureFormatSupported(const Format format) const;
|
||||
|
||||
const Capabilities& GetCapabilities() const { return m_Capabilities; }
|
||||
|
||||
|
@ -183,26 +183,26 @@ void CDeviceCommandContext::UploadTextureRegion(
|
||||
if (texture->GetType() == CTexture::Type::TEXTURE_2D)
|
||||
{
|
||||
ENSURE(layer == 0);
|
||||
if (texture->GetFormat() == Format::R8G8B8A8 ||
|
||||
texture->GetFormat() == Format::R8G8B8 ||
|
||||
texture->GetFormat() == Format::A8)
|
||||
if (texture->GetFormat() == Format::R8G8B8A8_UNORM ||
|
||||
texture->GetFormat() == Format::R8G8B8_UNORM ||
|
||||
texture->GetFormat() == Format::A8_UNORM)
|
||||
{
|
||||
ENSURE(texture->GetFormat() == dataFormat);
|
||||
size_t bytesPerPixel = 4;
|
||||
GLenum pixelFormat = GL_RGBA;
|
||||
switch (dataFormat)
|
||||
{
|
||||
case Format::R8G8B8A8:
|
||||
case Format::R8G8B8A8_UNORM:
|
||||
break;
|
||||
case Format::R8G8B8:
|
||||
case Format::R8G8B8_UNORM:
|
||||
pixelFormat = GL_RGB;
|
||||
bytesPerPixel = 3;
|
||||
break;
|
||||
case Format::A8:
|
||||
case Format::A8_UNORM:
|
||||
pixelFormat = GL_ALPHA;
|
||||
bytesPerPixel = 1;
|
||||
break;
|
||||
case Format::L8:
|
||||
case Format::L8_UNORM:
|
||||
pixelFormat = GL_LUMINANCE;
|
||||
bytesPerPixel = 1;
|
||||
break;
|
||||
@ -219,10 +219,10 @@ void CDeviceCommandContext::UploadTextureRegion(
|
||||
ogl_WarnIfError();
|
||||
}
|
||||
else if (
|
||||
texture->GetFormat() == Format::BC1_RGB ||
|
||||
texture->GetFormat() == Format::BC1_RGBA ||
|
||||
texture->GetFormat() == Format::BC2 ||
|
||||
texture->GetFormat() == Format::BC3)
|
||||
texture->GetFormat() == Format::BC1_RGB_UNORM ||
|
||||
texture->GetFormat() == Format::BC1_RGBA_UNORM ||
|
||||
texture->GetFormat() == Format::BC2_UNORM ||
|
||||
texture->GetFormat() == Format::BC3_UNORM)
|
||||
{
|
||||
ENSURE(xOffset == 0 && yOffset == 0);
|
||||
ENSURE(texture->GetFormat() == dataFormat);
|
||||
@ -231,13 +231,13 @@ void CDeviceCommandContext::UploadTextureRegion(
|
||||
GLenum internalFormat = GL_COMPRESSED_RGB_S3TC_DXT1_EXT;
|
||||
switch (texture->GetFormat())
|
||||
{
|
||||
case Format::BC1_RGBA:
|
||||
case Format::BC1_RGBA_UNORM:
|
||||
internalFormat = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
|
||||
break;
|
||||
case Format::BC2:
|
||||
case Format::BC2_UNORM:
|
||||
internalFormat = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT;
|
||||
break;
|
||||
case Format::BC3:
|
||||
case Format::BC3_UNORM:
|
||||
internalFormat = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
|
||||
break;
|
||||
default:
|
||||
@ -253,7 +253,7 @@ void CDeviceCommandContext::UploadTextureRegion(
|
||||
}
|
||||
else if (texture->GetType() == CTexture::Type::TEXTURE_CUBE)
|
||||
{
|
||||
if (texture->GetFormat() == Format::R8G8B8A8)
|
||||
if (texture->GetFormat() == Format::R8G8B8A8_UNORM)
|
||||
{
|
||||
ENSURE(texture->GetFormat() == dataFormat);
|
||||
ENSURE(level == 0 && layer < 6);
|
||||
|
@ -170,19 +170,19 @@ std::unique_ptr<CTexture> CTexture::Create(CDevice* device, const char* name,
|
||||
case Format::UNDEFINED:
|
||||
debug_warn("Texture should defined format");
|
||||
break;
|
||||
case Format::R8G8B8A8:
|
||||
case Format::R8G8B8A8_UNORM:
|
||||
break;
|
||||
case Format::R8G8B8:
|
||||
case Format::R8G8B8_UNORM:
|
||||
internalFormat = GL_RGB;
|
||||
pixelFormat = GL_RGB;
|
||||
pixelType = GL_UNSIGNED_BYTE;
|
||||
break;
|
||||
case Format::A8:
|
||||
case Format::A8_UNORM:
|
||||
internalFormat = GL_ALPHA;
|
||||
pixelFormat = GL_ALPHA;
|
||||
pixelType = GL_UNSIGNED_BYTE;
|
||||
break;
|
||||
case Format::L8:
|
||||
case Format::L8_UNORM:
|
||||
internalFormat = GL_LUMINANCE;
|
||||
pixelFormat = GL_LUMINANCE;
|
||||
pixelType = GL_UNSIGNED_BYTE;
|
||||
@ -221,12 +221,14 @@ std::unique_ptr<CTexture> CTexture::Create(CDevice* device, const char* name,
|
||||
pixelType = GL_UNSIGNED_INT_24_8_EXT;
|
||||
break;
|
||||
#endif
|
||||
case Format::BC1_RGB: FALLTHROUGH;
|
||||
case Format::BC1_RGBA: FALLTHROUGH;
|
||||
case Format::BC2: FALLTHROUGH;
|
||||
case Format::BC3:
|
||||
case Format::BC1_RGB_UNORM: FALLTHROUGH;
|
||||
case Format::BC1_RGBA_UNORM: FALLTHROUGH;
|
||||
case Format::BC2_UNORM: FALLTHROUGH;
|
||||
case Format::BC3_UNORM:
|
||||
compressedFormat = true;
|
||||
break;
|
||||
default:
|
||||
debug_warn("Unsupported format.");
|
||||
}
|
||||
// glCompressedTexImage2D can't accept a null data, so we will initialize it during uploading.
|
||||
if (!compressedFormat)
|
||||
@ -243,7 +245,7 @@ std::unique_ptr<CTexture> CTexture::Create(CDevice* device, const char* name,
|
||||
{
|
||||
ENSURE(MIPLevelCount == 1);
|
||||
#if !CONFIG2_GLES
|
||||
if (format == Format::R8G8B8A8)
|
||||
if (format == Format::R8G8B8A8_UNORM)
|
||||
{
|
||||
glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, sampleCount, GL_RGBA8, width, height, GL_TRUE);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user