gboisse / gfx Goto Github PK
View Code? Open in Web Editor NEWA minimalist and easy to use graphics API.
License: MIT License
A minimalist and easy to use graphics API.
License: MIT License
Please add a functionality to query mouse cursor position.
Is this the right way to create a compute kernel?
program = gfxCreateProgram(gfx, "myCompute");
kernel = gfxCreateComputeKernel(gfx, program, "main");
Host side:
byteBuffer = gfxCreateBuffer<uint32_t>(gfx, (nBytes / sizeof(uint32_t) + 1));
gfxProgramSetParameter(..., .., "byteBufferRW", byteBuffer);
gfxProgramSetParameter(..., .., "byteBuffer", byteBuffer);
Comp Shader:
RWByteAddressBuffer byteBufferRW;
byteBufferRW.Store(idx, value);
ByteAddressBuffer byteBuffer;
loadVal = byteBuffer.Load(idx);
value and loadVal aren't same. Seems like I am creating the byte addressable buffer wrong?
Hi, I would like to update a small buffer from CPU (every frame) and then use it in a compute shader.
I am not sure how to use buffers with kGfxCpuAccess_Write
enabled.
gfx relies a lot on logging to report errors. When developing in Visual Studio or another IDE, we always can read the debug output but when the application is run by Pix or another tool, we can't anymore.
Ensuring a console is always available would be great.
gfx_scene.h
is of great help for loading assets.
Some kind of gfx_frame_graph.h
would help a lot of managing resources and developing/reusing/sharing render techniques (a set of render passes).
Is it possible to extend materials to have kd, ks and shininess loaded from .mtl files? Tinyobjloader already loads these properties, just need support from gfx.
Alternatively, an approximate conversion from non-pbr to pbr would also help. e.g. metallicity = ks / (ks + kd) and roughness = sqrt(sqrt(2 / (2 + shininess))).
Hi,
Is it possible to render large point-clouds?
E.G. 1000 000 points.
Could you please overload gfxClearTexture/BackBuffer
with user specified color value.
gfxProgramSet*() functions should raise an error when parameter names are not found?
Hi, your tool/engine looks great, from https://twitter.com/ocornut/status/1371548539046727680
What are the plans for that tool?
I realize this is still early on, but I tried to create a simple 'hello world' but couldn't render a simple obj cube (and a ImGUI:Button)
Could you help? Here is the code:
#include "gfx_window.h"
#include "gfx_scene.h"
#include "gfx_imgui.h"
int main(int argc, char* argv[])
{
GfxWindow window = gfxCreateWindow(1024, 768, "hello gfx");
GfxContext context = gfxCreateContext(window);
GfxScene scene = gfxCreateScene();
gfxImGuiInitialize(context);
GfxResult res = gfxSceneImport(scene, "cube.obj");
auto cam = gfxSceneCreateCamera(scene);
gfxSceneSetActiveCamera(scene, cam);
while (!gfxWindowIsCloseRequested(window))
{
GfxResult res = gfxWindowPumpEvents(window);
// https://docs.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes
bool key = gfxWindowIsKeyDown(window, 0x42);
if (key) { printf("hi!\n"); }
gfxFrame(context);
gfxImGuiRender();
gfxFinish(context);
}
gfxSceneClear(scene);
gfxDestroyScene(scene);
gfxDestroyContext(context);
gfxDestroyWindow(window);
}
Add to CMakeLists.txt
add_executable(test test.cpp)
target_link_libraries(test gfx)
Hi,
Any chance you are working on a similar library for Vulkan?
Regards,
Sayantan
Instead of the common pattern :
gfxDestroyTexture(gfx_, accumulationDIBuffer);
accumulationDIBuffer = {};
Just doing :
gfxDestroyTexture(gfx_, accumulationDIBuffer);
With :
GfxResult gfxDestroyTexture(GfxContext context, GfxTexture& texture)
{
GfxInternal *gfx = GfxInternal::GetGfx(context);
if(!gfx) return kGfxResult_InvalidParameter;
GfxResult result = gfx->destroyTexture(texture);
texture = {}; // maybe test result ? maybe reset in destroyTexture ?
return result;
}
So, it seems that cgltf
returns nullptr
names on objects that have no valid name, which crashes std::string
as they do not accept nullptr
assignments (which is a really annoying thing if you ask me): c31f5ce (could cause the crash by trying to load the Sponza scene)
This ticket is mostly to track whether you think there's other places where this check should be added?
How? Context creation offers two overloads - one asks for a window handle and the other asks for a D3D device handle. For headless mode, I guess we have to use the second overload using D3D device handle. However, I'm stuck at creating a D3D device.
I need some something simple: like: getMeADevice(int index)
, where index
represents one of the several GPU adapters in the system. Please let me know!
As a side note: I can already decouple rendering resolution from display-frame-buffer resolution using custom render-targets or compute-shaders.
Well, what are my options here?
I don't see a gfxCommandCopyTextureToBuffer(), but I can copy Gpu-Buffers to Cpu memory and access it for processing.
Maybe this is an option - copy texture (gpu) to gpu-buffer with a shader, then copy gpu-buffer to mapped cpu-memory?
Is there a better option?
A common pattern for implementing constant buffer is to share a header between C++ and HLSL :
#ifndef GPU_SHARED_H
#define GPU_SHARED_H
#ifdef __cplusplus
#include <glm/gtx/type_aligned.hpp>
#include <glm/gtx/compatibility.hpp>
typedef uint32_t uint;
typedef glm::ivec2 int2;
typedef glm::ivec4 int4;
typedef glm::uvec2 uint2;
typedef glm::aligned_uvec3 uint3;
typedef glm::uvec4 uint4;
typedef glm::aligned_vec4 float4;
typedef glm::aligned_vec3 float3;
typedef glm::aligned_vec2 float2;
typedef glm::bool3 bool3;
typedef glm::mat4 float4x4;
#endif // __cplusplus
enum MyEnum
{
VALUE1 = 0,
VALUE2
};
struct MyContants
{
float attribute0;
uint attribute1;
uint2 attribute2;
uint attribute3;
uint attribute4;
MyEnum attribute5;
};
#endif // GPU_SHARED_H
These typedef declarations are probably wrong :
float2
and int2
don't match ?bool3
?HLSL contant buffer alignment rules aren't obvious, and we still can't use -not_use_legacy_cbuf_load with DXC.
I propose gfx provide a small set (subset?) of types we can use and arrange freely in constant buffers.
Hi
gfx is support Linux platform or not?
Hi,
I'm trying to do texture mapping using ray-query. Shader side code would look something like this -
myArrayOfTextures[giveMeMaterialIdx(committedInstanceIndex)].Load(uv)
As such, I need to create an array-of-textures. Texture2DArrays aren't helpful as all slices must have the same resolution. Any suggestions or alternatives?
How could we keep some information (filename, line number...) about resources we create for providing more information when reporting leaks?
Hi,
This seems very trivial but I cannot set the value of a define when passing as compiler argument.
For example, how would you pass the following define as a createKernel
argument?
#define MYDEFINE 64
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.