Skip to content

Commit

Permalink
Merge branch 'OGRECave:master' into removeFiles
Browse files Browse the repository at this point in the history
  • Loading branch information
mosfet80 authored Apr 29, 2024
2 parents 04ab392 + 2ca9dc9 commit c4ae95a
Show file tree
Hide file tree
Showing 58 changed files with 1,265 additions and 141 deletions.
5 changes: 5 additions & 0 deletions CMake/Dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,11 @@ if(WIN32)
macro_log_feature(AMDAGS_FOUND "AMDAGS" "Use AMD GPU Services library to provide D3D vendor extensions" "https://gpuopen.com/gaming-product/amd-gpu-services-ags-library/" FALSE "" "")
endif()

if(ANDROID)
find_package(AndroidSwappy)
macro_log_feature(AndroidSwappy_FOUND "Android Swappy" "Frame Pacing Library (Swappy) for Android" "https://developer.android.com/games/sdk/frame-pacing" FALSE "" "")
endif()

find_package(OpenVR)
macro_log_feature(OpenVR_FOUND "OpenVR" "OpenVR for Virtual Reality" "https://github.com/ValveSoftware/openvr" FALSE "" "")

Expand Down
47 changes: 47 additions & 0 deletions CMake/Packages/FindAndroidSwappy.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#-------------------------------------------------------------------
# This file is part of the CMake build system for OGRE-Next
# (Object-oriented Graphics Rendering Engine)
# For the latest info, see http://www.ogre3d.org/
#
# The contents of this file are placed in the public domain. Feel
# free to make use of it in any way you like.
#-------------------------------------------------------------------

# - Try to find AndroidSwappy
# Once done, this will define
#
# AndroidSwappy_FOUND - system has AndroidSwappy
# AndroidSwappy_INCLUDE_DIRS - the AndroidSwappy include directories
# AndroidSwappy_LIBRARIES - link these to use AndroidSwappy

include(FindPkgMacros)
findpkg_begin(AndroidSwappy)

# Get path, convert backslashes as ${ENV_${var}}
getenv_path(OGRE_SOURCE)
getenv_path(OGRE_HOME)

# construct search paths
set(AndroidSwappy_PREFIX_PATH ${OGRE_SOURCE}/Dependencies ${ENV_OGRE_SOURCE}/Dependencies ${OGRE_HOME} ${ENV_OGRE_HOME})

create_search_paths(AndroidSwappy)

# redo search if prefix path changed
clear_if_changed(AndroidSwappy_PREFIX_PATH
AndroidSwappy_LIBRARY_FWK
AndroidSwappy_LIBRARY_REL
AndroidSwappy_LIBRARY_DBG
AndroidSwappy_INCLUDE_DIR
)

get_debug_names(AndroidSwappy_LIBRARY_NAMES)

use_pkgconfig(AndroidSwappy_PKGC AndroidSwappy)

findpkg_framework(AndroidSwappy)

find_path(AndroidSwappy_INCLUDE_DIR NAMES swappyVk.h HINTS ${AndroidSwappy_FRAMEWORK_INCLUDES} ${AndroidSwappy_INC_SEARCH_PATH} ${AndroidSwappy_PKGC_INCLUDE_DIRS} PATH_SUFFIXES "swappy" "swappy/swappy")
find_library(AndroidSwappy_LIBRARY NAMES swappy_static HINTS ${AndroidSwappy_LIB_SEARCH_PATH} ${AndroidSwappy_PKGC_LIBRARY_DIRS} PATH_SUFFIXES "" release relwithdebinfo minsizerel debug)

findpkg_finish(AndroidSwappy)
add_parent_dir(AndroidSwappy_INCLUDE_DIRS AndroidSwappy_INCLUDE_DIR)
1 change: 1 addition & 0 deletions CMake/Templates/OgreVulkanBuildSettings.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

// CMake auto-generated configuration options

