Skip to content

Commit 264e6f1

Browse files
committed
fix compile errors, correct dependent names, add missing recreateSurface and adjust old API to the new one, make it compile and produce an APK (meshloaders example checked).
1 parent 3843302 commit 264e6f1

File tree

5 files changed

+77
-14
lines changed

5 files changed

+77
-14
lines changed

examples_tests/common/CommonAPI.h

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -859,6 +859,69 @@ class CommonAPI
859859
#endif
860860
}
861861

862+
#ifdef _NBL_PLATFORM_ANDROID_
863+
static void recreateSurface(nbl::ui::CGraphicalApplicationAndroid* framework)
864+
{
865+
using namespace nbl;
866+
android_app* app = framework->getApp();
867+
auto apiConnection = framework->getAPIConnection();
868+
auto window = framework->getWindow();
869+
auto logicalDevice = framework->getLogicalDevice();
870+
auto surface = nbl::video::CSurfaceGLAndroid::create(nbl::core::smart_refctd_ptr<nbl::video::COpenGLESConnection>((nbl::video::COpenGLESConnection*)apiConnection), nbl::core::smart_refctd_ptr<nbl::ui::IWindowAndroid>(static_cast<nbl::ui::IWindowAndroid*>(window)));
871+
auto renderpass = framework->getRenderpass();
872+
nbl::asset::E_FORMAT depthFormat = framework->getDepthFormat();
873+
framework->setSurface(surface);
874+
uint32_t width = ANativeWindow_getWidth(app->window);
875+
uint32_t height = ANativeWindow_getHeight(app->window);
876+
uint32_t scImageCount = framework->getSwapchainImageCount();
877+
nbl::video::ISurface::SFormat requestedFormat;
878+
879+
// Temporary to make previous examples work
880+
requestedFormat.format = nbl::asset::EF_R8G8B8A8_SRGB;
881+
requestedFormat.colorSpace.eotf = nbl::asset::EOTF_sRGB;
882+
requestedFormat.colorSpace.primary = nbl::asset::ECP_SRGB;
883+
884+
auto gpus = apiConnection->getPhysicalDevices();
885+
assert(!gpus.empty());
886+
auto extractedInfos = extractGPUInfos(gpus, surface);
887+
auto suitableGPUIndex = findSuitableGPU(extractedInfos, true);
888+
auto gpu = gpus.begin()[suitableGPUIndex];
889+
const auto& gpuInfo = extractedInfos[suitableGPUIndex];
890+
891+
auto swapchain = createSwapchain(nbl::video::EAT_OPENGL_ES,
892+
gpuInfo,
893+
scImageCount,
894+
width,
895+
height,
896+
nbl::core::smart_refctd_ptr<nbl::video::ILogicalDevice>(logicalDevice),
897+
surface,
898+
nbl::asset::IImage::E_USAGE_FLAGS::EUF_NONE,
899+
nbl::video::ISurface::EPM_FIFO_RELAXED,
900+
requestedFormat
901+
);
902+
auto fbo = [&]()
903+
{
904+
auto fbos = createFBOWithSwapchainImages(scImageCount,
905+
width,
906+
height,
907+
nbl::core::smart_refctd_ptr<nbl::video::ILogicalDevice>(logicalDevice),
908+
swapchain,
909+
nbl::core::smart_refctd_ptr<nbl::video::IGPURenderpass>(renderpass),
910+
depthFormat
911+
);
912+
913+
std::vector<nbl::core::smart_refctd_ptr<video::IGPUFramebuffer>> data;
914+
for(auto it : fbos)
915+
data.push_back(it);
916+
917+
return data;
918+
}();
919+
920+
framework->setSwapchain(std::move(swapchain));
921+
framework->setFBOs(fbo);
922+
}
923+
#endif
924+
862925
template<bool gpuInit = true, class EventCallback = CommonAPIEventCallback>
863926
static void Init(
864927
InitOutput& result,

include/nbl/video/utilities/CPropertyPool.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class CPropertyPool final : public IPropertyPool
101101

102102
// useful for everyone
103103
template<typename DescriptorSetLayoutType>
104-
static inline void fillDescriptorLayoutBindings(DescriptorSetLayoutType::SBinding* bindings, asset::IShader::E_SHADER_STAGE* stageAccessFlags=nullptr)
104+
static inline void fillDescriptorLayoutBindings(typename DescriptorSetLayoutType::SBinding* bindings, asset::IShader::E_SHADER_STAGE* stageAccessFlags=nullptr)
105105
{
106106
IPropertyPool::fillDescriptorLayoutBindings<DescriptorSetLayoutType,PropertyCount>(bindings,stageAccessFlags);
107107
}

include/nbl/video/utilities/IPropertyPool.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ class IPropertyPool : public core::IReferenceCounted
191191

192192
// useful for everyone
193193
template<typename DescriptorSetLayoutType, uint32_t PropertyCount>
194-
static inline void fillDescriptorLayoutBindings(DescriptorSetLayoutType::SBinding* bindings, asset::IShader::E_SHADER_STAGE* stageAccessFlags=nullptr)
194+
static inline void fillDescriptorLayoutBindings(typename DescriptorSetLayoutType::SBinding* bindings, asset::IShader::E_SHADER_STAGE* stageAccessFlags=nullptr)
195195
{
196196
DescriptorSetLayoutType::fillBindingsSameType(bindings,PropertyCount,asset::E_DESCRIPTOR_TYPE::EDT_STORAGE_BUFFER,nullptr,stageAccessFlags);
197197
}

src/nbl/asset/interchange/CGLTFLoader.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,7 +1089,7 @@ namespace nbl
10891089

10901090
for (uint16_t i = 0; i < vertexInfluenceData.perVertexComponentsData.size(); ++i) //! iterate over single components
10911091
{
1092-
VertexInfluenceData::ComponentData& skinComponent = vertexInfluenceData.perVertexComponentsData[i];
1092+
typename VertexInfluenceData::ComponentData& skinComponent = vertexInfluenceData.perVertexComponentsData[i];
10931093

10941094
JointComponentT* vJoint = reinterpret_cast<JointComponentT*>(vJointsComponentDataRaw) + i;
10951095
WeightCompomentT* vWeight = reinterpret_cast<WeightCompomentT*>(vWeightsComponentDataRaw) + i;
@@ -1099,7 +1099,7 @@ namespace nbl
10991099
}
11001100
}
11011101

