Skip to content

Commit

Permalink
Merge branch 'postprocess_version' into 'master'
Browse files Browse the repository at this point in the history
[Postprocessing] Add an API version, mirroring Lua

See merge request OpenMW/openmw!3552
  • Loading branch information
uramer committed Nov 16, 2023
2 parents 6484e2e + de8c93d commit d6220b7
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 39 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ set(OPENMW_VERSION_MAJOR 0)
set(OPENMW_VERSION_MINOR 49)
set(OPENMW_VERSION_RELEASE 0)
set(OPENMW_LUA_API_REVISION 50)
set(OPENMW_POSTPROCESSING_API_REVISION 1)

set(OPENMW_VERSION_COMMITHASH "")
set(OPENMW_VERSION_TAGHASH "")
Expand Down
1 change: 1 addition & 0 deletions components/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ if (GIT_CHECKOUT)
-DOPENMW_VERSION_MINOR=${OPENMW_VERSION_MINOR}
-DOPENMW_VERSION_RELEASE=${OPENMW_VERSION_RELEASE}
-DOPENMW_LUA_API_REVISION=${OPENMW_LUA_API_REVISION}
-DOPENMW_POSTPROCESSING_API_REVISION=${OPENMW_POSTPROCESSING_API_REVISION}
-DOPENMW_VERSION=${OPENMW_VERSION}
-DMACROSFILE=${CMAKE_SOURCE_DIR}/cmake/OpenMWMacros.cmake
"-DCMAKE_CONFIGURATION_TYPES=${CMAKE_CONFIGURATION_TYPES}"
Expand Down
3 changes: 3 additions & 0 deletions components/fx/pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <components/sceneutil/lightmanager.hpp>
#include <components/settings/values.hpp>
#include <components/stereo/multiview.hpp>
#include <components/version/version.hpp>

#include "stateupdater.hpp"
#include "technique.hpp"
Expand Down Expand Up @@ -67,6 +68,7 @@ namespace fx
@uboStruct
#define OMW_API_VERSION @apiVersion
#define OMW_REVERSE_Z @reverseZ
#define OMW_RADIAL_FOG @radialFog
#define OMW_EXPONENTIAL_FOG @exponentialFog
Expand Down Expand Up @@ -259,6 +261,7 @@ float omw_EstimateFogCoverageFromUV(vec2 uv)

const std::vector<std::pair<std::string, std::string>> defines
= { { "@pointLightCount", std::to_string(SceneUtil::PPLightBuffer::sMaxPPLightsArraySize) },
{ "@apiVersion", std::to_string(Version::getPostprocessingApiRevision()) },
{ "@version", std::to_string(technique.getGLSLVersion()) },
{ "@multiview", Stereo::getMultiview() ? "1" : "0" },
{ "@builtinSampler", Stereo::getMultiview() ? "sampler2DArray" : "sampler2D" },
Expand Down
5 changes: 5 additions & 0 deletions components/version/version.cpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ namespace Version
return @OPENMW_LUA_API_REVISION@;
}

int getPostprocessingApiRevision()
{
return @OPENMW_POSTPROCESSING_API_REVISION@;
}