#cmakedefine OGRE_VULKAN_USE_SWAPPY
#cmakedefine OGRE_VULKAN_WINDOW_NULL
#cmakedefine OGRE_VULKAN_WINDOW_WIN32
#cmakedefine OGRE_VULKAN_WINDOW_XCB
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,7 @@ if( OGRE_GLSUPPORT_USE_EGL_HEADLESS )
endif()
cmake_dependent_option(OGRE_BUILD_RENDERSYSTEM_GLES2 "Build OpenGL ES 2.x RenderSystem" FALSE "OPENGLES2_FOUND;NOT WINDOWS_STORE;NOT WINDOWS_PHONE" FALSE)
cmake_dependent_option(OGRE_BUILD_RENDERSYSTEM_VULKAN "Build Vulkan RenderSystem" TRUE "Vulkan_FOUND" FALSE)
cmake_dependent_option(OGRE_VULKAN_USE_SWAPPY "Vulkan: Use Swappy Frame Pacing (Recommended)" TRUE "ANDROID;AndroidSwappy_FOUND" FALSE)
cmake_dependent_option(OGRE_VULKAN_WINDOW_NULL "Allow headless support. If more than one OGRE_VULKAN_WINDOW is enabled, interface can be selected at runtime" FALSE "OGRE_BUILD_RENDERSYSTEM_VULKAN" FALSE)
cmake_dependent_option(OGRE_VULKAN_WINDOW_WIN32 "Use Win32 (Default / Native window). If more than one OGRE_VULKAN_WINDOW is enabled, interface can be selected at runtime" TRUE "OGRE_BUILD_RENDERSYSTEM_VULKAN;WIN32" FALSE)
cmake_dependent_option(OGRE_VULKAN_WINDOW_XCB "Use X11 / xcb (Default / Native window). If more than one OGRE_VULKAN_WINDOW is enabled, interface can be selected at runtime" TRUE "OGRE_BUILD_RENDERSYSTEM_VULKAN;UNIX;NOT ANDROID;NOT OGRE_CONFIG_UNIX_NO_X11" FALSE)
Expand Down
7 changes: 7 additions & 0 deletions Components/Hlms/Pbs/src/OgreHlmsJsonPbs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,10 @@ namespace Ogre
changeBlendblock );
}

itor = json.FindMember( "refraction_strength" );
if( itor != json.MemberEnd() && itor->value.IsNumber() )
pbsDatablock->setRefractionStrength( static_cast<float>( itor->value.GetDouble() ) );

itor = json.FindMember( "clear_coat" );
if( itor != json.MemberEnd() && itor->value.IsObject() )
{
Expand Down Expand Up @@ -837,6 +841,9 @@ namespace Ogre
outString += "\n\t\t\t}";
}

outString += ",\n\t\t\t\"refraction_strength\" : ";
outString += StringConverter::toString( pbsDatablock->getRefractionStrength() );

if( pbsDatablock->getClearCoat() != 0.0f )
{
outString += ",\n\t\t\t\"clear_coat\" :\n\t\t\t{";
Expand Down
4 changes: 3 additions & 1 deletion Components/Hlms/Pbs/src/OgreHlmsPbs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2801,7 +2801,7 @@ namespace Ogre
if( mHasPlanarReflections )
{
mPlanarReflections->fillConstBufferData( renderTarget, cameras.renderingCamera,
projectionMatrix, passBufferPtr );
passBufferPtr );
passBufferPtr += mPlanarReflections->getConstBufferSize() >> 2u;
}
#endif
Expand Down Expand Up @@ -3193,6 +3193,8 @@ namespace Ogre

#ifdef OGRE_BUILD_COMPONENT_PLANAR_REFLECTIONS
mLastBoundPlanarReflection = 0u;
if( mHasPlanarReflections )
++texUnit; // We do not bind this texture now, but its slot is reserved.
#endif
mListener->hlmsTypeChanged( casterPass, commandBuffer, datablock, texUnit );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,6 @@ namespace Ogre
Assumes 'passBufferPtr' is aligned to a vec4/float4 boundary.
*/
void fillConstBufferData( TextureGpu *renderTarget, const Camera *camera,
const Matrix4 &projectionMatrix,
float *RESTRICT_ALIAS passBufferPtr ) const;