1102-
std::vector<VertexInfluenceData::ComponentData> skinComponentUnlimitedStream;
1102+
std::vector<typename VertexInfluenceData::ComponentData> skinComponentUnlimitedStream;
11031103
{
11041104
for (const auto& vertexInfluenceData : vertexInfluenceDataContainer)
11051105
for (const auto& skinComponent : vertexInfluenceData.perVertexComponentsData)
@@ -1112,13 +1112,13 @@ namespace nbl
11121112
}
11131113

11141114
//! sort, cache and keep only biggest influencers
1115-
std::sort(std::begin(skinComponentUnlimitedStream), std::end(skinComponentUnlimitedStream), [&](const VertexInfluenceData::ComponentData& lhs, const VertexInfluenceData::ComponentData& rhs) { return lhs.weight < rhs.weight; });
1115+
std::sort(std::begin(skinComponentUnlimitedStream), std::end(skinComponentUnlimitedStream), [&](const typename VertexInfluenceData::ComponentData& lhs, const typename VertexInfluenceData::ComponentData& rhs) { return lhs.weight < rhs.weight; });
11161116
{
11171117
auto iteratorEnd = skinComponentUnlimitedStream.begin() + (vertexInfluenceDataContainer.size() - 1u) * 4u;
11181118
if (skinComponentUnlimitedStream.begin() != iteratorEnd)
11191119
skinComponentUnlimitedStream.erase(skinComponentUnlimitedStream.begin(), iteratorEnd);
11201120

1121-
std::sort(std::begin(skinComponentUnlimitedStream), std::end(skinComponentUnlimitedStream), [&](const VertexInfluenceData::ComponentData& lhs, const VertexInfluenceData::ComponentData& rhs) { return lhs.joint < rhs.joint; });
1121+
std::sort(std::begin(skinComponentUnlimitedStream), std::end(skinComponentUnlimitedStream), [&](const typename VertexInfluenceData::ComponentData& lhs, const typename VertexInfluenceData::ComponentData& rhs) { return lhs.joint < rhs.joint; });
11221122
}
11231123

