Added args.
This commit is contained in:
parent
a8c1c5f669
commit
6ffdb3e247
4 changed files with 92 additions and 23 deletions
|
@ -112,14 +112,16 @@ static void updateTextureCubeRectBgra8(bgfx::TextureHandle _handle, uint8_t _sid
|
|||
bgfx::updateTextureCube(_handle, _side, 0, _x, _y, _width, _height, mem);
|
||||
}
|
||||
|
||||
int _main_(int /*_argc*/, char** /*_argv*/)
|
||||
int _main_(int _argc, char** _argv)
|
||||
{
|
||||
Args args(_argc, _argv);
|
||||
|
||||
uint32_t width = 1280;
|
||||
uint32_t height = 720;
|
||||
uint32_t debug = BGFX_DEBUG_TEXT;
|
||||
uint32_t reset = BGFX_RESET_VSYNC;
|
||||
|
||||
bgfx::init();
|
||||
bgfx::init(args.m_type, args.m_pciId);
|
||||
bgfx::reset(width, height, reset);
|
||||
|
||||
// Enable debug text.
|
||||
|
@ -149,24 +151,6 @@ int _main_(int /*_argc*/, char** /*_argv*/)
|
|||
loadTexture("texture_compression_ptc24.pvr"),
|
||||
};
|
||||
|
||||
const bgfx::Memory* mem8 = bgfx::alloc(32*32*32);
|
||||
const bgfx::Memory* mem16f = bgfx::alloc(32*32*32*2);
|
||||
const bgfx::Memory* mem32f = bgfx::alloc(32*32*32*4);
|
||||
for (uint8_t zz = 0; zz < 32; ++zz)
|
||||
{
|
||||
for (uint8_t yy = 0; yy < 32; ++yy)
|
||||
{
|
||||
for (uint8_t xx = 0; xx < 32; ++xx)
|
||||
{
|
||||
const uint32_t offset = ( (zz*32+yy)*32+xx);
|
||||
const uint32_t val = xx ^ yy ^ zz;
|
||||
mem8->data[offset] = val<<3;
|
||||
*(uint16_t*)&mem16f->data[offset*2] = bx::halfFromFloat( (float)val/32.0f);
|
||||
*(float*)&mem32f->data[offset*4] = (float)val/32.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const bgfx::Caps* caps = bgfx::getCaps();
|
||||
const bool texture3DSupported = !!(caps->supported & BGFX_CAPS_TEXTURE_3D);
|
||||
const bool blitSupported = !!(caps->supported & BGFX_CAPS_TEXTURE_BLIT);
|
||||
|
@ -176,6 +160,24 @@ int _main_(int /*_argc*/, char** /*_argv*/)
|
|||
|
||||
if (texture3DSupported)
|
||||
{
|
||||
const bgfx::Memory* mem8 = bgfx::alloc(32*32*32);
|
||||
const bgfx::Memory* mem16f = bgfx::alloc(32*32*32*2);
|
||||
const bgfx::Memory* mem32f = bgfx::alloc(32*32*32*4);
|
||||
for (uint8_t zz = 0; zz < 32; ++zz)
|
||||
{
|
||||
for (uint8_t yy = 0; yy < 32; ++yy)
|
||||
{
|
||||
for (uint8_t xx = 0; xx < 32; ++xx)
|
||||
{
|
||||
const uint32_t offset = ( (zz*32+yy)*32+xx);
|
||||
const uint32_t val = xx ^ yy ^ zz;
|
||||
mem8->data[offset] = val<<3;
|
||||
*(uint16_t*)&mem16f->data[offset*2] = bx::halfFromFloat( (float)val/32.0f);
|
||||
*(float*)&mem32f->data[offset*4] = (float)val/32.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (0 != (BGFX_CAPS_FORMAT_TEXTURE_2D & caps->formats[bgfx::TextureFormat::R8]) )
|
||||
{
|
||||
textures3d[numTextures3d++] = bgfx::createTexture3D(32, 32, 32, 0, bgfx::TextureFormat::R8, BGFX_TEXTURE_U_CLAMP|BGFX_TEXTURE_V_CLAMP|BGFX_TEXTURE_W_CLAMP, mem8);
|
||||
|
|
|
@ -141,14 +141,16 @@ inline float square(float _x)
|
|||
|
||||
class HDR : public entry::AppI
|
||||
{
|
||||
void init(int /*_argc*/, char** /*_argv*/) BX_OVERRIDE
|
||||
void init(int _argc, char** _argv) BX_OVERRIDE
|
||||
{
|
||||
Args args(_argc, _argv);
|
||||
|
||||
m_width = 1280;
|
||||
m_height = 720;
|
||||
m_debug = BGFX_DEBUG_TEXT;
|
||||
m_reset = BGFX_RESET_VSYNC;
|
||||
|
||||
bgfx::init();
|
||||
bgfx::init(args.m_type, args.m_pciId);
|
||||
bgfx::reset(m_width, m_height, m_reset);
|
||||
|
||||
// Enable m_debug text.
|
||||
|
|
|
@ -13,8 +13,9 @@
|
|||
namespace stl = tinystl;
|
||||
|
||||
#include <bgfx/bgfx.h>
|
||||
#include <bx/readerwriter.h>
|
||||
#include <bx/commandline.h>
|
||||
#include <bx/fpumath.h>
|
||||
#include <bx/readerwriter.h>
|
||||
#include <bx/string.h>
|
||||
#include "entry/entry.h"
|
||||
#include <ib-compress/indexbufferdecompression.h>
|
||||
|
@ -621,3 +622,59 @@ void meshSubmit(const Mesh* _mesh, const MeshState*const* _state, uint8_t _numPa
|
|||
{
|
||||
_mesh->submit(_state, _numPasses, _mtx, _numMatrices);
|
||||
}
|
||||
|
||||
Args::Args(int _argc, char** _argv)
|
||||
: m_type(bgfx::RendererType::Count)
|
||||
, m_pciId(BGFX_PCI_ID_NONE)
|
||||
{
|
||||
bx::CommandLine cmdLine(_argc, (const char**)_argv);
|
||||
|
||||
if (cmdLine.hasArg("gl") )
|
||||
{
|
||||
m_type = bgfx::RendererType::OpenGL;
|
||||
}
|
||||
else if (cmdLine.hasArg("noop")
|
||||
|| cmdLine.hasArg("vk") )
|
||||
{
|
||||
m_type = bgfx::RendererType::OpenGL;
|
||||
}
|
||||
else if (BX_ENABLED(BX_PLATFORM_WINDOWS) )
|
||||
{
|
||||
if (cmdLine.hasArg("d3d9") )
|
||||
{
|
||||
m_type = bgfx::RendererType::Direct3D9;
|
||||
}
|
||||
else if (cmdLine.hasArg("d3d11") )
|
||||
{
|
||||
m_type = bgfx::RendererType::Direct3D11;
|
||||
}
|
||||
else if (cmdLine.hasArg("d3d12") )
|
||||
{
|
||||
m_type = bgfx::RendererType::Direct3D12;
|
||||
}
|
||||
}
|
||||
else if (BX_ENABLED(BX_PLATFORM_OSX) )
|
||||
{
|
||||
if (cmdLine.hasArg("mtl") )
|
||||
{
|
||||
m_type = bgfx::RendererType::Metal;
|
||||
}
|
||||
}
|
||||
|
||||
if (cmdLine.hasArg("amd") )
|
||||
{
|
||||
m_pciId = BGFX_PCI_ID_AMD;
|
||||
}
|
||||
else if (cmdLine.hasArg("nvidia") )
|
||||
{
|
||||
m_pciId = BGFX_PCI_ID_NVIDIA;
|
||||
}
|
||||
else if (cmdLine.hasArg("intel") )
|
||||
{
|
||||
m_pciId = BGFX_PCI_ID_INTEL;
|
||||
}
|
||||
else if (cmdLine.hasArg("sw") )
|
||||
{
|
||||
m_pciId = BGFX_PCI_ID_SOFTWARE_RASTERIZER;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,4 +43,12 @@ void meshStateDestroy(MeshState* _meshState);
|
|||
void meshSubmit(const Mesh* _mesh, uint8_t _id, bgfx::ProgramHandle _program, const float* _mtx, uint64_t _state = BGFX_STATE_MASK);
|
||||
void meshSubmit(const Mesh* _mesh, const MeshState*const* _state, uint8_t _numPasses, const float* _mtx, uint16_t _numMatrices = 1);
|
||||
|
||||
struct Args
|
||||
{
|
||||
Args(int _argc, char** _argv);
|
||||
|
||||
bgfx::RendererType::Enum m_type;
|
||||
uint16_t m_pciId;
|
||||
};
|
||||
|
||||
#endif // BGFX_UTILS_H_HEADER_GUARD
|
||||
|
|
Reference in a new issue