|
@@ -157,47 +157,55 @@ bgfx::TextureHandle loadTextureWithUpdate(const char* _filePath, uint64_t _flags
|
|
|
BX_CHECK(1 >= imageContainer->m_depth, "3D Texture loading not supported");
|
|
BX_CHECK(1 >= imageContainer->m_depth, "3D Texture loading not supported");
|
|
|
BX_CHECK(1 == imageContainer->m_numLayers, "Texture Layer loading not supported");
|
|
BX_CHECK(1 == imageContainer->m_numLayers, "Texture Layer loading not supported");
|
|
|
|
|
|
|
|
- if (!imageContainer->m_cubeMap &&
|
|
|
|
|
- 1 >= imageContainer->m_depth &&
|
|
|
|
|
- 1 == imageContainer->m_numLayers &&
|
|
|
|
|
- bgfx::isTextureValid(0, false, imageContainer->m_numLayers, bgfx::TextureFormat::Enum(imageContainer->m_format), _flags)
|
|
|
|
|
- )
|
|
|
|
|
|
|
+ if (!imageContainer->m_cubeMap
|
|
|
|
|
+ && 1 >= imageContainer->m_depth
|
|
|
|
|
+ && 1 == imageContainer->m_numLayers
|
|
|
|
|
+ && bgfx::isTextureValid(0, false, imageContainer->m_numLayers, bgfx::TextureFormat::Enum(imageContainer->m_format), _flags)
|
|
|
|
|
+ )
|
|
|
{
|
|
{
|
|
|
handle = bgfx::createTexture2D(
|
|
handle = bgfx::createTexture2D(
|
|
|
- uint16_t(imageContainer->m_width)
|
|
|
|
|
|
|
+ uint16_t(imageContainer->m_width)
|
|
|
, uint16_t(imageContainer->m_height)
|
|
, uint16_t(imageContainer->m_height)
|
|
|
, 1 < imageContainer->m_numMips
|
|
, 1 < imageContainer->m_numMips
|
|
|
, imageContainer->m_numLayers
|
|
, imageContainer->m_numLayers
|
|
|
, bgfx::TextureFormat::Enum(imageContainer->m_format)
|
|
, bgfx::TextureFormat::Enum(imageContainer->m_format)
|
|
|
, _flags
|
|
, _flags
|
|
|
, NULL
|
|
, NULL
|
|
|
- );
|
|
|
|
|
|
|
+ );
|
|
|
|
|
|
|
|
uint32_t width = imageContainer->m_width;
|
|
uint32_t width = imageContainer->m_width;
|
|
|
uint32_t height = imageContainer->m_height;
|
|
uint32_t height = imageContainer->m_height;
|
|
|
|
|
|
|
|
for (uint8_t lod = 0, num = imageContainer->m_numMips; lod < num; ++lod)
|
|
for (uint8_t lod = 0, num = imageContainer->m_numMips; lod < num; ++lod)
|
|
|
{
|
|
{
|
|
|
- if (width < 4 || height < 4) break;
|
|
|
|
|
- width = bx::max(1u, width);
|
|
|
|
|
|
|
+ if (width < 4 || height < 4)
|
|
|
|
|
+ {
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ width = bx::max(1u, width);
|
|
|
height = bx::max(1u, height);
|
|
height = bx::max(1u, height);
|
|
|
|
|
|
|
|
bimg::ImageMip mip;
|
|
bimg::ImageMip mip;
|
|
|
|
|
+
|
|
|
if (bimg::imageGetRawData(*imageContainer, 0, lod, imageContainer->m_data, imageContainer->m_size, mip))
|
|
if (bimg::imageGetRawData(*imageContainer, 0, lod, imageContainer->m_data, imageContainer->m_size, mip))
|
|
|
{
|
|
{
|
|
|
const uint8_t* mipData = mip.m_data;
|
|
const uint8_t* mipData = mip.m_data;
|
|
|
uint32_t mipDataSize = mip.m_size;
|
|
uint32_t mipDataSize = mip.m_size;
|
|
|
|
|
|
|
|
- bgfx::updateTexture2D(handle,
|
|
|
|
|
- 0,
|
|
|
|
|
- lod,
|
|
|
|
|
- 0,
|
|
|
|
|
- 0,
|
|
|
|
|
- uint16_t(width),
|
|
|
|
|
- uint16_t(height),
|
|
|
|
|
- bgfx::copy(mipData, mipDataSize));
|
|
|
|
|
|
|
+ bgfx::updateTexture2D(
|
|
|
|
|
+ handle
|
|
|
|
|
+ , 0
|
|
|
|
|
+ , lod
|
|
|
|
|
+ , 0
|
|
|
|
|
+ , 0
|
|
|
|
|
+ , uint16_t(width)
|
|
|
|
|
+ , uint16_t(height)
|
|
|
|
|
+ , bgfx::copy(mipData, mipDataSize)
|
|
|
|
|
+ );
|
|
|
}
|
|
}
|
|
|
- width >>= 1;
|
|
|
|
|
|
|
+
|
|
|
|
|
+ width >>= 1;
|
|
|
height >>= 1;
|
|
height >>= 1;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -336,15 +344,17 @@ public:
|
|
|
m_ibh = bgfx::createIndexBuffer(bgfx::makeRef(s_cubeIndices, sizeof(s_cubeIndices) ) );
|
|
m_ibh = bgfx::createIndexBuffer(bgfx::makeRef(s_cubeIndices, sizeof(s_cubeIndices) ) );
|
|
|
|
|
|
|
|
// Create programs.
|
|
// Create programs.
|
|
|
- m_program = loadProgram("vs_update", "fs_update");
|
|
|
|
|
- m_programCmp = loadProgram("vs_update", "fs_update_cmp");
|
|
|
|
|
|
|
+ m_program = loadProgram("vs_update", "fs_update");
|
|
|
|
|
+ m_programCmp = loadProgram("vs_update", "fs_update_cmp");
|
|
|
m_program3d.idx = bgfx::kInvalidHandle;
|
|
m_program3d.idx = bgfx::kInvalidHandle;
|
|
|
|
|
+
|
|
|
if (m_texture3DSupported)
|
|
if (m_texture3DSupported)
|
|
|
{
|
|
{
|
|
|
m_program3d = loadProgram("vs_update", "fs_update_3d");
|
|
m_program3d = loadProgram("vs_update", "fs_update_3d");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
m_programCompute.idx = bgfx::kInvalidHandle;
|
|
m_programCompute.idx = bgfx::kInvalidHandle;
|
|
|
|
|
+
|
|
|
if (m_computeSupported)
|
|
if (m_computeSupported)
|
|
|
{
|
|
{
|
|
|
m_programCompute = bgfx::createProgram( loadShader( "cs_update" ), true );
|
|
m_programCompute = bgfx::createProgram( loadShader( "cs_update" ), true );
|
|
@@ -524,19 +534,14 @@ public:
|
|
|
|
|
|
|
|
showExampleDialog(this);
|
|
showExampleDialog(this);
|
|
|
|
|
|
|
|
- ImGui::SetNextWindowPos(
|
|
|
|
|
- ImVec2(10, 270.0f)
|
|
|
|
|
- , ImGuiCond_FirstUseEver
|
|
|
|
|
- );
|
|
|
|
|
- ImGui::SetNextWindowSize(
|
|
|
|
|
- ImVec2(150.0f, 70.0f)
|
|
|
|
|
- , ImGuiCond_FirstUseEver
|
|
|
|
|
- );
|
|
|
|
|
|
|
+ ImGui::SetNextWindowPos (ImVec2( 10.0f, 270.0f), ImGuiCond_FirstUseEver);
|
|
|
|
|
+ ImGui::SetNextWindowSize(ImVec2(150.0f, 70.0f), ImGuiCond_FirstUseEver);
|
|
|
|
|
|
|
|
- ImGui::Begin("Show descriptions"
|
|
|
|
|
|
|
+ ImGui::Begin(
|
|
|
|
|
+ "Show descriptions"
|
|
|
, NULL
|
|
, NULL
|
|
|
, ImGuiWindowFlags_NoResize
|
|
, ImGuiWindowFlags_NoResize
|
|
|
- );
|
|
|
|
|
|
|
+ );
|
|
|
|
|
|
|
|
if (ImGui::Button(m_showDescriptions ? "ON" : "OFF"))
|
|
if (ImGui::Button(m_showDescriptions ? "ON" : "OFF"))
|
|
|
{
|
|
{
|
|
@@ -723,7 +728,6 @@ public:
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
// Set view and projection matrix for view 1.
|
|
// Set view and projection matrix for view 1.
|
|
|
const uint32_t numColumns = BX_COUNTOF(m_textures) / 2;
|
|
const uint32_t numColumns = BX_COUNTOF(m_textures) / 2;
|
|
|
|
|
|