11241124
auto* vOverrideJointsData = reinterpret_cast<uint8_t*>(vOverrideJointsBuffer->getPointer()) + commonVJointsOffset;
@@ -1280,8 +1280,8 @@ namespace nbl
12801280
for (uint16_t i = 0; i < quantRequest.encodeData.size(); ++i) //! quantization test
12811281
{
12821282
auto& encode = quantRequest.encodeData[i];
1283-
auto* quantBuffer = std::get<QuantRequest::QUANT_BUFFER>(encode);
1284-
auto* errorBuffer = std::get<QuantRequest::ERROR_BUFFER>(encode);
1283+
auto* quantBuffer = std::get<typename QuantRequest::QUANT_BUFFER>(encode);
1284+
auto* errorBuffer = std::get<typename QuantRequest::ERROR_BUFFER>(encode);
12851285
const WEIGHT_ENCODING requestWeightEncoding = std::get<WEIGHT_ENCODING>(encode);
12861286
const E_FORMAT requestQuantFormat = std::get<E_FORMAT>(encode);
12871287

@@ -1293,7 +1293,7 @@ namespace nbl
12931293
const auto& weightInput = packedWeightsStream.pointer[i];
12941294
if (weightInput)
12951295
{
1296-
const QuantRequest::ERROR_TYPE& errorComponent = errorBuffer[i] = core::abs(quantsDecoded.pointer[i] - weightInput);
1296+
const typename QuantRequest::ERROR_TYPE& errorComponent = errorBuffer[i] = core::abs(quantsDecoded.pointer[i] - weightInput);
12971297

12981298
if (errorComponent)
12991299
{
@@ -1680,7 +1680,7 @@ namespace nbl
16801680

16811681
if(nodes.error() != simdjson::error_code::NO_SUCH_FIELD)
16821682
for (const auto& node : nodes.get_array())
1683-
glTFScene.nodes.push_back(node.get_uint64());
1683+
glTFScene.nodes.push_back(static_cast<uint32_t>(node.get_uint64()));
16841684
}
16851685
}
16861686

src/nbl/video/CVulkanAccelerationStructure.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ uint64_t CVulkanAccelerationStructure::getReferenceForHostOperations() const
3939
}
4040

4141
template<>
42-
static VkDeviceOrHostAddressKHR CVulkanAccelerationStructure::getVkDeviceOrHostAddress(VkDevice vk_device, const CVulkanDeviceFunctionTable* vk_devf, const DeviceAddressType& addr) {
42+
VkDeviceOrHostAddressKHR CVulkanAccelerationStructure::getVkDeviceOrHostAddress(VkDevice vk_device, const CVulkanDeviceFunctionTable* vk_devf, const DeviceAddressType& addr) {
4343
VkDeviceOrHostAddressKHR ret = {};
4444
if(addr.buffer.get() != nullptr)
4545
{
@@ -52,7 +52,7 @@ static VkDeviceOrHostAddressKHR CVulkanAccelerationStructure::getVkDeviceOrHostA
5252
return ret;
5353
}
5454
template<>
55-
static VkDeviceOrHostAddressKHR CVulkanAccelerationStructure::getVkDeviceOrHostAddress(VkDevice vk_device, const CVulkanDeviceFunctionTable* vk_devf, const HostAddressType& addr) {
55+
VkDeviceOrHostAddressKHR CVulkanAccelerationStructure::getVkDeviceOrHostAddress(VkDevice vk_device, const CVulkanDeviceFunctionTable* vk_devf, const HostAddressType& addr) {
5656
VkDeviceOrHostAddressKHR ret = {};
5757
if(addr.buffer.get() != nullptr)
5858
{
@@ -65,7 +65,7 @@ static VkDeviceOrHostAddressKHR CVulkanAccelerationStructure::getVkDeviceOrHostA
6565
return ret;
6666
}
6767
template<>
68-
static VkDeviceOrHostAddressConstKHR CVulkanAccelerationStructure::getVkDeviceOrHostConstAddress(VkDevice vk_device, const CVulkanDeviceFunctionTable* vk_devf, const DeviceAddressType& addr) {
68+
VkDeviceOrHostAddressConstKHR CVulkanAccelerationStructure::getVkDeviceOrHostConstAddress(VkDevice vk_device, const CVulkanDeviceFunctionTable* vk_devf, const DeviceAddressType& addr) {
6969
VkDeviceOrHostAddressConstKHR ret = {};
7070
if(addr.buffer.get() != nullptr)
7171
{
@@ -78,7 +78,7 @@ static VkDeviceOrHostAddressConstKHR CVulkanAccelerationStructure::getVkDeviceOr
7878
return ret;
7979
}
8080
template<>
81-
static VkDeviceOrHostAddressConstKHR CVulkanAccelerationStructure::getVkDeviceOrHostConstAddress(VkDevice vk_device, const CVulkanDeviceFunctionTable* vk_devf, const HostAddressType& addr) {
81+
VkDeviceOrHostAddressConstKHR CVulkanAccelerationStructure::getVkDeviceOrHostConstAddress(VkDevice vk_device, const CVulkanDeviceFunctionTable* vk_devf, const HostAddressType& addr) {
8282
VkDeviceOrHostAddressConstKHR ret = {};
8383
if(addr.buffer.get() != nullptr)
8484
{

0 commit comments

Comments
 (0)