Skip to content

Commit

Permalink
Merge branch 'dev-3.0.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
kyaoNV committed Jul 10, 2018
2 parents cc62b5b + e672342 commit 94456e5
Show file tree
Hide file tree
Showing 21 changed files with 715 additions and 115 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
v3.0.5
------
- Added support for exporting BMP and TGA images.
- Added `ConstantBuffer::renderUI()` to automatically render UI for editing a constant buffer's values.

Bug Fixes:
- Fixed crash when setting ForwardRenderer sample to MSAA with sample count 1
- std::string version of Gui::addTextBox() now correctly updates the user's string
- Fixed row-pitch calculation when copying texture subresources in DX12

v3.0.4
------
- Updated Slang to 0.10.24
Expand Down
2 changes: 2 additions & 0 deletions Framework/Source/API/ConstantBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
#include "Graphics/Program/ProgramReflection.h"
#include "API/Device.h"

#include "Renderer.h"

namespace Falcor
{
ConstantBuffer::~ConstantBuffer() = default;
Expand Down
5 changes: 3 additions & 2 deletions Framework/Source/API/ConstantBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,9 @@ namespace Falcor
virtual bool uploadToGPU(size_t offset = 0, size_t size = -1) override;

ConstantBufferView::SharedPtr getCbv() const;
protected:

private:
ConstantBuffer(const std::string& name, const ReflectionResourceType::SharedConstPtr& pReflectionType, size_t size);
mutable ConstantBufferView::SharedPtr mpCbv;
};
}
}
2 changes: 1 addition & 1 deletion Framework/Source/API/D3D12/D3D12CopyContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ namespace Falcor
footprint[0].Footprint.Width = (size.x == -1) ? pTexture->getWidth(mipLevel) - offset.x : size.x;
footprint[0].Footprint.Height = (size.y == -1) ? pTexture->getHeight(mipLevel) - offset.y : size.y;
footprint[0].Footprint.Depth = (size.z == -1) ? pTexture->getDepth(mipLevel) - offset.z : size.z;
footprint[0].Footprint.RowPitch = footprint[0].Footprint.Width * getFormatBytesPerBlock(pTexture->getFormat());
footprint[0].Footprint.RowPitch = align_to(D3D12_TEXTURE_DATA_PITCH_ALIGNMENT, footprint[0].Footprint.Width * getFormatBytesPerBlock(pTexture->getFormat()));
rowCount[0] = footprint[0].Footprint.Height;
rowSize[0] = footprint[0].Footprint.RowPitch;
bufferSize = rowSize[0] * rowCount[0] * footprint[0].Footprint.Depth;
Expand Down
7 changes: 7 additions & 0 deletions Framework/Source/API/VariablesBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "Texture.h"
#include "Graphics/Program/ProgramReflection.h"
#include "API/Device.h"
#include "Utils/VariablesBufferUI.h"
#include <cstring>

namespace Falcor
Expand Down Expand Up @@ -393,4 +394,10 @@ namespace Falcor
std::memcpy(mData.data() + offset, pSrc, size);
mDirty = true;
}

