-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f11e5cb
commit e064cb8
Showing
20 changed files
with
2,429 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* Copyright (C) 2016 The Android Open Source Project | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include "LTC.h" | ||
|
||
#include "details/Engine.h" | ||
#include "details/Texture.h" | ||
|
||
namespace filament { | ||
|
||
#include "ltc.inc" | ||
|
||
void LTC::init(FEngine& engine) noexcept { | ||
constexpr size_t fp16Count = LTC_LUT_SIZE * LTC_LUT_SIZE * 4; | ||
constexpr size_t byteCount = fp16Count * sizeof(uint16_t); | ||
|
||
static_assert(sizeof(LTC_LUT_1) == byteCount, "LTC_LUT_SIZE doesn't match size of the LTC LUT 1"); | ||
|
||
Texture* lut1 = Texture::Builder() | ||
.width(LTC_LUT_SIZE) | ||
.height(LTC_LUT_SIZE) | ||
.format(backend::TextureFormat::RGBA16F) | ||
.build(engine); | ||
|
||
Texture::PixelBufferDescriptor buffer1(LTC_LUT_1, byteCount, | ||
Texture::Format::RGBA, Texture::Type::HALF); | ||
|
||
lut1->setImage(engine, 0, std::move(buffer1)); | ||
|
||
mLUT1 = downcast(lut1); | ||
|
||
static_assert(sizeof(LTC_LUT_2) == byteCount, "LTC_LUT_SIZE doesn't match size of the LTC LUT 2"); | ||
|
||
Texture* ltc2 = Texture::Builder() | ||
.width(LTC_LUT_SIZE) | ||
.height(LTC_LUT_SIZE) | ||
.format(backend::TextureFormat::RGBA16F) | ||
.build(engine); | ||
|
||
Texture::PixelBufferDescriptor buffer2(LTC_LUT_2, byteCount, | ||
Texture::Format::RGBA, Texture::Type::HALF); | ||
|
||
ltc2->setImage(engine, 0, std::move(buffer2)); | ||
|
||
mLUT2 = downcast(ltc2); | ||
} | ||
|
||
void LTC::terminate(FEngine& engine) noexcept { | ||
if (mLUT1) { | ||
engine.destroy(mLUT1); | ||
} | ||
|
||
if (mLUT2) { | ||
engine.destroy(mLUT2); | ||
} | ||
} | ||
|
||
} // namespace filament |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* Copyright (C) 2016 The Android Open Source Project | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#ifndef TNT_FILAMENT_DETAILS_LTC_H | ||
#define TNT_FILAMENT_DETAILS_LTC_H | ||
|
||
#include <backend/Handle.h> | ||
|
||
#include "details/Texture.h" | ||
|
||
#include <utils/compiler.h> | ||
|
||
namespace filament { | ||
|
||
class FEngine; | ||
|
||
#define FILAMENT_LTC_LUT_SIZE 64 | ||
|
||
class LTC { | ||
public: | ||
explicit LTC() noexcept = default; | ||
|
||
LTC(LTC const& rhs) = delete; | ||
LTC(LTC&& rhs) = delete; | ||
LTC& operator=(LTC const& rhs) = delete; | ||
LTC& operator=(LTC&& rhs) = delete; | ||
|
||
void init(FEngine& engine) noexcept; | ||
|
||
size_t getLutSize() const noexcept { | ||
return LTC_LUT_SIZE; | ||
} | ||
|
||
bool isValid() const noexcept { | ||
return mLUT1 != nullptr && mLUT2 != nullptr; | ||
} | ||
|
||
backend::Handle<backend::HwTexture> getTexture1() const noexcept { | ||
return mLUT1->getHwHandle(); | ||
} | ||
|
||
backend::Handle<backend::HwTexture> getTexture2() const noexcept { | ||
return mLUT2->getHwHandle(); | ||
} | ||
|
||
void terminate(FEngine& engine) noexcept; | ||
|
||
private: | ||
FTexture* mLUT1 = nullptr; | ||
FTexture* mLUT2 = nullptr; | ||
|
||
static constexpr size_t LTC_LUT_SIZE = FILAMENT_LTC_LUT_SIZE; | ||
|
||
static const uint16_t LTC_LUT_1[]; | ||
static const uint16_t LTC_LUT_2[]; | ||
}; | ||
|
||
} // namespace filament | ||
|
||
#endif // TNT_FILAMENT_DETAILS_LTC_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.