From 6f7e8bb396ee827ae795dc4cd2fedebaf48c6fea Mon Sep 17 00:00:00 2001 From: baldurk Date: Thu, 3 Dec 2020 22:29:15 +0000 Subject: [PATCH] Add python interface consistency check that we don't use non-class enums * These enums are generally not preferred anyway, but they also can't have docstrings so can't be checked for *missing* docstrings. --- qrenderdoc/Code/Interface/PersistantConfig.h | 2 + qrenderdoc/Code/pyrenderdoc/PythonContext.cpp | 28 +++++++++++ renderdoc/api/replay/replay_enums.h | 50 +++++++++++++++++-- 3 files changed, 77 insertions(+), 3 deletions(-) diff --git a/qrenderdoc/Code/Interface/PersistantConfig.h b/qrenderdoc/Code/Interface/PersistantConfig.h index 8ea22678a..16e5572bd 100644 --- a/qrenderdoc/Code/Interface/PersistantConfig.h +++ b/qrenderdoc/Code/Interface/PersistantConfig.h @@ -219,7 +219,9 @@ struct ShaderProcessingTool DECLARE_REFLECTION_STRUCT(ShaderProcessingTool); +#if !defined(SWIG) #define BUGREPORT_URL "https://renderdoc.org/bugreporter" +#endif DOCUMENT("Describes a submitted bug report."); struct BugReport diff --git a/qrenderdoc/Code/pyrenderdoc/PythonContext.cpp b/qrenderdoc/Code/pyrenderdoc/PythonContext.cpp index 914cab58e..fafd6d02b 100644 --- a/qrenderdoc/Code/pyrenderdoc/PythonContext.cpp +++ b/qrenderdoc/Code/pyrenderdoc/PythonContext.cpp @@ -480,8 +480,36 @@ bool PythonContext::CheckInterfaces(rdcstr &log) PyGILState_STATE gil = PyGILState_Ensure(); errors |= CheckCoreInterface(log); errors |= CheckQtInterface(log); + + for(rdcstr module_name : {"renderdoc", "qrenderdoc"}) + { + PyObject *mod = PyImport_ImportModule(module_name.c_str()); + PyObject *dict = PyModule_GetDict(mod); + + PyObject *key, *value; + Py_ssize_t pos = 0; + + while(PyDict_Next(dict, &pos, &key, &value)) + { + rdcstr name = ToQStr(key); + + if(name.beginsWith("__")) + continue; + + if(!PyCallable_Check(value)) + { + log += "Non-callable object found: " + module_name + "." + name + + ". Expected only classes and functions.\n"; + errors = true; + } + } + + Py_DECREF(mod); + } + PyGILState_Release(gil); + log.trim(); return errors; } diff --git a/renderdoc/api/replay/replay_enums.h b/renderdoc/api/replay/replay_enums.h index 40292c4d6..6a6c991a7 100644 --- a/renderdoc/api/replay/replay_enums.h +++ b/renderdoc/api/replay/replay_enums.h @@ -469,7 +469,29 @@ enum class AddressMode : uint32_t DECLARE_REFLECTION_ENUM(AddressMode); -enum YcbcrConversion +DOCUMENT(R"(The color model conversion that a YCbCr sampler uses to convert from YCbCr to RGB. + +.. data:: Raw + + The input values are not converted at all. + +.. data:: RangeOnly + + There is no model conversion but the inputs are range expanded as for YCbCr. + +.. data:: BT709 + + The conversion uses the BT.709 color model conversion. + +.. data:: BT601 + + The conversion uses the BT.601 color model conversion. + +.. data:: BT2020 + + The conversion uses the BT.2020 color model conversion. +)"); +enum class YcbcrConversion { Raw, RangeOnly, @@ -480,7 +502,18 @@ enum YcbcrConversion DECLARE_REFLECTION_ENUM(YcbcrConversion); -enum YcbcrRange +DOCUMENT(R"(Specifies the range of encoded values and their interpretation. + +.. data:: ITUFull + + The full range of input values are valid and interpreted according to ITU "full range" rules. + +.. data:: ITUNarrow + + A head and foot are reserved in the encoded values, and the remaining values are expanded + according to "narrow range" rules. +)"); +enum class YcbcrRange { ITUFull, ITUNarrow, @@ -488,7 +521,18 @@ enum YcbcrRange DECLARE_REFLECTION_ENUM(YcbcrRange); -enum ChromaSampleLocation +DOCUMENT(R"(Determines where in the pixel downsampled chrome samples are positioned. + +.. data:: CositedEven + + The chroma samples are positioned exactly in the same place as the even luma co-ordinates. + +.. data:: Midpoint + + The chrome samples are positioned half way between each even luma sample and the next highest odd + luma sample. +)"); +enum class ChromaSampleLocation { CositedEven, Midpoint,