void VariablesBuffer::renderUI(Gui* pGui, const char* uiGroup)
{
VariablesBufferUI variablesBufferUI(*this);
variablesBufferUI.renderUI(pGui, uiGroup);
}
}
11 changes: 11 additions & 0 deletions Framework/Source/API/VariablesBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
namespace Falcor
{
class Sampler;
// Forward declares for gui draw func
class Gui;

/** Manages shader buffers containing named data, such as Constant/Uniform Buffers and Structured Buffers.
When accessing a variable by name, you can only use a name which points to a basic Type, or an array of basic Type (so if you want the start of a structure, ask for the first field in the struct).
Expand Down Expand Up @@ -80,6 +82,15 @@ namespace Falcor

size_t getElementSize() const { return mElementSize; }

/** Renders ui for reflected data within the buffer.
\param[in] pGui Pointer to the GUI structure for rendering
\param[in] uiGroup optional label for GUI
*/
void renderUI(Gui* pGui, const char* uiGroup);

// Allows UI functions to look through reflection data
friend class VariablesBufferUI;

protected:
template<typename T>
void setVariable(const std::string& name, size_t elementIndex, const T& value);
Expand Down
2 changes: 1 addition & 1 deletion Framework/Source/ArgList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ namespace Falcor
{
return mMap.at(key);
}
catch(std::out_of_range)
catch(const std::out_of_range&)
{
return std::vector<ArgList::Arg>();
}
Expand Down
4 changes: 2 additions & 2 deletions Framework/Source/Falcor.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,5 +160,5 @@
#define FALCOR_MAJOR_VERSION 3
#define FALCOR_MINOR_VERSION 0
#define FALCOR_DEV_STAGE ""
#define FALCOR_DEV_REVISION 4
#define FALCOR_VERSION_STRING "3.0.4"
#define FALCOR_DEV_REVISION 5
#define FALCOR_VERSION_STRING "3.0.5"
2 changes: 2 additions & 0 deletions Framework/Source/Falcor.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,7 @@
<ClCompile Include="Utils\Psychophysics\SingleThresholdMeasurement.cpp" />
<ClCompile Include="Utils\PythonEmbedding.cpp" />
<ClCompile Include="Utils\TextRenderer.cpp" />
<ClCompile Include="Utils\VariablesBufferUI.cpp" />
<ClCompile Include="Utils\Video\VideoDecoder.cpp" />
<ClCompile Include="Utils\Video\VideoEncoder.cpp" />
<ClCompile Include="Utils\Video\VideoEncoderUI.cpp" />
Expand Down Expand Up @@ -1122,6 +1123,7 @@
<ClInclude Include="Utils\TextRenderer.h" />
<ClInclude Include="Utils\ThreadPool.h" />
<ClInclude Include="Utils\UserInput.h" />
<ClInclude Include="Utils\VariablesBufferUI.h" />
<ClInclude Include="Utils\Video\VideoDecoder.h" />
<ClInclude Include="Utils\Video\VideoEncoder.h" />
<ClInclude Include="Utils\Video\VideoEncoderUI.h" />
Expand Down
6 changes: 6 additions & 0 deletions Framework/Source/Falcor.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,9 @@
<ClCompile Include="Effects\FXAA\FXAA.cpp">
<Filter>Effects\FXAA</Filter>
</ClCompile>
<ClCompile Include="Utils\VariablesBufferUI.cpp">
<Filter>Utils</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Graphics\Model\Animation.h">
Expand Down Expand Up @@ -1693,6 +1696,9 @@
<ClInclude Include="Effects\FXAA\FXAA.h">
<Filter>Effects\FXAA</Filter>
</ClInclude>
<ClInclude Include="Utils\VariablesBufferUI.h">
<Filter>Utils</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Filter Include="Externals">
Expand Down
2 changes: 2 additions & 0 deletions Framework/Source/Framework.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ using namespace glm;
#define safe_delete(_a) {delete _a; _a = nullptr;}
#define safe_delete_array(_a) {delete[] _a; _a = nullptr;}
#define align_to(_alignment, _val) (((_val + _alignment - 1) / _alignment) * _alignment)
#define concat_strings_(a, b) a##b
#define concat_strings(a, b) concat_strings_(a, b)

#if defined(_MSC_VER)
#define FALCOR_DEPRECATED(MESSAGE) __declspec(deprecated(MESSAGE))
Expand Down
111 changes: 71 additions & 40 deletions Framework/Source/Utils/Bitmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "Utils/Platform/OS.h"
#include "API/Device.h"
#include <cstring>
#include "StringUtils.h"

namespace Falcor
{
Expand Down Expand Up @@ -163,14 +164,18 @@ namespace Falcor
return FIF_PNG;
case Bitmap::FileFormat::JpegFile:
return FIF_JPEG;
case Bitmap::FileFormat::TgaFile:
return FIF_TARGA;
case Bitmap::FileFormat::BmpFile:
return FIF_BMP;
case Bitmap::FileFormat::PfmFile:
return FIF_PFM;
case Bitmap::FileFormat::ExrFile:
return FIF_EXR;
default:
should_not_get_here();
}
return FIF_PNG;
return FIF_PNG;
}

static FREE_IMAGE_TYPE getImageType(uint32_t bytesPerPixel)
Expand Down Expand Up @@ -224,45 +229,7 @@ namespace Falcor
}
}

