Feedback on Framework 2016 - Draft

The Partridge Family were neither partridges nor a family. Discuss.
User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Feedback on Framework 2016 - Draft

Post by chili » June 26th, 2016, 6:00 am

Mostly done the new version of the framework for the reboot series (and for the base of the 3D series starting code). I'd like as many of you guys to test it out as possible, hopefully on a bunch of different platforms to see if there are any problems anywhere.

I'm also looking for any feedback you have about the code itself. Anything you think should be added, removed, or changed, I want to hear about it.

Specifically:
  • I remember people saying that there was a problem with the mouse code. If that is still an issue here, I'd like to know.
  • Anything that should be added in terms of functionality of the window class. Right now you can close the window, display a modal messagebox, and get the commandline args.
  • Anything that could be made better with c++11/14 stuff that I'm missing.
I will post a link to the repo on github and a solution zip. Build with VS2015 Community.

https://github.com/planetchili/frame_2016_draft
Attachments
Chili Framework 2016 - Draft.zip
(62.16 KiB) Downloaded 170 times
Chili

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: Feedback on Framework 2016 - Draft

Post by albinopapa » June 26th, 2016, 6:21 pm

Not a huge deal, but your code is a little inconsistent in places.

Code: Select all

DXGI_SWAP_CHAIN_DESC sd;
	ZeroMemory( &sd,sizeof( sd ) );

D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc;
	memset( &srvDesc,0,sizeof( srvDesc ) );
You can avoid even having to ZeroMemory or memset by just putting empty curly braces after declarations

Code: Select all

D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc{}; 
which just zero initializes the struct.

There is also a really nice macro that I like to use for this kind of code,

Code: Select all

// This:
if( FAILED( hr = pSwapChain->GetBuffer(
		0,
		__uuidof( ID3D11Texture2D ),
		(LPVOID*)&pBackBuffer ) ) )
	{
		throw CHILI_GFX_EXCEPTION( hr,L"Getting back buffer" );
	}

// becomes this
if( FAILED( hr = pSwapChain->GetBuffer(
		0,
		IID_PPV_ARGS( &pBackBuffer ) ) ) )
	{
		throw CHILI_GFX_EXCEPTION( hr,L"Getting back buffer" );
	}
I know it works, but this might have been a typo,

Code: Select all

// This
	pImmediateContext->IASetPrimitiveTopology( D3D10_PRIMITIVE_TOPOLOGY_TRIANGLELIST );
// probably should be this since you are using DX11
	pImmediateContext->IASetPrimitiveTopology( D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST );
Your test compiles and runs on my system
AMD A10-7870K
Win10

I'm kind of surprised. I thought the feature level being 9.1 it would require 9.1 shader code/semantics.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

MrGodin
Posts: 721
Joined: November 30th, 2013, 7:40 pm
Location: Merville, British Columbia Canada

Re: Feedback on Framework 2016 - Draft

Post by MrGodin » June 26th, 2016, 11:10 pm

Build on Win 10,Intel 2 quad Q8200 2.34 GHz CPU, debug x64. AMD radeon HD 7700 series video card.
Ran fine, drug mouse and resized the green box.
Curiosity killed the cat, satisfaction brought him back

Pindrought
Posts: 432
Joined: September 26th, 2013, 4:57 pm
Location: Kentucky
Contact:

Re: Feedback on Framework 2016 - Draft

Post by Pindrought » June 27th, 2016, 3:32 am

Works on
Windows 7 64Bit
Intel I7 4770k
Radeon R9 390 GPU


On that note...
Never seen try catches like that. Very weird. Didn't know you could have multiple catches.
PM me if you need to contact me. Thanks to all the helpful people on this forum especially to Chili.

cameron
Posts: 794
Joined: June 26th, 2012, 5:38 pm
Location: USA

Re: Feedback on Framework 2016 - Draft

Post by cameron » June 27th, 2016, 4:30 am

There is a lot of new stuff in there that is cool and nice to see but there is a couple things I notice.

Your constexpr usage is strange to me, it almost seems you are using in place of inline or just const. You declare some things constexpr and never see it being used in a constant expression. I know constexpr implicitly means both const and inline(for functions) and can help with optimizations but I don't think it should be used in place of them. If I can't get what I want compile time with constexpr then I personally feel I would be better off with without it. I think the usage may confuse some people at some point as inline or const would be a better option. The MakeRGB function in addition to some of the static constants is good usage of constexpr, but I am mainly talking about those Event classes.

The exception handling is working cleanly and looks nice, I can never get it very clean so I don't use it much(I usually resort more to error codes). I also like the addition of the Colors header and extra keyboard support.