std::string getOpenmwVersionDescription()
{
std::string str = "OpenMW version ";
Expand Down
1 change: 1 addition & 0 deletions components/version/version.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace Version
std::string_view getCommitHash();
std::string_view getTagHash();
int getLuaApiRevision();
int getPostprocessingApiRevision();

// Prepares string that contains version and commit hash.
std::string getOpenmwVersionDescription();
Expand Down
5 changes: 5 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@

release = version = "UNRELEASED"
luaApiRevision = "UNKNOWN"
ppApiRevision = "UNDEFINED"

try:
cmake_raw = open(project_root+'/CMakeLists.txt', 'r').read()
Expand All @@ -80,13 +81,17 @@
luaApiRevisionMatch = re.search('set\(OPENMW_LUA_API_REVISION (\d+)\)', cmake_raw)
if luaApiRevisionMatch:
luaApiRevision = luaApiRevisionMatch.group(1)
ppApiRevisionMatch = re.search('set\(OPENMW_POSTPROCESSING_API_REVISION (\d+)\)', cmake_raw)
if ppApiRevisionMatch:
ppApiRevision = ppApiRevisionMatch.group(1)

except Exception as ex:
print("WARNING: Version will be set to '{0}' because: '{1}'.".format(release, str(ex)))
import traceback; traceback.print_exc()

rst_prolog = f"""
.. |luaApiRevision| replace:: {luaApiRevision}
.. |ppApiRevision| replace:: {ppApiRevision}
"""

# The language for content autogenerated by Sphinx. Refer to documentation
Expand Down
82 changes: 43 additions & 39 deletions docs/source/reference/postprocessing/omwfx.rst
Original file line number Diff line number Diff line change
Expand Up @@ -126,45 +126,49 @@ Builtin Uniforms
Builtin Macros
##############

+-----------------------+----------------+----------------------------------------------------------------------+
| Macro | Definition | Description |
+=======================+================+======================================================================+
|``OMW_REVERSE_Z`` | ``0`` or ``1`` | Whether a reversed depth buffer is in use. |
| | | |
| | | ``0`` Depth sampler will be in range [1, 0] |
| | | |
| | | ``1`` Depth sampler will be in range [0, 1] |
+-----------------------+----------------+----------------------------------------------------------------------+
|``OMW_RADIAL_FOG`` | ``0`` or ``1`` | Whether radial fog is in use. |
| | | |
| | | ``0`` Fog is linear |
| | | |
| | | ``1`` Fog is radial |
+-----------------------+----------------+----------------------------------------------------------------------+
|``OMW_EXPONENTIAL_FOG``| ``0`` or ``1`` | Whether exponential fog is in use. |
| | | |
| | | ``0`` Fog is linear |
| | | |
| | | ``1`` Fog is exponential |
+-----------------------+----------------+----------------------------------------------------------------------+
| ``OMW_HDR`` | ``0`` or ``1`` | Whether average scene luminance is computed every frame. |
| | | |
| | | ``0`` Average scene luminance is not computed |
| | | |
| | | ``1`` Average scene luminance is computed |
+-----------------------+----------------+----------------------------------------------------------------------+
| ``OMW_NORMALS`` | ``0`` or ``1`` | Whether normals are available as a sampler in the technique. |
| | | |
| | | ``0`` Normals are not available |
| | | |
| | | ``1`` Normals are available. |
+-----------------------+----------------+----------------------------------------------------------------------+
| ``OMW_MULTIVIEW`` | ``0`` or ``1`` | Whether multiview rendering is in use. |
| | | |
| | | ``0`` Multiview not in use |
| | | |
| | | ``1`` Multiview in use. |
+-----------------------+----------------+----------------------------------------------------------------------+
+-----------------------+-----------------+----------------------------------------------------------------------+
| Macro | Definition | Description |
+=======================+=================+======================================================================+
|``OMW_REVERSE_Z`` | ``0`` or ``1`` | Whether a reversed depth buffer is in use. |
| | | |
| | | ``0`` Depth sampler will be in range [1, 0] |
| | | |
| | | ``1`` Depth sampler will be in range [0, 1] |
+-----------------------+-----------------+----------------------------------------------------------------------+
|``OMW_RADIAL_FOG`` | ``0`` or ``1`` | Whether radial fog is in use. |
| | | |
| | | ``0`` Fog is linear |
| | | |
| | | ``1`` Fog is radial |
+-----------------------+-----------------+----------------------------------------------------------------------+
|``OMW_EXPONENTIAL_FOG``| ``0`` or ``1`` | Whether exponential fog is in use. |
| | | |
| | | ``0`` Fog is linear |
| | | |
| | | ``1`` Fog is exponential |
+-----------------------+-----------------+----------------------------------------------------------------------+
| ``OMW_HDR`` | ``0`` or ``1`` | Whether average scene luminance is computed every frame. |
| | | |
| | | ``0`` Average scene luminance is not computed |
| | | |
| | | ``1`` Average scene luminance is computed |
+-----------------------+-----------------+----------------------------------------------------------------------+
| ``OMW_NORMALS`` | ``0`` or ``1`` | Whether normals are available as a sampler in the technique. |
| | | |
| | | ``0`` Normals are not available |
| | | |
| | | ``1`` Normals are available. |
+-----------------------+-----------------+----------------------------------------------------------------------+
| ``OMW_MULTIVIEW`` | ``0`` or ``1`` | Whether multiview rendering is in use. |
| | | |
| | | ``0`` Multiview not in use |
| | | |
| | | ``1`` Multiview in use. |
+-----------------------+-----------------+----------------------------------------------------------------------+
| ``OMW_API_VERSION`` | |ppApiRevision| | The revision of OpenMW postprocessing API. |
| | | It is an integer that is incremented every time the API is changed. |
| | | This was added in 0.49, so it will be undefined in 0.48. |
+-----------------------+-----------------+----------------------------------------------------------------------+


Builtin Functions
Expand Down

0 comments on commit d6220b7

Please sign in to comment.