if (fileFormat == Bitmap::FileFormat::PngFile)
{
pImage = FreeImage_ConvertFromRawBits((BYTE*)pData, width, height, bytesPerPixel * width, bytesPerPixel * 8, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK, isTopDown);
if(is_set(exportFlags, ExportFlags::ExportAlpha) == false)
{
auto pTemp = pImage;
pImage = FreeImage_ConvertTo24Bits(pImage);
FreeImage_Unload(pTemp);
}
flags = PNG_Z_BEST_COMPRESSION;

if(is_set(exportFlags, ExportFlags::Uncompressed))
{
flags = PNG_Z_NO_COMPRESSION;
}

if(is_set(exportFlags, ExportFlags::Lossy))
{
logError("Bitmap::saveImage: PNG does not support lossy compression mode.");
return;
}
}
else if (fileFormat == Bitmap::FileFormat::JpegFile)
{
FIBITMAP* pTemp = FreeImage_ConvertFromRawBits((BYTE*)pData, width, height, bytesPerPixel * width, bytesPerPixel * 8, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK, isTopDown);
pImage = FreeImage_ConvertTo24Bits(pTemp);
FreeImage_Unload(pTemp);
if(is_set(exportFlags, ExportFlags::Lossy) == false || is_set(exportFlags, ExportFlags::Uncompressed))
{
flags = JPEG_QUALITYSUPERB | JPEG_SUBSAMPLING_444;
}

if(is_set(exportFlags, ExportFlags::ExportAlpha))
{
logError("Bitmap::saveImage: JPEG does not support alpha channel.");
return;
}
}
else if (fileFormat == Bitmap::FileFormat::PfmFile || fileFormat == Bitmap::FileFormat::ExrFile)
if (fileFormat == Bitmap::FileFormat::PfmFile || fileFormat == Bitmap::FileFormat::ExrFile)
{
if(bytesPerPixel != 16 && bytesPerPixel != 12)
{
Expand Down Expand Up @@ -330,6 +297,70 @@ namespace Falcor
}
}
}
else
{
FIBITMAP* pTemp = FreeImage_ConvertFromRawBits((BYTE*)pData, width, height, bytesPerPixel * width, bytesPerPixel * 8, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK, isTopDown);
if(is_set(exportFlags, ExportFlags::ExportAlpha) == false || fileFormat == Bitmap::FileFormat::JpegFile)
{
pImage = FreeImage_ConvertTo24Bits(pTemp);
FreeImage_Unload(pTemp);
}
else
{
pImage = pTemp;
}

std::vector<std::string> warnings;
switch(fileFormat)
{
case FileFormat::JpegFile:
if (is_set(exportFlags, ExportFlags::Lossy) == false || is_set(exportFlags, ExportFlags::Uncompressed))
{
flags = JPEG_QUALITYSUPERB | JPEG_SUBSAMPLING_444;
}
if (is_set(exportFlags, ExportFlags::ExportAlpha))
{
warnings.push_back("JPEG format does not support alpha channel.");
}
break;

// Lossless formats
case FileFormat::PngFile:
flags = is_set(exportFlags, ExportFlags::Uncompressed) ? PNG_Z_NO_COMPRESSION : PNG_Z_BEST_COMPRESSION;

if (is_set(exportFlags, ExportFlags::Lossy))
{
warnings.push_back("PNG format does not support lossy compression mode.");
}
break;

case FileFormat::TgaFile:
if (is_set(exportFlags, ExportFlags::Lossy))
{
warnings.push_back("TGA format does not support lossy compression mode.");
}
break;

case FileFormat::BmpFile:
if (is_set(exportFlags, ExportFlags::Lossy))
{
warnings.push_back("BMP format does not support lossy compression mode.");
}
if (is_set(exportFlags, ExportFlags::ExportAlpha))
{
warnings.push_back("BMP format does not support alpha channel.");
}
break;

default:
should_not_get_here();
}

if(warnings.empty() == false)
{
logWarning("Bitmap::saveImage: " + joinStrings(warnings, " "));
}
}

FreeImage_Save(toFreeImageFormat(fileFormat), pImage, filename.c_str(), flags);
FreeImage_Unload(pImage);
Expand Down
2 changes: 2 additions & 0 deletions Framework/Source/Utils/Bitmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ namespace Falcor
{
PngFile, //< PNG file for lossless compressed 8-bits images with optional alpha
JpegFile, //< JPEG file for lossy compressed 8-bits images without alpha
TgaFile, //< TGA file for lossless uncompressed 8-bits images with optional alpha
BmpFile, //< BMP file for lossless uncompressed 8-bits images with optional alpha
PfmFile, //< PFM file for floating point HDR images with 32-bit float per channel
ExrFile, //< EXR file for floating point HDR images with 16-bit float per channel
};
Expand Down
Loading

0 comments on commit 94456e5

Please sign in to comment.