Also might be worth giving those nameless structs/unions names because its a non standard extension.

As far of things I was looking for as a beginner it would be nice to see some basic xaudio2 or something. But that can all wait until a later tutorial.
Last edited by cameron on June 28th, 2016, 2:16 am, edited 1 time in total.
Computer too slow? Consider running a VM on your toaster.

Nurlan
Posts: 22
Joined: January 4th, 2016, 3:45 am
Location: Saint-Petersburg. Russia

Re: Feedback on Framework 2016 - Draft

Post by Nurlan » June 27th, 2016, 9:19 am

Something don`t work. It gaves me a lot of errors(61)
What is an opposite of parallel.If you are engineer it is a series.If you are a mathematic-perpendicular

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: Feedback on Framework 2016 - Draft

Post by albinopapa » June 27th, 2016, 6:36 pm

Nurlan wrote:Something don`t work. It gaves me a lot of errors(61)
What operating system are you on?
What Visual Studio version are you using?
What processor and video card are you using?
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

User avatar
cyboryxmen
Posts: 190
Joined: November 14th, 2014, 2:03 am

Re: Feedback on Framework 2016 - Draft

Post by cyboryxmen » June 28th, 2016, 5:06 am

Looking at the way you implement constexpr, I actually managed to figure out a more efficient method of creating consts without the use of a static variable.

Code: Select all

namespace Colors
{
	template<unsigned char r, unsigned char g, unsigned char b>
	struct MakeRGB
	{
		static constexpr Color Value()
		{
			return (r << 16) | (g << 8) | b;
		}
	};
	using White = MakeRGB< 255u, 255u, 255u >;
	using Black = MakeRGB< 0u, 0u, 0u >;
	using Gray = MakeRGB< 0x80u, 0x80u, 0x80u >;
	using LightGray = MakeRGB< 0xD3u, 0xD3u, 0xD3u >;
	using Red = MakeRGB< 255u, 0u, 0u >;
	using Green = MakeRGB< 0u, 255u, 0u >;
	using Blue = MakeRGB< 0u, 0u, 255u >;
	using Yellow = MakeRGB< 255u, 255u, 0u >;
	using Cyan = MakeRGB< 0u, 255u, 255u >;
	using Magenta = MakeRGB< 255u, 0u, 255u >;
}

Code: Select all

	gfx.PutPixel( x,y,Colors::Red::Value() );
In theory, this has three advantages. One, it makes sure that the compiler optimises the code by inlining the result in straight away(there are some cases where it won't do that with static constexpr for certain runtime code.) Also, it saves memory as the compiler does usually save the value of the static as a variable in the code for runtime especially if you accidentally save a reference of it in code. This should also prevent you from doing that unnecessary as shown here.

Code: Select all

	static constexpr Color c = MakeRGB<0, 0, 0>::Result();
	void Do(Color const* i)
	{
		//impossible with template function
		i = &White::Value();
		//still possible with static constexpr
		i = &c;
	}
Really, the only disadvantage is that you need to type more just to get the value and you still need to make another MakeRGB function for runtime. In any case, I also made a basic struct to handle simple intrinsic type consts.

Code: Select all

	template<class Type, Type value>
	struct IntrinsicConst
	{
		static constexpr Type Value()
		{
			return value;
		}
	};

Code: Select all

private:
	using bufferSize = IntrinsicConst<unsigned int, 4u>;
-Zekilk
Zekilk

User avatar
LuisR14
Posts: 1248
Joined: May 23rd, 2013, 3:52 pm
Location: USA
Contact:

Re: Feedback on Framework 2016 - Draft

Post by LuisR14 » June 28th, 2016, 7:11 am

there's already a class that does exactly that last part tho, std::integral_constant xD

also, instead in your example i'd make the MakeRGB a function template, that would solve the "having to make a runtime version" dilemma
always available, always on, about ~10 years c/c++, java[script], win32/directx api, [x]html/css/php/some asp/sql experience. (all self taught)
Knows English, Spanish and Japanese.
[url=irc://irc.freenode.net/#pchili]irc://irc.freenode.net/#pchili[/url] [url=irc://luisr14.no-ip.org/#pchili]alt[/url] -- join up if ever want real-time help or to just chat :mrgreen: --

Nurlan
Posts: 22
Joined: January 4th, 2016, 3:45 am
Location: Saint-Petersburg. Russia

Re: Feedback on Framework 2016 - Draft

Post by Nurlan » June 28th, 2016, 11:21 am

Windows 10
Intel Core i5
Intel(R) HD Graphics 3000
Also my computer does not support diretx 11, maybe it will help
What is an opposite of parallel.If you are engineer it is a series.If you are a mathematic-perpendicular

Post Reply