TextureGpu *getTexture( uint8 actorIdx ) const;
Expand Down
6 changes: 4 additions & 2 deletions Components/PlanarReflections/src/OgrePlanarReflections.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,6 @@ namespace Ogre
}
//-----------------------------------------------------------------------------------
void PlanarReflections::fillConstBufferData( TextureGpu *renderTarget, const Camera *camera,
const Matrix4 &projectionMatrix,
float *RESTRICT_ALIAS passBufferPtr ) const
{
const Matrix4 viewMatrix = camera->getViewMatrix( true );
Expand Down Expand Up @@ -886,7 +885,10 @@ namespace Ogre
memset( passBufferPtr, 0, ( mMaxActiveActors - mActiveActors.size() ) * 4u * sizeof( float ) );
passBufferPtr += ( mMaxActiveActors - mActiveActors.size() ) * 4u;

Matrix4 reflProjMat = PROJECTIONCLIPSPACE2DTOIMAGESPACE_PERSPECTIVE * projectionMatrix;
// We call getProjectionMatrixWithRSDepth directly because
// it must NOT account for requiresTextureFlipping.
Matrix4 reflProjMat =
PROJECTIONCLIPSPACE2DTOIMAGESPACE_PERSPECTIVE * camera->getProjectionMatrixWithRSDepth();
for( size_t i = 0; i < 16; ++i )
*passBufferPtr++ = (float)reflProjMat[0][i];

Expand Down
1 change: 1 addition & 0 deletions Docs/2.0/JSON/PbsAllSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ including invalid combinations (i.e. having a Metallic texture and a Specular te
"shadow_const_bias" : 0.01,
"two_sided" : false,
"receive_shadows" : true,
"refraction_strength" : 0.2,

"workflow" : "specular_ogre" "specular_fresnel" "metallic",

Expand Down
8 changes: 8 additions & 0 deletions Docs/src/manual/HlmsPBSDatablockReference.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ Reference Guide: HLMS PBS Datablock {#hlmspbsdatablockref}
- If switching from the 'default' BRDF implementation, the scene will be too bright. If so, divide light power by PI.
- **DEFAULT="default"**

## Parameter: refraction_strength

- Value of type float
- See Ogre::HlmsPbsDatablock::setRefractionStrength
- **DEFAULT=0.075**

## Parameter: detail_diffuse[X] {#dbParamDetailDiffuse}
- Name of the detail map to be used on top of the diffuse colour
- Can contain up to 4 detail_diffuse blocks (`detail_diffuse0` to `detail_diffuse3`)
Expand Down Expand Up @@ -263,6 +269,8 @@ Reference Guide: HLMS PBS Datablock {#hlmspbsdatablockref}
"macroblock" : "macroblock_name",
"macroblock" : ["macroblock_name", "macroblock_name_for_shadows"],
"shadow_const_bias" : 0.01,
"refraction_strength" : 0.2,
"brdf" : "default",
"detail_diffuse0" :
Expand Down
29 changes: 29 additions & 0 deletions OgreMain/include/OgreRenderQueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ namespace Ogre
Semaphore mSemaphore;
std::atomic<bool> mKeepCompiling;

bool mExceptionFound; // GUARDED_BY( mMutex )
std::exception_ptr mThreadedException; // GUARDED_BY( mMutex )

public:
ParallelHlmsCompileQueue();

Expand All @@ -102,13 +105,39 @@ namespace Ogre

inline void pushWarmUpRequest( const Request &&request ) { mRequests.emplace_back( request ); }

/** Starts worker threads (job queue) so they start accepting work every time pushRequest()
gets called and will keep compiling those shaders until stopAndWait() is called.
The work is done in updateThread() and is in charge of compiling shaders AND generating PSOs.
@remarks
This function must not be called if RenderSystem::supportsMultithreadedShaderCompliation
is false.
@param sceneManager
*/
void start( SceneManager *sceneManager );
/** Signals worker threads we won't be submitting more work, so they should stop once they're
done compiling all pending shaders / PSOs.
Will wait until all shaders are done.
@param sceneManager
*/
void stopAndWait( SceneManager *sceneManager );
/// The actual work done by the job queues.
void updateThread( size_t threadIdx, HlmsManager *hlmsManager );

/// Similar to start() and stopAndWait() at the same time: It assumes all work has already been
/// gathered in mRequests via pushWarmUpRequest() (instead of gather it as we go)
/// and fires all threads to compile the shaders and PSOs in parallel.
///
/// It will wait until all threads are done.
void fireWarmUpParallel( SceneManager *sceneManager );

/// The actual work done by fireWarmUpParallel().
void updateWarmUpThread( size_t threadIdx, HlmsManager *hlmsManager,
const HlmsCache *passCaches );

/// Serial alternative of fireWarmUpParallel() + updateWarmUpThread() for when
/// RenderSystem::supportsMultithreadedShaderCompliation is false.
void warmUpSerial( HlmsManager *hlmsManager, const HlmsCache *passCaches );
};

Expand Down
22 changes: 20 additions & 2 deletions OgreMain/include/OgreRenderSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -305,9 +305,27 @@ namespace Ogre
bool getWBufferEnabled() const;

/** Returns supported sample description for requested FSAA mode, with graceful downgrading.
*/
@note
Depth/Stencil-only buffer formats combined with TextureFlags::Uav is valid
but a rarely-supported combination. Don't ask for it unless that's truly what you want.
@param sampleDesc
Reqiested sample description.
@param format
Use PF_NULL returns to query support for framebuffer-less rendering.
@param textureFlags
See TextureFlags::TextureFlags.
Relevant flags are:
NotTexture
Uav
@param depthTextureFlags
Only used if format is a colour pixel format.
Same as textureFlags, but for associated depth buffer if format.
@return
Supported sample description for requested FSAA mode, with graceful downgrading.
*/
virtual SampleDescription validateSampleDescription( const SampleDescription &sampleDesc,
PixelFormatGpu format );
PixelFormatGpu format, uint32 textureFlags,
uint32 depthTextureFlags );

/** Creates a new rendering window.
@remarks
Expand Down
1 change: 1 addition & 0 deletions OgreMain/include/OgreScriptCompiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -931,6 +931,7 @@ namespace Ogre
ID_MSAA,
ID_MSAA_AUTO,
ID_EXPLICIT_RESOLVE,
ID_NOT_TEXTURE,
ID_REINTERPRETABLE,
ID_KEEP_CONTENT,
ID_DEPTH_POOL,
Expand Down
16 changes: 9 additions & 7 deletions OgreMain/include/OgreWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,15 @@ namespace Ogre
/** \addtogroup Resources
* @{
*/
OGRE_ASSUME_NONNULL_BEGIN

class _OgreExport Window : public OgreAllocatedObj
{
protected:
String mTitle;
TextureGpu *mTexture;
TextureGpu *mDepthBuffer;
TextureGpu *mStencilBuffer;
String mTitle;
TextureGpu *ogre_nullable mTexture;
TextureGpu *ogre_nullable mDepthBuffer;
TextureGpu *ogre_nullable mStencilBuffer;

/** 0/0 is legal and will be interpreted as 0/1.
0/anything is interpreted as zero.
Expand Down Expand Up @@ -295,15 +296,16 @@ namespace Ogre

/// WARNING: Attempting to change the TextureGpu (e.g. setResolution, setPixelFormat)
/// is undefined behavior
TextureGpu *getTexture() const;
TextureGpu *getDepthBuffer() const;
TextureGpu *getStencilBuffer() const;
TextureGpu *ogre_nullable getTexture() const;
TextureGpu *ogre_nullable getDepthBuffer() const;
TextureGpu *ogre_nullable getStencilBuffer() const;

virtual void getCustomAttribute( IdString name, void *pData ) {}

virtual void swapBuffers() = 0;
};

OGRE_ASSUME_NONNULL_END
/** @} */
/** @} */
} // namespace Ogre
Expand Down
40 changes: 21 additions & 19 deletions OgreMain/include/Threading/OgreThreads.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,31 @@ THE SOFTWARE.
# define OGRE_THREAD_CALL_CONVENTION
#endif

namespace Ogre
{
template <typename T>
struct DeleteOnDestructor
{
T *ptr;
DeleteOnDestructor( T *_ptr ) : ptr( _ptr ) {}
~DeleteOnDestructor() { delete ptr; }

// Prevent being able to copy this object
DeleteOnDestructor( const DeleteOnDestructor & ) = delete;
DeleteOnDestructor &operator=( const DeleteOnDestructor & ) = delete;
};
} // namespace Ogre

#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32 || OGRE_PLATFORM == OGRE_PLATFORM_WINRT
/// See Threads::CreateThread for an example on how to use
# define THREAD_DECLARE( threadFunction ) \
unsigned long OGRE_THREAD_CALL_CONVENTION threadFunction##_internal( void *argName ) \
{ \
unsigned long retVal = 0; \
Ogre::ThreadHandle *threadHandle( reinterpret_cast<Ogre::ThreadHandle *>( argName ) ); \
try \
{ \
threadHandle->_setOsHandleToSelf(); \
retVal = threadFunction( threadHandle ); \
} \
catch( ... ) \
{ \
} \
delete threadHandle; \
Ogre::DeleteOnDestructor<Ogre::ThreadHandle> container( threadHandle ); \
threadHandle->_setOsHandleToSelf(); \
retVal = threadFunction( threadHandle ); \
return retVal; \
}
#else
Expand All @@ -66,16 +75,9 @@ THE SOFTWARE.
{ \
unsigned long retVal = 0; \
Ogre::ThreadHandle *threadHandle( reinterpret_cast<Ogre::ThreadHandle *>( argName ) ); \
try \
{ \
threadHandle->_setOsHandleToSelf(); \
retVal = threadFunction( threadHandle ); \
} \
catch( ... ) \
{ \
} \
delete threadHandle; \
\
Ogre::DeleteOnDestructor<Ogre::ThreadHandle> container( threadHandle ); \
threadHandle->_setOsHandleToSelf(); \
retVal = threadFunction( threadHandle ); \
return (void *)retVal; \
}
#endif
Expand Down
11 changes: 9 additions & 2 deletions OgreMain/src/OgreFreeImageCodec2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ THE SOFTWARE.

#include <sstream>

// We want to be compatible with both FreeImage and FreeImageRe, but first specifies sizes as DWORD and
// second as uint32_t. On Windows both DWORD (unsigned long) and uint32_t are separate 32bit types, so
// pointers to them can not be mixed
#ifndef FISIZE
# define FISIZE decltype( FIICCPROFILE::size ) // DWORD for FreeImage, uint32_t for FreeImageRe
#endif

namespace Ogre
{
FreeImageCodec2::RegisteredCodecList FreeImageCodec2::msCodecList;
Expand Down Expand Up @@ -425,7 +432,7 @@ namespace Ogre
FreeImage_SaveToMemory( (FREE_IMAGE_FORMAT)mFreeImageType, fiBitmap, mem );
// Grab data information
uint8_t *data;
uint32_t size;
FISIZE size;
FreeImage_AcquireMemory( mem, &data, &size );
// Copy data into our own buffer
// Because we're asking MemoryDataStream to free this, must create in a compatible way
Expand Down Expand Up @@ -657,7 +664,7 @@ namespace Ogre
FIMEMORY *fiMem = FreeImage_OpenMemory( (uint8_t *)const_cast<char *>( magicNumberPtr ),
static_cast<uint32_t>( maxbytes ) );

const FIBOOL bValid = FreeImage_ValidateFromMemory( (FREE_IMAGE_FORMAT)mFreeImageType, fiMem );
const auto bValid = FreeImage_ValidateFromMemory( (FREE_IMAGE_FORMAT)mFreeImageType, fiMem );
FreeImage_CloseMemory( fiMem );

if( bValid )
Expand Down
Loading

0 comments on commit c4ae95a

Please sign in to comment.