Giter VIP home page Giter VIP logo

mkxjun / directx11-with-windows-sdk Goto Github PK

View Code? Open in Web Editor NEW
1.5K 45.0 353.0 388.49 MB

现代DX11系列教程:使用Windows SDK(C++)开发Direct3D 11.x

Home Page: https://directx11.tech

License: MIT License

C++ 80.02% C 11.16% HLSL 1.84% CMake 2.10% Batchfile 0.05% Dockerfile 0.01% Python 2.36% JavaScript 0.02% Shell 0.10% Makefile 0.08% M4 0.08% HTML 0.80% Ada 0.35% Assembly 0.54% Pascal 0.22% C# 0.21% DIGITAL Command Language 0.01% Roff 0.01% Inno Setup 0.04% Rust 0.03%
directx11 windows-sdk dx11 visual-studio visual-studio-code cmake win7-11 imgui assimp

directx11-with-windows-sdk's Issues

Cpp端反射生成CBuffer可能存在内存问题

可能存在bug的代码段 EffectHelper.cpp Lines 646~651

某一个Effect中存在两个Shader:Shader1和Shader2
有一个CBuffer内有若干个成员变量,但Shader1只使用了其中的某几个,C++段反射生成的Buffer的buffer size大小并不是完整的CBuffer的大小。(我的情况:CBuffer完整应是576bytes,但Shader1反射生成的Buffer只有560bytes)

而Shader2使用了完整的CBuffer,反射生成的Buffer大小为完整CBuffer大小(我的情况:Shader2反射生成的Buffer为576bytes)。但是因为在m_CBuffers中已经存在BindPoint相同的Buffer,所以Shader2反射生成的Buffer并没有覆盖到m_CBuffers中。

最终我的情况:渲染是没有问题的,但在关闭程序,析构CBufferData中的cbufferData数组(在m_CBuffers[x]中)时,会报内存越界的错误 (error: crt detected that the application wrote to memory after end of heap buffer)。

我的解决方法:

Lines 647
if (it == m_CBuffers.end()) 改成 if (it == m_CBuffers.end() || it->second.cbufferData.size() < cbDesc.Size)

Lines 649
m_CBuffers.emplace(...)
改成
if (!m_CBuffers.emplace(...).second) { m_CBuffers[sibDesc.BindPoint] = CBufferData(...); }

这样改的话对于目前我的项目来说是没有报内存越界的错了。
因为我的水平有限,这样改目前还不知道会不会引起其他问题。
如果有,请回复告知我一下,谢谢。

Win10中交换链效果的替换建议警告

换成VS2019后,以Debug模式打开教程项目,在调试输出窗口会看到以下内容:

DXGI WARNING: IDXGIFactory::CreateSwapChain: Blt-model swap effects (DXGI_SWAP_EFFECT_DISCARD and DXGI_SWAP_EFFECT_SEQUENTIAL) are legacy swap effects that are predominantly superceded by their flip-model counterparts (DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL and DXGI_SWAP_EFFECT_FLIP_DISCARD). Please consider updating your application to leverage flip-model swap effects to benefit from modern presentation enhancements. More information is available at http://aka.ms/dxgiflipmodel. [ MISCELLANEOUS WARNING #294: ]

更换VS2019后出现大量编译警告

由于VS2019新增了 C++ Core Guidelines 检查程序,有了更加细致的语法检查,现在有以下Warning:

  1. 部分类成员未在构造函数初始化(C26495)
  2. 算术溢出(C26450)
  3. 移动拷贝、移动赋值运算符可以使用noexcept(C26439)
  4. WinMain的批注不一致:此实例无批注。(C28251)

....还有很多暂时不列举

目前基本上已经解决,可能还有少数我还没发现的Warning...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.