Merge branch 'master' of github.com:Dynamitos/Seele
This commit is contained in:
+1
-1
@@ -5,7 +5,7 @@
|
||||
"buildCommandArgs": "",
|
||||
"ctestCommandArgs": "",
|
||||
"configurationType": "Debug",
|
||||
"generator": "Ninja Multi-Config",
|
||||
"generator": "Ninja",
|
||||
"intelliSenseMode": "windows-msvc-x64",
|
||||
"inheritEnvironments": [ "msvc_x64" ],
|
||||
"cmakeCommandArgs": "-DCMAKE_DEBUG_POSTFIX=\"\" -DCMAKE_PLATFORM=x64",
|
||||
|
||||
Binary file not shown.
+18
-18
@@ -1,23 +1,5 @@
|
||||
import Common;
|
||||
|
||||
struct GlyphInstanceData
|
||||
{
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
float width;
|
||||
float height;
|
||||
uint glyphIndex;
|
||||
};
|
||||
|
||||
struct TextData
|
||||
{
|
||||
StructuredBuffer<GlyphInstanceData> glyphs;
|
||||
SamplerState glyphSampler;
|
||||
Texture2D<float> glyphTextures[];
|
||||
};
|
||||
ParameterBlock<TextData> pText;
|
||||
|
||||
struct VertexInput
|
||||
{
|
||||
uint vertexId : SV_VertexID;
|
||||
@@ -31,6 +13,24 @@ struct VertexOutput
|
||||
uint glyphIndex : GLYPHINDEX;
|
||||
};
|
||||
|
||||
struct GlyphInstanceData
|
||||
{
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
float width;
|
||||
float height;
|
||||
uint glyphIndex;
|
||||
};
|
||||
struct TextData
|
||||
{
|
||||
StructuredBuffer<GlyphInstanceData> glyphs;
|
||||
SamplerState glyphSampler;
|
||||
Texture2D<float> glyphTextures[];
|
||||
};
|
||||
ParameterBlock<TextData> pText;
|
||||
|
||||
|
||||
[shader("vertex")]
|
||||
VertexOutput vertexMain(VertexInput input)
|
||||
{
|
||||
|
||||
@@ -70,6 +70,10 @@ struct LightEnv
|
||||
layout(set=3)
|
||||
ParameterBlock<LightEnv> pLightEnv;
|
||||
|
||||
[Differentiable]
|
||||
float polynomial(float a, float b, float c, float x) {
|
||||
return a * x * x + b * x + c;
|
||||
}
|
||||
|
||||
interface IBRDF
|
||||
{
|
||||
|
||||
@@ -205,6 +205,5 @@ void EnvironmentLoader::import(EnvironmentImportArgs args, PEnvironmentMapAsset
|
||||
|
||||
asset->skybox = std::move(cubeMap);
|
||||
asset->irradianceMap = std::move(convolutedMap);
|
||||
asset->specularMap = std::move(cubeMap);
|
||||
graphics->waitDeviceIdle();
|
||||
}
|
||||
|
||||
+6
-2
@@ -1,10 +1,10 @@
|
||||
#include "Asset/AssetImporter.h"
|
||||
#include "Asset/AssetRegistry.h"
|
||||
#include "Asset/EnvironmentLoader.h"
|
||||
#include "Asset/FontLoader.h"
|
||||
#include "Asset/MaterialLoader.h"
|
||||
#include "Asset/MeshLoader.h"
|
||||
#include "Asset/TextureLoader.h"
|
||||
#include "Asset/EnvironmentLoader.h"
|
||||
#include "Graphics/Initializer.h"
|
||||
#ifdef __APPLE__
|
||||
#include "Graphics/Metal/Graphics.h"
|
||||
@@ -50,7 +50,11 @@ int main() {
|
||||
AssetImporter::importEnvironmentMap(EnvironmentImportArgs{
|
||||
.filePath = sourcePath / "import" / "textures" / "newport_loft.hdr",
|
||||
});
|
||||
|
||||
AssetImporter::importTexture(TextureImportArgs{
|
||||
.filePath = sourcePath / "import" / "textures" / "grass_block_side.png",
|
||||
.importPath = "",
|
||||
});
|
||||
|
||||
getThreadPool().waitIdle();
|
||||
vd->commitMeshes();
|
||||
WindowCreateInfo mainWindowInfo = {
|
||||
|
||||
@@ -61,13 +61,15 @@ template <typename KeyType, typename NodeData, typename KeyFun, typename Compare
|
||||
constexpr IteratorBase& operator++() {
|
||||
// if current node has no right subtree
|
||||
if (node->rightChild == nullptr) {
|
||||
Node* temp = node;
|
||||
node = node->parent;
|
||||
// walk up hierarchy until we were the left subtree of any parent
|
||||
// this means that that parent is the correct next element
|
||||
while (node->rightChild == temp) {
|
||||
temp = node;
|
||||
if (node->parent != nullptr) {
|
||||
Node* temp = node;
|
||||
node = node->parent;
|
||||
// walk up hierarchy until we were the left subtree of any parent
|
||||
// this means that that parent is the correct next element
|
||||
while (node->rightChild == temp) {
|
||||
temp = node;
|
||||
node = node->parent;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// if there is a right subtree, descend there
|
||||
@@ -153,6 +155,7 @@ template <typename KeyType, typename NodeData, typename KeyFun, typename Compare
|
||||
constexpr Tree(Tree&& other) noexcept
|
||||
: alloc(std::move(other.alloc)), root(std::move(other.root)), pseudoRoot(std::move(other.pseudoRoot)), iteratorsDirty(true),
|
||||
_size(std::move(other._size)), comp(std::move(other.comp)) {
|
||||
pseudoRoot.setLeftChild(root);
|
||||
other._size = 0;
|
||||
}
|
||||
constexpr ~Tree() noexcept { clear(); }
|
||||
@@ -165,6 +168,7 @@ template <typename KeyType, typename NodeData, typename KeyFun, typename Compare
|
||||
for (const auto& elem : other) {
|
||||
insert(elem);
|
||||
}
|
||||
pseudoRoot.setLeftChild(root);
|
||||
markIteratorsDirty();
|
||||
}
|
||||
return *this;
|
||||
@@ -180,6 +184,7 @@ template <typename KeyType, typename NodeData, typename KeyFun, typename Compare
|
||||
_size = std::move(other._size);
|
||||
comp = std::move(other.comp);
|
||||
other._size = 0;
|
||||
pseudoRoot.setLeftChild(root);
|
||||
markIteratorsDirty();
|
||||
}
|
||||
return *this;
|
||||
|
||||
@@ -25,7 +25,6 @@ RenderPass::RenderPass(PGraphics graphics, Gfx::RenderTargetLayout _layout, Arra
|
||||
desc->setStoreAction(cast(color.getStoreOp()));
|
||||
desc->setLevel(0);
|
||||
if (!layout.resolveAttachments.empty()) {
|
||||
const auto& resolve = layout.resolveAttachments[i];
|
||||
desc->setResolveLevel(0);
|
||||
// store multisampled attachment as well
|
||||
if(color.getStoreOp() == Gfx::SE_ATTACHMENT_STORE_OP_STORE) {
|
||||
@@ -33,7 +32,6 @@ RenderPass::RenderPass(PGraphics graphics, Gfx::RenderTargetLayout _layout, Arra
|
||||
} else {
|
||||
desc->setStoreAction(MTL::StoreActionMultisampleResolve);
|
||||
}
|
||||
desc->setResolveTexture(resolve.getTexture().cast<TextureBase>()->getImage());
|
||||
}
|
||||
}
|
||||
if (layout.depthAttachment.getTexture() != nullptr) {
|
||||
@@ -49,7 +47,6 @@ RenderPass::RenderPass(PGraphics graphics, Gfx::RenderTargetLayout _layout, Arra
|
||||
} else {
|
||||
depth->setStoreAction(MTL::StoreActionMultisampleResolve);
|
||||
}
|
||||
depth->setResolveTexture(layout.depthResolveAttachment.getTexture().cast<TextureBase>()->getImage());
|
||||
}
|
||||
}
|
||||
// TODO: stencil
|
||||
@@ -61,9 +58,16 @@ void RenderPass::updateRenderPass() {
|
||||
const auto& color = layout.colorAttachments[i];
|
||||
auto desc = renderPass->colorAttachments()->object(i);
|
||||
desc->setTexture(color.getTexture().cast<TextureBase>()->getImage());
|
||||
if (!layout.resolveAttachments.empty()) {
|
||||
const auto& resolve = layout.resolveAttachments[i];
|
||||
desc->setResolveTexture(resolve.getTexture().cast<TextureBase>()->getImage());
|
||||
}
|
||||
}
|
||||
if (layout.depthAttachment.getTexture() != nullptr) {
|
||||
auto depth = renderPass->depthAttachment();
|
||||
depth->setTexture(layout.depthAttachment.getTexture().cast<TextureBase>()->getImage());
|
||||
if (layout.depthResolveAttachment.getTexture() != nullptr) {
|
||||
depth->setResolveTexture(layout.depthResolveAttachment.getTexture().cast<TextureBase>()->getImage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,6 +52,7 @@ class Window : public Gfx::Window {
|
||||
CA::MetalLayer* metalLayer;
|
||||
CA::MetalDrawable* drawable;
|
||||
OTexture2D backBuffer;
|
||||
OEvent renderDoneSemaphore;
|
||||
|
||||
std::function<void(KeyCode, InputAction, KeyModifier)> keyCallback;
|
||||
std::function<void(double, double)> mouseMoveCallback;
|
||||
|
||||
@@ -92,9 +92,6 @@ Window::Window(PGraphics graphics, const WindowCreateInfo& createInfo) : graphic
|
||||
[[metalWindow contentView] setLayer:(__bridge id)metalLayer];
|
||||
[[metalWindow contentView] setWantsLayer:YES];
|
||||
framebufferFormat = Gfx::SE_FORMAT_B8G8R8A8_SRGB;
|
||||
|
||||
drawable = metalLayer->nextDrawable();
|
||||
createBackBuffer();
|
||||
}
|
||||
|
||||
Window::~Window() { glfwDestroyWindow(static_cast<GLFWwindow*>(windowHandle)); }
|
||||
@@ -104,6 +101,8 @@ void Window::show() { glfwShowWindow(windowHandle); }
|
||||
void Window::pollInput() { glfwPollEvents(); }
|
||||
|
||||
void Window::beginFrame() {
|
||||
drawable = metalLayer->nextDrawable();
|
||||
createBackBuffer();
|
||||
static double start = glfwGetTime();
|
||||
double end = glfwGetTime();
|
||||
currentFrameDelta = end - start;
|
||||
@@ -112,13 +111,10 @@ void Window::beginFrame() {
|
||||
}
|
||||
|
||||
void Window::endFrame() {
|
||||
graphics->waitDeviceIdle();
|
||||
graphics->getQueue()->getCommands()->present(drawable);
|
||||
graphics->getQueue()->submitCommands();
|
||||
graphics->getQueue()->getCommands()->present(drawable);
|
||||
currentFrameIndex++;
|
||||
drawable->release();
|
||||
drawable = metalLayer->nextDrawable();
|
||||
createBackBuffer();
|
||||
}
|
||||
|
||||
void Window::onWindowCloseEvent() {}
|
||||
@@ -181,6 +177,7 @@ void Window::createBackBuffer() {
|
||||
.samples = static_cast<uint32>(buf->sampleCount()),
|
||||
},
|
||||
buf);
|
||||
renderDoneSemaphore = new Event(graphics);
|
||||
}
|
||||
|
||||
Viewport::Viewport(PWindow owner, const ViewportCreateInfo& createInfo) : Gfx::Viewport(owner, createInfo) {
|
||||
|
||||
@@ -79,8 +79,8 @@ BasePass::BasePass(Gfx::PGraphics graphics, PScene scene) : RenderPass(graphics)
|
||||
});
|
||||
}
|
||||
skybox = Seele::Component::Skybox{
|
||||
.day = scene->getLightEnvironment()->getEnvironmentMap()->getIrradianceMap(),
|
||||
.night = scene->getLightEnvironment()->getEnvironmentMap()->getIrradianceMap(),
|
||||
.day = scene->getLightEnvironment()->getEnvironmentMap()->getSkybox(),
|
||||
.night = scene->getLightEnvironment()->getEnvironmentMap()->getSkybox(),
|
||||
.fogColor = Vector(0.1, 0.1, 0.8),
|
||||
.blendFactor = 0,
|
||||
};
|
||||
@@ -157,8 +157,7 @@ void BasePass::render() {
|
||||
vertexData->getInstanceDataSet()->updateBuffer(VertexData::CULLINGDATA_NAME, 0, cullingBuffer);
|
||||
vertexData->getInstanceDataSet()->writeChanges();
|
||||
permutation.setVertexData(vertexData->getTypeName());
|
||||
const auto& materials = vertexData->getMaterialData();
|
||||
for (const auto& materialData : materials) {
|
||||
for (const auto& materialData : vertexData->getMaterialData()) {
|
||||
// material not used for any active meshes, skip
|
||||
if (materialData.instances.size() == 0)
|
||||
continue;
|
||||
|
||||
@@ -139,11 +139,9 @@ void Seele::beginCompilation(const ShaderCompilationInfo& info, SlangCompileTarg
|
||||
|
||||
slang::ProgramLayout* signature = specializedComponent->getLayout(0, diagnostics.writeRef());
|
||||
CHECK_DIAGNOSTICS();
|
||||
//std::cout << info.name << std::endl;
|
||||
for (uint32 i = 0; i < signature->getParameterCount(); ++i) {
|
||||
auto param = signature->getParameterByIndex(i);
|
||||
layout->addMapping(param->getName(), param->getBindingIndex());
|
||||
//std::cout << param->getName() << ": " << param->getBindingIndex() << std::endl;
|
||||
}
|
||||
|
||||
// workaround
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#include "Math/Math.h"
|
||||
#include "MinimalEngine.h"
|
||||
|
||||
|
||||
namespace Seele {
|
||||
enum class ExpressionType {
|
||||
UNKNOWN,
|
||||
@@ -184,6 +183,9 @@ struct SwizzleExpression : public ShaderExpression {
|
||||
StaticArray<int32, 4> comp = {-1, -1, -1, -1};
|
||||
SwizzleExpression() {}
|
||||
SwizzleExpression(StaticArray<int32, 4> comp) : comp(std::move(comp)) {}
|
||||
SwizzleExpression(std::string key, std::string target, StaticArray<int32, 4> comp) : ShaderExpression(key) {
|
||||
inputs["target"].source = target;
|
||||
}
|
||||
virtual ~SwizzleExpression() {}
|
||||
virtual uint64 getIdentifier() const override { return IDENTIFIER; }
|
||||
virtual std::string evaluate(Map<std::string, std::string>& varState) const override;
|
||||
@@ -194,6 +196,11 @@ DEFINE_REF(SwizzleExpression)
|
||||
struct SampleExpression : public ShaderExpression {
|
||||
static constexpr uint64 IDENTIFIER = 0x16;
|
||||
SampleExpression() {}
|
||||
SampleExpression(std::string key, std::string texture, std::string sampler, std::string texCoords) : ShaderExpression(key) {
|
||||
inputs["texture"].source = texture;
|
||||
inputs["sampler"].source = sampler;
|
||||
inputs["texCoords"].source = texCoords;
|
||||
}
|
||||
virtual ~SampleExpression() {}
|
||||
virtual uint64 getIdentifier() const override { return IDENTIFIER; }
|
||||
virtual std::string evaluate(Map<std::string, std::string>& varState) const override;
|
||||
@@ -205,8 +212,6 @@ DEFINE_REF(SampleExpression)
|
||||
struct MaterialNode {
|
||||
std::string profile;
|
||||
Map<std::string, std::string> variables;
|
||||
MaterialNode() {}
|
||||
~MaterialNode() {}
|
||||
void save(ArchiveBuffer& buffer) const;
|
||||
void load(ArchiveBuffer& buffer);
|
||||
};
|
||||
|
||||
@@ -9,7 +9,8 @@ MeshUpdater::MeshUpdater(PScene scene) : ComponentSystem<Component::Transform, C
|
||||
|
||||
MeshUpdater::~MeshUpdater() {}
|
||||
|
||||
void MeshUpdater::update(entt::entity, Component::Transform& transform, Component::Mesh& comp) {
|
||||
void MeshUpdater::update(entt::entity id, Component::Transform& transform, Component::Mesh& comp) {
|
||||
scene->accessComponent<Component::Camera>(id);
|
||||
if (comp.meshletOffsets.empty()) {
|
||||
for (uint32 i = 0; i < comp.asset->meshes.size(); ++i) {
|
||||
comp.meshletOffsets.add(comp.asset->meshes[i]->vertexData->addCullingMapping(comp.asset->meshes[i]->id));
|
||||
|
||||
@@ -16,3 +16,11 @@ print(positions)
|
||||
print(indices)
|
||||
|
||||
|
||||
# Create a tensor with attached grads from a numpy array
|
||||
# Note: We pass zero=True to initialize the grads to zero on allocation
|
||||
x = spy.Tensor.numpy(device, np.array([1, 2, 3, 4], dtype=np.float32)).with_grads(zero=True)
|
||||
|
||||
# Evaluate the polynomial and ask for a tensor back
|
||||
# Expecting result = 2x^2 + 8x - 1
|
||||
result: spy.Tensor = module.polynomial(a=2, b=8, c=-1, x=x, _result='tensor')
|
||||
print(result.to_numpy())
|
||||
Reference in New Issue
Block a user